:py:mod:`desdeo_emo.surrogatemodels.BioGP`
==========================================

.. py:module:: desdeo_emo.surrogatemodels.BioGP


Module Contents
---------------

Classes
~~~~~~~

.. autoapisummary::

   desdeo_emo.surrogatemodels.BioGP.Node
   desdeo_emo.surrogatemodels.BioGP.LinearNode
   desdeo_emo.surrogatemodels.BioGP.BioGP



Functions
~~~~~~~~~

.. autoapisummary::

   desdeo_emo.surrogatemodels.BioGP.negative_r2_score



.. py:function:: negative_r2_score(y_true, y_pred)


.. py:class:: Node(value, depth, max_depth, max_subtrees, prob_terminal, function_set, terminal_set)

   A node object representing a function or terminal node in the tree.

   :param value: A function node has as its value a function. Terminal nodes contain variables
                 which are either float or str.
   :type value: function, str or float
   :param depth: The depth the node is at.
   :type depth: int
   :param function_set: The function set to use when creating the trees.
   :type function_set: array_like
   :param terminal_set: The terminals (variables and constants) to use when creating the trees.
   :type terminal_set: array_like

   .. py:method:: predict(decision_variables=None)


   .. py:method:: node_label()


   .. py:method:: draw(dot, count)


   .. py:method:: get_sub_nodes()

      Get all nodes belonging to the subtree under the current node.

      :returns: **nodes** -- A list of nodes in the subtree.
      :rtype: list


   .. py:method:: grow_tree(max_depth=None, method='grow', depth=0, ind=None)

      Create a random tree recursively using either grow or full method.

      :param max_depth: The maximum depth of the tree.
      :type max_depth: int
      :param method: Methods: 'grow', 'full'.
                     For the 'grow' method, nodes are chosen at random from both functions and
                     terminals.
                     The 'full' method chooses nodes from the function set until the max depth
                     is reached,
                     and then terminals are chosen.
      :type method: str
      :param depth: Current depth.
      :type depth: int
      :param ind: The starting node from which to begin growing trees.
      :type ind: :obj:



.. py:class:: LinearNode(max_depth, max_subtrees, prob_terminal, function_set, terminal_set, error_lim, complexity_scalar=0.5, value='linear', depth=0)

   Bases: :py:obj:`Node`

   The parent node of the tree, from which a number of subtrees emerge, as defined
   by the user. The linear node takes a weighted sum of the output from the subtrees
   and
   also uses a bias value. The weights and the bias are calculated by the linear least
   square technique.

   :param value: A function node has as its value a function. Terminal nodes contain variables
                 which are either float or str.
   :type value: function, str or float
   :param depth: The depth the node is at.
   :type depth: int

   .. py:method:: calculate_linear(X_train, y_train)



.. py:class:: BioGP(training_algorithm: Type[desdeo_emo.EAs.BaseEA.BaseEA] = PPGA, pop_size: int = 500, probability_crossover: float = 0.9, probability_mutation: float = 0.3, max_depth: int = 5, max_subtrees: int = 4, prob_terminal: float = 0.5, complexity_scalar: float = 0.5, error_lim: float = 0.001, init_method: str = 'ramped_half_and_half', model_selection_criterion: str = 'min_error', loss_function: str = 'mse', single_obj_generations: int = 10, function_set=('add', 'sub', 'mul', 'div'), terminal_set=None)

   Bases: :py:obj:`desdeo_problem.surrogatemodels.SurrogateModels.BaseRegressor`

   Helper class that provides a standard way to create an ABC using
   inheritance.

   .. py:method:: fit(X: pandas.DataFrame, y: pandas.DataFrame)


   .. py:method:: _create_individuals()


   .. py:method:: _model_performance(trees: LinearNode, X: numpy.ndarray = None, y: numpy.ndarray = None)


   .. py:method:: predict(X: numpy.ndarray)


   .. py:method:: select()


   .. py:method:: add(x, y)
      :staticmethod:


   .. py:method:: sub(x, y)
      :staticmethod:


   .. py:method:: mul(x, y)
      :staticmethod:


   .. py:method:: div(x, y)
      :staticmethod:


   .. py:method:: sqrt(x)
      :staticmethod:


   .. py:method:: log(x)
      :staticmethod:


   .. py:method:: sin(x)
      :staticmethod:


   .. py:method:: cos(x)
      :staticmethod:


   .. py:method:: tan(x)
      :staticmethod:


   .. py:method:: neg(x)
      :staticmethod:



