eqdisco.models.SymbolicClassifier#

class eqdisco.models.SymbolicClassifier(population_size=300, generations=30, functions=('add', 'sub', 'mul', 'div', 'sin', 'cos', 'exp', 'log', 'sqrt', 'square'), decision='logistic', loss=None, class_weight=None, optimize='none', optimize_fraction=0.1, optimize_iterations=20, selection='tournament', tournament_size=5, parsimony=0.0, complexity='size', init_depth=(2, 5), max_depth=10, max_size=50, p_crossover=0.7, crossover='subtree', p_subtree_mutation=0.4, p_point_mutation=0.25, p_hoist_mutation=0.1, p_constant_mutation=0.15, p_shrink_mutation=0.05, p_insert_mutation=0.05, p_constant=0.2, const_range=(-5.0, 5.0), n_islands=1, migration_interval=10, migration_size=2, elitism=1, constraints=None, units=None, constraint_weight=10.0, seed_equations=None, library=None, p_library=0.05, library_learning=False, library_interval=5, llm_proposer=None, llm_interval=5, llm_n_proposals=5, validation_fraction=0.0, model_selection='best', patience=None, time_limit=None, max_evaluations=None, feature_names=None, random_state=None, verbose=0)[source]#

Bases: _TreeGP, ClassifierMixin

Genetic programming for classification by a symbolic decision function.

Binary problems evolve one expression \(f\); multi-class problems are solved one-versus-rest. With decision="logistic" the probability of the positive class is \(\sigma(a+bf)\) with \(a, b\) fitted by logistic regression for every candidate, and the loss is the cross-entropy. With decision="sign" the classifier is the critical equation \(f(\mathbf{x})>0\) and the loss is the balanced error, as in the GP-based identification of reactor runaway criteria of Kummer, Varga and Abonyi (2019).

The parameters are those of SymbolicRegressor; loss is "log_loss" or "balanced_error" (defaults follow decision), class_weight="balanced" reweights the classes, and optimize="lbfgs" tunes the parameters of the best offspring by L-BFGS on the cross-entropy (logistic decision).

Attributes:
equation_Equation

Decision function (binary problems): positive class where it is above 0.

equations_dict

Decision function of every class (multi-class problems).

classes_ndarray
decision_function(X)[source]#

Value of the decision function(s): shape (N,) for two classes, (N, K) otherwise.

fit(X, y)[source]#

Run the search on (X, y) with class labels y.

predict_proba(X)[source]#

Class probabilities (logistic transform of the decision functions).