Атрибут estimators_
требует, чтобы модель была установлена первой:
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=3, random_state=0)
clf.estimators_
# AttributeError: 'BaggingClassifier' object has no attribute 'estimators_'
clf.fit(X, y)
clf.estimators_
# result:
[SVC(C=1.0, break_ties=False, cache_size=200, class_weight=None, coef0=0.0,
decision_function_shape='ovr', degree=3, gamma='scale', kernel='rbf',
max_iter=-1, probability=False, random_state=2087557356, shrinking=True,
tol=0.001, verbose=False),
SVC(C=1.0, break_ties=False, cache_size=200, class_weight=None, coef0=0.0,
decision_function_shape='ovr', degree=3, gamma='scale', kernel='rbf',
max_iter=-1, probability=False, random_state=132990059, shrinking=True,
tol=0.001, verbose=False),
SVC(C=1.0, break_ties=False, cache_size=200, class_weight=None, coef0=0.0,
decision_function_shape='ovr', degree=3, gamma='scale', kernel='rbf',
max_iter=-1, probability=False, random_state=1109697837, shrinking=True,
tol=0.001, verbose=False)]