Nodes and weights¶
EvoDAG.node¶
The individuals. Variable is an input variable
scaled by a coefficient and Function is the base of
the functions that combine other individuals. The coefficients of a node are
found by ordinary least squares
(compute_weight), except those of the Naive
Bayes and Centroid nodes, which come from the class labels.
- class Variable[source]¶
Bases:
objectTerminal node: a variable of the input (or a stored node) times a least-squares weight; arity 0.
- property height¶
Height of the node in the DAG; zero for the nodes created directly from the inputs.
- tostore()[source]¶
Return a light copy that keeps the variable, weight, position, height and fitness but not the outputs.
- w2dict()[source]¶
Return the weight with each entry converted to plain Python lists, ready to be serialized.
- tojson()[source]¶
Return a JSON string with the node class, variable, weight, position, height and fitness.
- property position¶
Position where this variable is in the history
- property fitness¶
Stores the fitness on the training set
- property fitness_vs¶
Stores the fitness on the validation set
- property variable¶
The variable is indicated by the position in EvoDAG.X
- property weight¶
The weight is obtained by OLS on RootGP._ytr
- raw_outputs(X)[source]¶
Return the outputs of the referenced variable on the training and test sets, before the weight.
- set_weight(r)[source]¶
Compute the weight by least squares on the training set if not set; False if it cannot be computed.
- eval(X)[source]¶
Evaluate the node on X, setting hy and hy_test to the weighted outputs; False if no weight is found.
- property hy¶
Predicted values of the training and validation set
- labels(classifier=True)[source]¶
Labels predicted by the node on the training examples, remembered until
hyis replaced or released:argmaxof the outputs in classification andsign + 1of the output in regression. They are what the agreement heuristic compares, thousands of times per fit.
- property density¶
Fraction of the entries of the predicted values that are not zero (average over the outputs); it drives the choice of functions
- property hy_test¶
Predicted values of the test set
- class Function[source]¶
Bases:
VariableBase class of the nodes that combine other nodes; two arguments by default.
- tostore()[source]¶
Return a light copy of the node as in Variable, which also stores the number of arguments.
- signature()[source]¶
Return a string made of the symbol and the argument positions, used to detect repeated nodes.
- hy2listM(X)[source]¶
Return the training and test outputs of the argument nodes X as lists, one list per output if multiple.
- class Function1[source]¶
Bases:
FunctionBase class of the nodes that apply a function to their arguments and fit one weight per output.
- class Add[source]¶
Bases:
FunctionSum of its arguments, each times a least-squares coefficient; arity 5 by default (at least 2); symbol +.
- class Mul[source]¶
Bases:
Function1Element-wise product of its arguments (two by default), scaled by a least-squares weight; symbol
*.
- class Div[source]¶
Bases:
Function1Element-wise division of the first argument by the second, scaled by a least-squares weight; symbol /.
- class Atan2[source]¶
Bases:
Function1Element-wise two-argument arctangent of its two arguments, scaled by a least-squares weight; symbol atan2.
- class Hypot[source]¶
Bases:
Function1Element-wise square root of the sum of the squares of its two arguments, scaled by a least-squares weight.
- class OneArg[source]¶
Bases:
Function1Base class of the nodes with a single argument that apply a function element-wise and scale it by a weight.
- class Acos[source]¶
Bases:
OneArgElement-wise arccosine of its single argument, scaled by a least-squares weight; arity 1.
- class Asin[source]¶
Bases:
OneArgElement-wise arcsine of its single argument, scaled by a least-squares weight; arity 1.
- class Atan[source]¶
Bases:
OneArgElement-wise arctangent of its single argument, scaled by a least-squares weight; arity 1.
- class Cos[source]¶
Bases:
OneArgElement-wise cosine of its single argument, scaled by a least-squares weight; arity 1.
- class Sin[source]¶
Bases:
OneArgElement-wise sine of its single argument, scaled by a least-squares weight; arity 1.
- class Tan[source]¶
Bases:
OneArgElement-wise tangent of its single argument, scaled by a least-squares weight; arity 1.
- class Cosh[source]¶
Bases:
OneArgElement-wise hyperbolic cosine of its single argument, scaled by a least-squares weight; arity 1.
- class Sinh[source]¶
Bases:
OneArgElement-wise hyperbolic sine of its single argument, scaled by a least-squares weight; arity 1.
- class Tanh[source]¶
Bases:
OneArgElement-wise hyperbolic tangent of its single argument, scaled by a least-squares weight; arity 1.
- class Acosh[source]¶
Bases:
OneArgElement-wise inverse hyperbolic cosine of its single argument, scaled by a least-squares weight; arity 1.
- class Asinh[source]¶
Bases:
OneArgElement-wise inverse hyperbolic sine of its single argument, scaled by a least-squares weight; arity 1.
- class Atanh[source]¶
Bases:
OneArgElement-wise inverse hyperbolic tangent of its single argument, scaled by a least-squares weight; arity 1.
- class Exp[source]¶
Bases:
OneArgElement-wise exponential of its single argument, scaled by a least-squares weight; arity 1.
- class Expm1[source]¶
Bases:
OneArgElement-wise exponential minus one of its single argument, scaled by a least-squares weight; arity 1.
- class Log[source]¶
Bases:
OneArgElement-wise natural logarithm of its single argument, scaled by a least-squares weight; arity 1.
- class Log2[source]¶
Bases:
OneArgElement-wise base 2 logarithm of its single argument, scaled by a least-squares weight; arity 1.
- class Log10[source]¶
Bases:
OneArgElement-wise base 10 logarithm of its single argument, scaled by a least-squares weight; arity 1.
- class Log1p[source]¶
Bases:
OneArgElement-wise natural logarithm of one plus the value of its single argument, scaled by a least-squares weight; arity 1.
- class Lgamma[source]¶
Bases:
OneArgElement-wise logarithm of the absolute value of the gamma function of its single argument, scaled by a least-squares weight; arity 1.
- class Sqrt[source]¶
Bases:
OneArgElement-wise square root of its single argument, scaled by a least-squares weight; arity 1.
- class Sq[source]¶
Bases:
OneArgElement-wise square of its single argument, scaled by a least-squares weight; arity 1.
- class Sign[source]¶
Bases:
OneArgElement-wise sign (-1, 0 or 1) of its single argument, scaled by a least-squares weight; arity 1.
- class Fabs[source]¶
Bases:
OneArgElement-wise absolute value of its single argument, scaled by a least-squares weight; arity 1.
- class Ceil[source]¶
Bases:
OneArgElement-wise ceiling of its single argument, scaled by a least-squares weight; arity 1.
- class Floor[source]¶
Bases:
OneArgElement-wise floor of its single argument, scaled by a least-squares weight; arity 1.
- class Min[source]¶
Bases:
Function1Element-wise minimum of its arguments (two by default, at least 2), scaled by a least-squares weight.
- class Max[source]¶
Bases:
Function1Element-wise maximum of its arguments (two by default, at least 2), scaled by a least-squares weight.
- class Argmax[source]¶
Bases:
Function1Position of the argument with the largest value at each element, scaled by a least-squares weight.
- class Argmin[source]¶
Bases:
ArgmaxPosition of the argument with the smallest value at each element, scaled by a least-squares weight.
- class NaiveBayes[source]¶
Bases:
FunctionGaussian naive Bayes over its arguments, with one output per class; classification only; symbol NB.
- hy2listM(X)[source]¶
Return the training and test outputs of the argument nodes X as flat lists of vectors.
- w2dict()[source]¶
Return the weight (class coefficients, used arguments and number of classes) with plain Python lists.
- set_weight(X)[source]¶
Compute the per-class mean, variance and prior of each argument from the training set; False on failure.
- class NaiveBayesMN[source]¶
Bases:
NaiveBayesMultinomial naive Bayes over its arguments, with one output per class; classification only; symbol MN.
- set_weight(X)[source]¶
Compute the per-class log proportions and log priors of the arguments from the training set.
- class MultipleVariables[source]¶
Bases:
AddSum of all the input variables, each times a least-squares coefficient fitted jointly; symbol X.
- raw_outputs(X)[source]¶
Return the outputs of all the variables on the training and test sets, before the weights.
- class Centroid[source]¶
Bases:
NaiveBayesNegative squared Euclidean distance to the class centroids of its arguments, one output per class; symbol Centroid.
- set_weight(hy)[source]¶
Compute, from the training set, the negative mean of each argument in each class.