This package defines model trees as scikit-learn compatible estimators. These can be used for both classification and regression.
The model trees use the gradient-based split criterion from [1]
The modeltrees package can directly be installed from GitHub using pip:
pip install https://github.com/schufa-innovationlab/model-trees/archive/master.zip
Now you are ready to start, e.g. with our introductory example
The modeltrees package is still under development. You can install the current development version via
pip install https://github.com/schufa-innovationlab/model-trees/archive/dev.zip
There might be reasons not to use pip with GitHub, e.g. because some proxy does not allows to connect to GitHub, or pip is just not your tool of choice (keep in mind: you can also use pip in a conda setup).
In that case you could:
- Clone the repository locally and use the local path instead of aboves GitHub path.
- You can just copy the
modeltrees
folder into your projects source root. In that case, you have to install the dependencies manually.
The package provides two estimator classes:
ModelTreeRegressor
for regression and ModelTreeClassifier
for classification.
Both provide default settings for the base estimators used in the leafs and can directly be used.
from modeltrees import ModelTreeRegressor
import numpy as np
X = np.random.randn(10000, 3)
y = np.matmul(X, [[-1], [2], [1.5]]) + np.random.randn(10000, 1) * 0.2
mt = ModelTreeRegressor()
mt.fit(X,y)
p = mt.predict([[1, 2, 3]])
print(f"Prediction: {p}")
There is an examples
folder that contains further examples and evaluations.
See the corresponding readme for further details and a list of examples.
[1] Broelemann, K. and Kasneci, G.; A Gradient-Based Split Criterion for Highly Accurate and Transparent Model Trees; International Joint Conference on Artificial Intelligence (IJCAI) 2019; pdf
Bibtex
@inproceedings{Broelemann2019modeltrees,
author = {Klaus Broelemann and Gjergji Kasneci},
title = {A Gradient-Based Split Criterion for Highly
Accurate and Transparent Model Trees},
booktitle = {Proceedings of the 28th International Joint
Conference on Artificial Intelligence, {IJCAI} 2019},
year = 2019
}