Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix RF slowdown with n_jobs=-1 #206

Merged
merged 2 commits into from
Nov 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Changelog
* Added support for unlimited pipelines with a max_time limit :pr:`70`
* Updated .readthedocs.yaml to successfully build :pr:`188`
* Fixes
* Fixed slow down in RFRegressor :pr:`206`
* Changes
* Refactored pipelines :pr:`108`
* Removed guardrails from Auto(*) :pr:`202`
Expand Down
3 changes: 2 additions & 1 deletion evalml/pipelines/classification/random_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RFClassificationPipeline(PipelineBase):
}

def __init__(self, objective, n_estimators, max_depth, impute_strategy,
percent_features, number_features, n_jobs=1, random_state=0):
percent_features, number_features, n_jobs=-1, random_state=0):

imputer = SimpleImputer(impute_strategy=impute_strategy)
enc = OneHotEncoder()
Expand All @@ -39,6 +39,7 @@ def __init__(self, objective, n_estimators, max_depth, impute_strategy,
number_features=number_features,
percent_features=percent_features,
threshold=-np.inf,
n_jobs=n_jobs,
random_state=random_state)

super().__init__(objective=objective,
Expand Down
3 changes: 2 additions & 1 deletion evalml/pipelines/classification/xgboost.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class XGBoostPipeline(PipelineBase):
}

def __init__(self, objective, eta, min_child_weight, max_depth, impute_strategy,
percent_features, number_features, n_estimators=10, n_jobs=1, random_state=0):
percent_features, number_features, n_estimators=10, n_jobs=-1, random_state=0):

imputer = SimpleImputer(impute_strategy=impute_strategy)
enc = OneHotEncoder()
Expand All @@ -36,6 +36,7 @@ def __init__(self, objective, eta, min_child_weight, max_depth, impute_strategy,
number_features=number_features,
percent_features=percent_features,
threshold=-np.inf,
n_jobs=n_jobs,
random_state=random_state)
estimator = XGBoostClassifier(random_state=random_state,
eta=eta,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ class RFClassifierSelectFromModel(FeatureSelector):
}

def __init__(self, number_features=None, n_estimators=10, max_depth=None,
percent_features=0.5, threshold=-np.inf, random_state=0):
percent_features=0.5, threshold=-np.inf, n_jobs=-1, random_state=0):
max_features = None
if number_features:
max_features = max(1, int(percent_features * number_features))
parameters = {"percent_features": percent_features,
"threshold": threshold}
estimator = SKRandomForestClassifier(random_state=random_state,
n_estimators=n_estimators,
max_depth=max_depth)
max_depth=max_depth,
n_jobs=n_jobs)
feature_selection = SkSelect(
estimator=estimator,
max_features=max_features,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,16 @@ class RFRegressorSelectFromModel(FeatureSelector):
}

def __init__(self, number_features=None, n_estimators=10, max_depth=None,
percent_features=0.5, threshold=-np.inf, random_state=0):
percent_features=0.5, threshold=-np.inf, n_jobs=-1, random_state=0):
max_features = None
if number_features:
max_features = max(1, int(percent_features * number_features))
parameters = {"percent_features": percent_features,
"threshold": threshold}
estimator = SKRandomForestRegressor(random_state=random_state,
n_estimators=n_estimators,
max_depth=max_depth)
max_depth=max_depth,
n_jobs=n_jobs)
feature_selection = SkSelect(
estimator=estimator,
max_features=max_features,
Expand Down
3 changes: 2 additions & 1 deletion evalml/pipelines/regression/random_forest.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class RFRegressionPipeline(PipelineBase):
}

def __init__(self, objective, n_estimators, max_depth, impute_strategy, percent_features,
number_features, n_jobs=1, random_state=0):
number_features, n_jobs=-1, random_state=0):

imputer = SimpleImputer(impute_strategy=impute_strategy)
enc = OneHotEncoder()
Expand All @@ -35,6 +35,7 @@ def __init__(self, objective, n_estimators, max_depth, impute_strategy, percent_
number_features=number_features,
percent_features=percent_features,
threshold=-np.inf,
n_jobs=n_jobs,
random_state=random_state)
estimator = RandomForestRegressor(random_state=random_state,
n_estimators=n_estimators,
Expand Down
2 changes: 1 addition & 1 deletion evalml/tests/pipeline_tests/test_pipelines.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class MockLogisticRegressionPipeline(PipelineBase):
name = "Mock Logistic Regression Pipeline"

def __init__(self, objective, penalty, C, impute_strategy,
number_features, n_jobs=1, random_state=0):
number_features, n_jobs=-1, random_state=0):
imputer = SimpleImputer(impute_strategy=impute_strategy)
enc = OneHotEncoder()
scaler = StandardScaler()
Expand Down