neural_trees.distill#
- neural_trees.distill(teacher, X, *, student=None, X_eval=None, threshold: float = 0.01, random_state: int | None = None) Distilled[source]#
Fit a soft tree to the probabilities of a fitted classifier.
- Parameters:
- teacherfitted classifier with predict_proba and classes_
XGBoost, LightGBM, a random forest, or any scikit-learn classifier.
- Xarray-like of shape (n_samples, n_features)
Rows to transfer on, usually the teacher’s training rows, on the scale the teacher expects. Soft trees learn best on standardised features: put a StandardScaler in front of both if the teacher was fitted on raw ones, or pass a student inside a pipeline.
- studentunfitted SoftDecisionTree, optional
Defaults to
SoftDecisionTree(depth=6, growth="per_leaf", growth_init="residual", max_epochs=180), the configuration measured above. Passsplit_features=kin it for rules that read more easily, at a measured cost in fidelity.- X_evalarray-like, optional
Held-out rows for the fidelity report.
- thresholdfloat, default=0.01
A class enters a row’s soft target only with at least this teacher probability; it keeps the repeated rows few.
- random_stateint, optional
Seed for the default student.
- Returns:
- Distilled