BrushEstimator

class pybrush.BrushEstimator.BrushEstimator(**kwargs)[source]

This is the base class for Brush estimators using the c++ engine.

Parameters are defined and documented in EstimatorInterface

Attributes

best_estimator_pybrush.Program

The final model picked from training. Used in subsequent calls to predict().

archive_list[deap_api.DeapIndividual]

The final population from training.

data_pybrush.Dataset

The complete data in Brush format.

train_pybrush.Dataset

Partition of data_ containing `(1-validation_size)`% of the data, in Brush format.

validation_pybrush.Dataset

Partition of data_ containing `(validation_size)`% of the data, in Brush format.

search_space_a Brush SearchSpace object.

Holds the operators and terminals and sampling utilities to update programs.

> NOTE: as for now, when serializing the model with pickle, the objects of type Dataset and SearchSpace are not serialized.

fit(X, y)[source]

Fit an estimator to X,y.

Parameters

Xnp.ndarray

2-d array of input data.

ynp.ndarray

1-d array of (boolean) target values.

get_params(deep=True)[source]

Get parameters for this estimator.

Parameters

deepbool, default=True

If True, will return the parameters for this estimator and contained subobjects that are estimators.

Returns

paramsdict

Parameter names mapped to their values.

partial_fit(X, y, *, lock_nodes_depth=0, keep_leaves_unlocked=True, keep_current_weights=False)[source]

Fit an estimator to X,y, without reseting the estimator.

Parameters

Xnp.ndarray

2-d array of input data.

ynp.ndarray

1-d array of (boolean) target values.

lock_nodes_depthint, optional

The depth of the tree to lock. Default is 0.

keep_leaves_unlockedbool, optional

Whether to skip leaves when locking nodes. Default is True.

keep_current_weightsbool, optional

Whether to keep current weights at the spot they appear, and preventing them to be changed during optimization. Default is False.

predict(X)[source]

Predict using the best estimator in the archive.

set_partial_fit_request(*, keep_current_weights: bool | None | str = '$UNCHANGED$', keep_leaves_unlocked: bool | None | str = '$UNCHANGED$', lock_nodes_depth: bool | None | str = '$UNCHANGED$') BrushEstimator[source]

Configure whether metadata should be requested to be passed to the partial_fit method.

Note that this method is only relevant when this estimator is used as a sub-estimator within a meta-estimator and metadata routing is enabled with enable_metadata_routing=True (see sklearn.set_config()). Please check the User Guide on how the routing mechanism works.

The options for each parameter are:

  • True: metadata is requested, and passed to partial_fit if provided. The request is ignored if metadata is not provided.

  • False: metadata is not requested and the meta-estimator will not pass it to partial_fit.

  • None: metadata is not requested, and the meta-estimator will raise an error if the user provides it.

  • str: metadata should be passed to the meta-estimator with this given alias instead of the original name.

The default (sklearn.utils.metadata_routing.UNCHANGED) retains the existing request. This allows you to change the request for some parameters and not others.

Added in version 1.3.

Parameters

keep_current_weightsstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for keep_current_weights parameter in partial_fit.

keep_leaves_unlockedstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for keep_leaves_unlocked parameter in partial_fit.

lock_nodes_depthstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for lock_nodes_depth parameter in partial_fit.

Returns

selfobject

The updated object.