scikit-learn-contrib / py-earth

A Python implementation of Jerome Friedman's Multivariate Adaptive Regression Splines
http://contrib.scikit-learn.org/py-earth/
BSD 3-Clause "New" or "Revised" License
455 stars 121 forks source link

Fitting MARS with distinct values-labels #177

Closed florakarniav closed 6 years ago

florakarniav commented 6 years ago

Hello, This is more of a question than an issue. I would like to know if it is possible to configure MARS to make predictions of distinct values.

For example if my Y takes values in 2,4,8, is there any way to make y_hat produce results consisting of these values only?

Thank you in advance

jcrudy commented 6 years ago

@florakarniav In scikit-learn terminology, what you want is a classifier, while Earth is a regressor. It's possible to create a classifier from one or more Earth models, but it might be easier to just use an existing classifier such as RandomForest. See http://scikit-learn.org/stable/modules/ensemble.html#random-forests. If you do want to form a classifier from Earth models, the simplest way is to create a Pipeline with two steps, the first being an Earth model and the second a LogisticRegression model. It's also possible to use gradient boosting to produce a classifier from multiple Earth models, but the code to do that is not well-tested or packaged yet.