neural_trees.DistilledFIGS#

class neural_trees.DistilledFIGS(teacher=None, max_rules: int = 256, synthetic: int = 0, random_state: int | None = None)[source]#

Bases: ClassifierMixin, BaseEstimator

A FIGS model trained on what a strong model learned: fit trains the teacher on (X, y), then a FIGSRegressor with max_rules splits on the teacher’s probability of each class (one regressor for two classes, one per class otherwise). Prediction uses only the FIGS model(s); the teacher is kept to measure agreement.

Parameters:
teacherclassifier with predict_proba, default=None

Cloned and fitted on (X, y). None uses scikit-learn’s HistGradientBoostingClassifier(). The measurements in the module docstring used a tuned XGBoost teacher.

max_rulesint, default=256

Split budget of each FIGS regressor. 256 to 512 is where the gain over FIGS on labels was measured; with several classes the total size is n_classes * max_rules.

syntheticint, default=0

MUNGE passes over the rows (see neural_trees.distillation.munge), labelled by the teacher for the student. Did not help in the measurements; kept for small tables.

random_stateint, optional

Seeds FIGS and the synthetic rows.

Attributes:
teacher_the fitted teacher
figs_list of fitted imodels.FIGSRegressor, one per modelled class
classes_, n_features_in_
complexity_int, total number of splits over figs_
fidelity(X) → float[source]#

Share of rows of X where this model predicts the teacher’s class.

set_fit_request(*, sample_weight: bool | None | str = '$UNCHANGED$') → DistilledFIGS#

Configure whether metadata should be requested to be passed to the 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 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 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:
sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in fit.

Returns:
selfobject

The updated object.

set_score_request(*, sample_weight: bool | None | str = '$UNCHANGED$') → DistilledFIGS#

Configure whether metadata should be requested to be passed to the score 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 score 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 score.

  • 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:
sample_weightstr, True, False, or None, default=sklearn.utils.metadata_routing.UNCHANGED

Metadata routing for sample_weight parameter in score.

Returns:
selfobject

The updated object.