I am experimenting with BagginClassifier, but I fail to get the expected functionality.
Basically, the BagginClassifier should draw (bootstrapping) a new data set with replacement. For example: the following code should generate a new bootstrapped sample of the same size as the original data set:
import sklearn.datasets as ds import numpy as np X, y = ds.load_iris().data, ds.load_iris().target bag = BaggingClassifier(base_estimator=LogisticRegression(), n_estimators=100, max_samples=1.0, bootstrap=True, n_jobs=1) bag.fit(X, y) print X[bag.estimators_samples_].shape >> 95
(or any other number close to 95).
Naively, I would expect to get the bootstrapped sample of the same size as the original one (150), but with some random repetition of rows. However, I get a smaller sample size with unique rows. That's strange.
What's wrong here?