Skip to content

Commit

Permalink
update doc
Browse files Browse the repository at this point in the history
  • Loading branch information
Deathn0t committed Mar 26, 2024
1 parent 4359852 commit b2a0671
Show file tree
Hide file tree
Showing 26 changed files with 1,157 additions and 588 deletions.
Binary file modified docs/examples/examples_jupyter.zip
Binary file not shown.
Binary file modified docs/examples/examples_python.zip
Binary file not shown.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 22 additions & 4 deletions docs/examples/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ Below is a gallery of examples on how to use DeepHyper.

.. only:: html

.. image:: /examples/images/thumb/sphx_glr_plot_from_serial_to_parallel_hyperparameter_search_thumb.png
.. image:: /examples/images/thumb/sphx_glr_plot_experimental_design_thumb.png
:alt:

:ref:`sphx_glr_examples_plot_from_serial_to_parallel_hyperparameter_search.py`
:ref:`sphx_glr_examples_plot_experimental_design.py`

.. raw:: html

<div class="sphx-glr-thumbnail-title">From Serial to Parallel Evaluations</div>
<div class="sphx-glr-thumbnail-title">Profile the Worker Utilization</div>
</div>


Expand Down Expand Up @@ -64,6 +64,23 @@ Below is a gallery of examples on how to use DeepHyper.
</div>


.. raw:: html

<div class="sphx-glr-thumbcontainer" tooltip="Author(s): Romain Egele.">

.. only:: html

.. image:: /examples/images/thumb/sphx_glr_plot_from_serial_to_parallel_hyperparameter_search_thumb.png
:alt:

:ref:`sphx_glr_examples_plot_from_serial_to_parallel_hyperparameter_search.py`

.. raw:: html

<div class="sphx-glr-thumbnail-title">From Serial to Parallel Evaluations</div>
</div>


.. raw:: html

<div class="sphx-glr-thumbcontainer" tooltip="Author(s): Romain Egele.">
Expand All @@ -89,9 +106,10 @@ Below is a gallery of examples on how to use DeepHyper.
.. toctree::
:hidden:

/examples/plot_from_serial_to_parallel_hyperparameter_search
/examples/plot_experimental_design
/examples/plot_notify_failures_hyperparameter_search
/examples/plot_transfer_learning_for_hps
/examples/plot_from_serial_to_parallel_hyperparameter_search
/examples/plot_profile_worker_utilization


Expand Down
115 changes: 115 additions & 0 deletions docs/examples/plot_experimental_design.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"\n# Profile the Worker Utilization\n\n**Author(s)**: Romain Egele.\n\nThis example demonstrates how to generate points from standard experimental designs (e.g., random, grid, lhs).\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from deephyper.analysis._matplotlib import update_matplotlib_rc\n\nupdate_matplotlib_rc()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First we define the hyperparameter search space.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from deephyper.problem import HpProblem\n\n\nproblem = HpProblem()\nproblem.add_hyperparameter((0.0001, 100.0, \"log-uniform\"), \"x\")\nproblem.add_hyperparameter((0.0, 100.0), \"y\")\nproblem.add_hyperparameter([1, 2, 3], \"z\")\nproblem\nproblem"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Then we define the black-box function to optimize.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"def run(job):\n config = job.parameters\n objective = config[\"x\"] + config[\"y\"]\n return objective"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Then we define the search. In this example, we use the `ExperimentalDesignSearch` class to generate points from a grid design. The `Evaluator` can also be used with this class to parallelize evalutions.\nNote that `n_points` and `max_evals` take the same value here.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"from deephyper.search.hps import ExperimentalDesignSearch\n\n\nmax_evals = 200\nsearch = ExperimentalDesignSearch(problem, run, n_points=max_evals, design=\"grid\")\nresults = search.search(max_evals)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Finally, we plot the results from the collected DataFrame.\n\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"import matplotlib.pyplot as plt\n\n\nfig, ax = plt.subplots()\nax.scatter(results[\"p:x\"], results[\"p:y\"], c=results[\"p:z\"], alpha=0.3)\nax.set_xscale(\"log\")\nplt.xlabel(\"x\")\nplt.ylabel(\"y\")\nplt.show()"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.6"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
57 changes: 57 additions & 0 deletions docs/examples/plot_experimental_design.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# -*- coding: utf-8 -*-
"""
Profile the Worker Utilization
==============================
**Author(s)**: Romain Egele.
This example demonstrates how to generate points from standard experimental designs (e.g., random, grid, lhs).
"""


from deephyper.analysis._matplotlib import update_matplotlib_rc

update_matplotlib_rc()

# %%
# First we define the hyperparameter search space.
from deephyper.problem import HpProblem


problem = HpProblem()
problem.add_hyperparameter((0.0001, 100.0, "log-uniform"), "x")
problem.add_hyperparameter((0.0, 100.0), "y")
problem.add_hyperparameter([1, 2, 3], "z")
problem
problem


# %%
# Then we define the black-box function to optimize.
def run(job):
config = job.parameters
objective = config["x"] + config["y"]
return objective


# %%
# Then we define the search. In this example, we use the `ExperimentalDesignSearch` class to generate points from a grid design. The `Evaluator` can also be used with this class to parallelize evalutions.
# Note that `n_points` and `max_evals` take the same value here.
from deephyper.search.hps import ExperimentalDesignSearch


max_evals = 200
search = ExperimentalDesignSearch(problem, run, n_points=max_evals, design="grid")
results = search.search(max_evals)

# %%
# Finally, we plot the results from the collected DataFrame.
import matplotlib.pyplot as plt


fig, ax = plt.subplots()
ax.scatter(results["p:x"], results["p:y"], c=results["p:z"], alpha=0.3)
ax.set_xscale("log")
plt.xlabel("x")
plt.ylabel("y")
plt.show()
1 change: 1 addition & 0 deletions docs/examples/plot_experimental_design.py.md5
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7f69999a456e564a57a3f22168030ff9

0 comments on commit b2a0671

Please sign in to comment.