8000 RandomForestRegressor in GridSearchCV uses more cores than specified · Issue #12289 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content
RandomForestRegressor in GridSearchCV uses more cores than specified #12289
Closed
@TomDLT

Description

@TomDLT

RandomForestRegressor in GridSearchCV uses more cores than specified.

import numpy as np
from sklearn.ensemble import RandomForestRegressor
from sklearn.model_selection import GridSearchCV

n_samples, n_features = 10000, 10
X = np.random.randn(n_samples, n_features)
y = np.random.randn(n_samples)

grid = {'n_estimators': [100, 200]}

# only one core is used (GOOD)
rfr = RandomForestRegressor(n_estimators=100)
rfr.fit(X, y)

# only two cores are used (GOOD)
rfr = RandomForestRegressor(n_estimators=100, n_jobs=1)
gsc = GridSearchCV(rfr, grid, n_jobs=2)
gsc.fit(X, y)

# more than two cores are used (BUG)
rfr = RandomForestRegressor(n_estimators=100)
gsc = GridSearchCV(rfr, grid, n_jobs=2)
gsc.fit(X, y)

This bug was introduced in #11741. @ogrisel @tomMoral

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0