Skip to content

GridSearchCV is not properly working with RandomBoosting*() #1

@tkrabel

Description

@tkrabel
model = RandomBoostingRegressor()
rb = GridSearchCV(model, param_grid={'n_estimators':[75, 100, 150]}, cv=5)
rb = rb.fit(X_train, y_train)

This code fails with an IndexError

File ".../python_random_boost/random_boost/random_boost.py", line 1183, in _fit_stage self.depths_[i] = depth
IndexError: index 100 is out of bounds for axis 0 with size 100

The reason is that RandomBoostingRegressor() is initialized with n_estimators=100, and it seems GridSearchCV() is not able to properly overwrite n_estimators when searching the grid (hence leading to an error when it tries out n_estimators=150. This is not a problem with GradientBoostingRegressor(), which has the same default value for n_estimators.

In essence, the problem is related to the fact that I create a vector in which I save the drawn tree depth values. The length of this vector equals n_estimators and seems to be set to 100 independent from the actual value tried out by GridSearchCV.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions