Issue
Is it possible to see the individual base classifiers that are formed by BaggingClassifier()
? The code I am working with is the example code from the sklearn library for making a prediction via bagging:
from sklearn.svm import SVC
from sklearn.ensemble import BaggingClassifier
from sklearn.datasets import make_classification
X, y = make_classification(n_samples=100, n_features=4,
n_informative=2, n_redundant=0,
random_state=0, shuffle=False)
clf = BaggingClassifier(base_estimator=SVC(),
n_estimators=10, random_state=0).fit(X, y)
clf.predict([[0, 0, 0, 0]])
The code correctly returns the prediction, but I need to see the models that were actually formed by BaggingClassifier
.
Solution
They are available in the estimators_
attribute. See the docs.
Answered By - Ben Reiniger
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.