scikit-learn compatible classification and regression
The partition_tree.sklearn module provides estimators that follow the familiar scikit-learn API: fit, predict, predict_proba, cross-validation, and pipeline compatibility.
Available estimators
PartitionTreeClassifier
PartitionForestClassifier
PartitionTreeRegressor
PartitionForestRegressor
Choose a tutorial
Use the task-specific walkthroughs for concrete examples and metrics:
from sklearn.datasets import load_irisfrom sklearn.model_selection import train_test_splitfrom partition_tree.sklearn import PartitionTreeClassifierX, y = load_iris(return_X_y=True)X_train, X_test, y_train, y_test = train_test_split(X, y, random_state=42)clf = PartitionTreeClassifier(max_leaves=20, random_state=42)clf.fit(X_train, y_train)clf.predict(X_test[:5])
/home/runner/work/partition_tree/partition_tree/partition_tree/src/partition_tree/sklearn/partition_tree.py:27: FutureWarning: Series.__getitem__ treating keys as positions is deprecated. In a future version, integer keys will always be treated as labels (consistent with DataFrame behavior). To access a value by position, use `ser.iloc[pos]`
y_dtype = y_df.dtypes[0]
array([1, 0, 2, 1, 1])
Notes
Use the classifier variants for discrete targets.
Use the regressor variants for numeric targets.
For full predictive distributions, switch to the skpro tutorial.