desdeo_emo.surrogatemodels.BioGP

Module Contents

Classes

Node

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

LinearNode

The parent node of the tree, from which a number of subtrees emerge, as defined

BioGP

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

Functions

negative_r2_score(y_true, y_pred)

desdeo_emo.surrogatemodels.BioGP.negative_r2_score(y_true, y_pred)[source]
class desdeo_emo.surrogatemodels.BioGP.Node(value, depth, max_depth, max_subtrees, prob_terminal, function_set, terminal_set)[source]

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

Parameters:
  • value (function, str or float) – A function node has as its value a function. Terminal nodes contain variables which are either float or str.

  • depth (int) – The depth the node is at.

  • function_set (array_like) – The function set to use when creating the trees.

  • terminal_set (array_like) – The terminals (variables and constants) to use when creating the trees.

predict(decision_variables=None)[source]
node_label()[source]
draw(dot, count)[source]
get_sub_nodes()[source]

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

Returns:

nodes – A list of nodes in the subtree.

Return type:

list

grow_tree(max_depth=None, method='grow', depth=0, ind=None)[source]

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

Parameters:
  • max_depth (int) – The maximum depth of the tree.

  • method (str) – 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.

  • depth (int) – Current depth.

  • ind – The starting node from which to begin growing trees.

class desdeo_emo.surrogatemodels.BioGP.LinearNode(max_depth, max_subtrees, prob_terminal, function_set, terminal_set, error_lim, complexity_scalar=0.5, value='linear', depth=0)[source]

Bases: 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.

Parameters:
  • value (function, str or float) – A function node has as its value a function. Terminal nodes contain variables which are either float or str.

  • depth (int) – The depth the node is at.

calculate_linear(X_train, y_train)[source]
class desdeo_emo.surrogatemodels.BioGP.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)[source]

Bases: desdeo_problem.surrogatemodels.SurrogateModels.BaseRegressor

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

fit(X: pandas.DataFrame, y: pandas.DataFrame)[source]
_create_individuals()[source]
_model_performance(trees: LinearNode, X: numpy.ndarray = None, y: numpy.ndarray = None)[source]
predict(X: numpy.ndarray)[source]
select()[source]
static add(x, y)[source]
static sub(x, y)[source]
static mul(x, y)[source]
static div(x, y)[source]
static sqrt(x)[source]
static log(x)[source]
static sin(x)[source]
static cos(x)[source]
static tan(x)[source]
static neg(x)[source]