Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use custom classifiers in ensemble classifiers in sklearn?

I read that the builtin ensemble methods in sklearn use decision trees as the base classifiers. Is it possible to use custom classifiers instead?

like image 638
Karthick Avatar asked May 09 '12 14:05

Karthick


People also ask

Why is an ensemble of classifiers better than a single classifier?

There are two main reasons to use an ensemble over a single model, and they are related; they are: Performance: An ensemble can make better predictions and achieve better performance than any single contributing model. Robustness: An ensemble reduces the spread or dispersion of the predictions and model performance.

Is ensemble of classifiers more accurate than any of its individual model?

True or False: Ensemble of classifiers may or may not be more accurate than any of its individual model. Usually, ensemble would improve the model, but it is not necessary. Hence, option A is correct.

Can I put a keras model in an Sklearn ensemble method?

This one line wrapper call converts the keras model into a scikit-learn model that can be used for Hyperparameter tuning using grid search, Random search etc but it can also be used, as you guessed it, for ensemble methods.


3 Answers

If you mean the random forest classes, then no, this is currently not possible. The option to allow other estimators was discussed on the scikit-learn mailing list last January, but I don't believe any actual code has come out that discussion.

like image 84
Fred Foo Avatar answered Oct 29 '22 22:10

Fred Foo


If you use sklearn.ensemble.AdaBoostClassifier, then the answer is yes: scikit-learn.org/stable/modules/generated/sklearn.ensemble.AdaBoostClassifier.html You can assign base_estimator yourself.

like image 24
andy Avatar answered Oct 29 '22 21:10

andy


I don't know if it helps, but you can very easily stack/combine custom classifiers using the Pipeline utilities: http://scikit-learn.org/stable/tutorial/statistical_inference/putting_together.html#pipelining

like image 23
user1151446 Avatar answered Oct 29 '22 20:10

user1151446