是否可以查看Bagging Classifier形成的模型?
Is it possible to view the models formed by Bagging Classifier?
是否可以看到由BaggingClassifier()
形成的各个基分类器?我正在使用的代码是来自 sklearn 库的示例代码,用于通过装袋进行预测:
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]])
代码正确 returns 预测,但我需要查看 BaggingClassifier
实际形成的模型。
它们在 estimators_
属性中可用。参见 the docs。
是否可以看到由BaggingClassifier()
形成的各个基分类器?我正在使用的代码是来自 sklearn 库的示例代码,用于通过装袋进行预测:
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]])
代码正确 returns 预测,但我需要查看 BaggingClassifier
实际形成的模型。
它们在 estimators_
属性中可用。参见 the docs。