Repository navigation
check if model is paralizable #230
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
Changes from all commits
6d13a75
2ab8b2b
55be0a8
9890555
7d8fa4d
239bf41
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -25,7 +25,8 @@ | |
| import sklearn.tree | ||
|
|
||
| from openml.flows import OpenMLFlow, sklearn_to_flow, flow_to_sklearn | ||
| from openml.flows.sklearn_converter import _format_external_version, _check_dependencies | ||
| from openml.flows.sklearn_converter import _format_external_version, \ | ||
| _check_dependencies, _check_n_jobs | ||
| from openml.exceptions import PyOpenMLError | ||
|
|
||
| this_directory = os.path.dirname(os.path.abspath(__file__)) | ||
|
|
@@ -555,3 +556,36 @@ def test_illegal_parameter_names_featureunion(self): | |
| ('OneHotEncoder', sklearn.preprocessing.OneHotEncoder(sparse=False, handle_unknown='ignore')) | ||
| ] | ||
| self.assertRaises(ValueError, sklearn.pipeline.FeatureUnion, transformer_list=transformer_list) | ||
|
|
||
| def test_paralizable_check(self): | ||
| # using this model should pass the test (if param distribution is legal) | ||
| singlecore_bagging = sklearn.ensemble.BaggingClassifier() | ||
| # using this model should return false (if param distribution is legal) | ||
| multicore_bagging = sklearn.ensemble.BaggingClassifier(n_jobs=5) | ||
| # using this param distribution should raise an exception | ||
| illegal_param_dist = {"base__n_jobs": [-1, 0, 1] } | ||
| # using this param distribution should not raise an exception | ||
| legal_param_dist = {"base__max_depth": [2, 3, 4]} | ||
|
|
||
| legal_models = [ | ||
| sklearn.ensemble.RandomForestClassifier(), | ||
| sklearn.ensemble.RandomForestClassifier(n_jobs=5), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't that fail because
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is exactly what happens, and this is specified in the answers array. Legal means here 'will not raise an error'. i added comments to make this more clear |
||
| sklearn.ensemble.RandomForestClassifier(n_jobs=-1), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't that fail because
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as previous |
||
| sklearn.pipeline.Pipeline(steps=[('bag', sklearn.ensemble.BaggingClassifier(n_jobs=1))]), | ||
| sklearn.pipeline.Pipeline(steps=[('bag', sklearn.ensemble.BaggingClassifier(n_jobs=5))]), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't that fail because
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as previous |
||
| sklearn.pipeline.Pipeline(steps=[('bag', sklearn.ensemble.BaggingClassifier(n_jobs=-1))]), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't that fail because
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as previous |
||
| sklearn.model_selection.GridSearchCV(singlecore_bagging, legal_param_dist), | ||
| sklearn.model_selection.GridSearchCV(multicore_bagging, legal_param_dist) | ||
| ] | ||
| illegal_models = [ | ||
| sklearn.model_selection.GridSearchCV(singlecore_bagging, illegal_param_dist), | ||
| sklearn.model_selection.GridSearchCV(multicore_bagging, illegal_param_dist) | ||
| ] | ||
|
|
||
| answers = [True, False, False, True, False, False, True, False] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, here it's obvious what you're doing. Maybe you can re-order the test to make it easier to comprehend (i.e. check the legal models before declaring the illegal models, and maybe giving the list a different name.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added some comments |
||
|
|
||
| for i in range(len(legal_models)): | ||
| self.assertTrue(_check_n_jobs(legal_models[i]) == answers[i]) | ||
|
|
||
| for i in range(len(illegal_models)): | ||
| self.assertRaises(PyOpenMLError, _check_n_jobs, illegal_models[i]) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One newline is enough ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
K.