-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #608 from bouthilx/feature/cmdline_parallel_workers
Add Executor class and CLI arguments for parallelism
- Loading branch information
Showing
30 changed files
with
548 additions
and
129 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
**************** | ||
Executor modules | ||
**************** | ||
|
||
.. automodule:: orion.executor | ||
:members: | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
:caption: Executor modules of Oríon | ||
|
||
executor/base | ||
executor/dask | ||
executor/joblib |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Base | ||
==== | ||
|
||
.. automodule:: orion.executor.base | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Dask Executor | ||
============= | ||
|
||
.. automodule:: orion.executor.dask_backend | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Joblib Executor | ||
=============== | ||
|
||
.. automodule:: orion.executor.joblib_backend | ||
:members: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,6 +64,7 @@ | |
code/benchmark | ||
code/client | ||
code/core | ||
code/executor | ||
code/plotting | ||
code/storage | ||
code/testing | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
""" | ||
=========== | ||
Parallelism | ||
=========== | ||
Multiprocessing | ||
--------------- | ||
(joblib's loky) | ||
Dask | ||
---- | ||
""" | ||
|
||
import joblib | ||
import numpy | ||
from sklearn import datasets | ||
from sklearn.model_selection import cross_validate | ||
from sklearn.svm import SVC | ||
|
||
from orion.client import create_experiment | ||
|
||
|
||
def main(C, gamma, tol, class_weight): | ||
|
||
diabetes = datasets.load_diabetes() | ||
|
||
X = diabetes.data | ||
y = diabetes.target | ||
|
||
model = SVC(kernel="rbf", C=C, gamma=gamma, tol=tol, class_weight=class_weight) | ||
|
||
# Single metric evaluation using cross_validate | ||
with joblib.parallel_backend("dask"): | ||
cv_results = cross_validate(model, X, y, cv=5) | ||
|
||
accuracy = numpy.mean(cv_results["test_score"]) | ||
error_rate = 1 - accuracy | ||
|
||
return [{"name": "test_error_rate", "type": "objective", "value": error_rate}] | ||
|
||
|
||
def hpo(n_workers=16): | ||
|
||
experiment = create_experiment( | ||
name="dask", | ||
max_trials=1000, | ||
max_broken=5, | ||
space={ | ||
"C": "loguniform(1e-6, 1e6, precision=None)", | ||
"gamma": "loguniform(1e-8, 1e8, precision=None)", | ||
"tol": "loguniform(1e-4, 1e-1, precision=None)", | ||
"class_weight": "choices([None, 'balanced'])", | ||
}, | ||
algorithms={"random": {"seed": 1}}, | ||
) | ||
|
||
with experiment.tmp_executor("dask", n_workers=n_workers): | ||
experiment.workon(main, n_workers=n_workers // 2) | ||
|
||
experiment.plot.regret().show() | ||
experiment.plot.partial_dependencies(params=["C", "gamma", "tol"]).show() | ||
|
||
|
||
if __name__ == "__main__": | ||
hpo() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.