Skip to content

Commit 653efc8

Browse files
committed
[DOC] separate examples pages
1 parent d668d6b commit 653efc8

11 files changed

Lines changed: 527 additions & 209 deletions

docs/source/examples.rst

Lines changed: 49 additions & 209 deletions
Original file line numberDiff line numberDiff line change
@@ -4,240 +4,80 @@
44
Examples
55
========
66

7-
This page provides a collection of examples demonstrating Hyperactive's capabilities.
7+
This section provides a collection of examples demonstrating Hyperactive's capabilities.
88
All examples are available in the
99
`examples directory <https://github.com/SimonBlanke/Hyperactive/tree/master/examples>`_
1010
on GitHub.
1111

12+
.. toctree::
13+
:maxdepth: 1
1214

13-
Example Gallery
14-
---------------
15+
examples/general
16+
examples/local_search
17+
examples/global_search
18+
examples/population_based
19+
examples/sequential_model_based
20+
examples/optuna_backend
21+
examples/sklearn_backend
22+
examples/integrations
23+
examples/other
24+
examples/interactive_tutorial
1525

16-
Hyperactive includes examples for various optimization algorithms and use cases.
17-
You can run any example directly:
1826

19-
.. code-block:: bash
27+
Overview
28+
--------
2029

21-
# Clone the repository
22-
git clone https://github.com/SimonBlanke/Hyperactive.git
23-
cd Hyperactive/examples
30+
Hyperactive provides examples for all optimization algorithms and integration
31+
patterns. The examples are organized by algorithm category:
2432

25-
# Run an example
26-
python gfo/hill_climbing_example.py
2733

34+
Gradient-Free Optimizers (GFO)
35+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2836

29-
Basic Examples
30-
--------------
37+
:ref:`examples_general`
38+
Basic examples showing custom function optimization and sklearn model tuning.
3139

32-
Custom Function Optimization
33-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
40+
:ref:`examples_local_search`
41+
Hill Climbing, Simulated Annealing, Downhill Simplex, and other local
42+
search methods that explore by making incremental moves.
3443

35-
The simplest use case: optimizing a mathematical function.
44+
:ref:`examples_global_search`
45+
Random Search, Grid Search, Powell's Method, and other algorithms that
46+
explore the search space more broadly.
3647

37-
.. literalinclude:: _snippets/examples/basic_examples.py
38-
:language: python
39-
:start-after: # [start:custom_function]
40-
:end-before: # [end:custom_function]
48+
:ref:`examples_population_based`
49+
Particle Swarm, Genetic Algorithm, Evolution Strategy, and other
50+
nature-inspired population methods.
4151

52+
:ref:`examples_sequential_model_based`
53+
Bayesian Optimization, Tree-Parzen Estimators, and other model-based
54+
methods that learn from previous evaluations.
4255

43-
Scikit-learn Model Tuning
44-
^^^^^^^^^^^^^^^^^^^^^^^^^
4556

46-
Hyperparameter optimization for machine learning models.
57+
Backend Examples
58+
^^^^^^^^^^^^^^^^
4759

48-
.. literalinclude:: _snippets/examples/basic_examples.py
49-
:language: python
50-
:start-after: # [start:sklearn_tuning]
51-
:end-before: # [end:sklearn_tuning]
60+
:ref:`examples_optuna_backend`
61+
Examples using Optuna's samplers including TPE, CMA-ES, NSGA-II/III,
62+
and Gaussian Process optimization.
5263

53-
54-
Gradient-Free Optimizer Examples
55-
--------------------------------
56-
57-
Local Search Algorithms
58-
^^^^^^^^^^^^^^^^^^^^^^^
59-
60-
.. list-table::
61-
:header-rows: 1
62-
:widths: 30 70
63-
64-
* - Algorithm
65-
- Example
66-
* - Hill Climbing
67-
- `hill_climbing_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/hill_climbing_example.py>`_
68-
* - Repulsing Hill Climbing
69-
- `repulsing_hill_climbing_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/repulsing_hill_climbing_example.py>`_
70-
* - Simulated Annealing
71-
- `simulated_annealing_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/simulated_annealing_example.py>`_
72-
* - Downhill Simplex
73-
- `downhill_simplex_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/downhill_simplex_example.py>`_
74-
75-
76-
Global Search Algorithms
77-
^^^^^^^^^^^^^^^^^^^^^^^^
78-
79-
.. list-table::
80-
:header-rows: 1
81-
:widths: 30 70
82-
83-
* - Algorithm
84-
- Example
85-
* - Random Search
86-
- `random_search_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/random_search_example.py>`_
87-
* - Grid Search
88-
- `grid_search_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/grid_search_example.py>`_
89-
* - Random Restart Hill Climbing
90-
- `random_restart_hill_climbing_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/random_restart_hill_climbing_example.py>`_
91-
* - Stochastic Hill Climbing
92-
- `stochastic_hill_climbing_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/stochastic_hill_climbing_example.py>`_
93-
* - Powell's Method
94-
- `powells_method_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/powells_method_example.py>`_
95-
* - Pattern Search
96-
- `pattern_search_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/pattern_search_example.py>`_
97-
98-
99-
Population-Based Algorithms
100-
^^^^^^^^^^^^^^^^^^^^^^^^^^^
101-
102-
.. list-table::
103-
:header-rows: 1
104-
:widths: 30 70
105-
106-
* - Algorithm
107-
- Example
108-
* - Particle Swarm
109-
- `particle_swarm_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/particle_swarm_example.py>`_
110-
* - Genetic Algorithm
111-
- `genetic_algorithm_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/genetic_algorithm_example.py>`_
112-
* - Evolution Strategy
113-
- `evolution_strategy_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/evolution_strategy_example.py>`_
114-
* - Differential Evolution
115-
- `differential_evolution_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/differential_evolution_example.py>`_
116-
* - Parallel Tempering
117-
- `parallel_tempering_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/parallel_tempering_example.py>`_
118-
* - Spiral Optimization
119-
- `spiral_optimization_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/spiral_optimization_example.py>`_
120-
121-
122-
Sequential Model-Based Algorithms
123-
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
124-
125-
.. list-table::
126-
:header-rows: 1
127-
:widths: 30 70
128-
129-
* - Algorithm
130-
- Example
131-
* - Bayesian Optimization
132-
- `bayesian_optimization_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/bayesian_optimization_example.py>`_
133-
* - Tree-Parzen Estimators
134-
- `tree_structured_parzen_estimators_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/tree_structured_parzen_estimators_example.py>`_
135-
* - Forest Optimizer
136-
- `forest_optimizer_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/forest_optimizer_example.py>`_
137-
* - Lipschitz Optimizer
138-
- `lipschitz_optimizer_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/lipschitz_optimizer_example.py>`_
139-
* - DIRECT Algorithm
140-
- `direct_algorithm_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/direct_algorithm_example.py>`_
141-
142-
143-
Optuna Backend Examples
144-
-----------------------
145-
146-
Examples using Optuna's optimization algorithms:
147-
148-
.. list-table::
149-
:header-rows: 1
150-
:widths: 30 70
151-
152-
* - Algorithm
153-
- Example
154-
* - TPE Optimizer
155-
- `tpe_sampler_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/optuna/tpe_sampler_example.py>`_
156-
* - CMA-ES
157-
- `cmaes_sampler_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/optuna/cmaes_sampler_example.py>`_
158-
* - Gaussian Process
159-
- `gp_sampler_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/optuna/gp_sampler_example.py>`_
160-
* - NSGA-II
161-
- `nsga_ii_sampler_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/optuna/nsga_ii_sampler_example.py>`_
162-
* - NSGA-III
163-
- `nsga_iii_sampler_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/optuna/nsga_iii_sampler_example.py>`_
164-
* - QMC
165-
- `qmc_sampler_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/optuna/qmc_sampler_example.py>`_
166-
* - Random
167-
- `random_sampler_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/optuna/random_sampler_example.py>`_
168-
* - Grid
169-
- `grid_sampler_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/optuna/grid_sampler_example.py>`_
64+
:ref:`examples_sklearn_backend`
65+
Scikit-learn compatible interfaces as drop-in replacements for
66+
GridSearchCV and RandomizedSearchCV.
17067

17168

17269
Integration Examples
173-
--------------------
174-
175-
Scikit-learn Integration
176-
^^^^^^^^^^^^^^^^^^^^^^^^
177-
178-
.. list-table::
179-
:header-rows: 1
180-
:widths: 30 70
181-
182-
* - Use Case
183-
- Example
184-
* - Classification with OptCV
185-
- `sklearn_classif_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/integrations/sklearn_classif_example.py>`_
186-
* - Grid Search
187-
- `grid_search_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/sklearn/grid_search_example.py>`_
188-
* - Random Search
189-
- `random_search_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/sklearn/random_search_example.py>`_
190-
191-
192-
Sktime Integration
193-
^^^^^^^^^^^^^^^^^^
194-
195-
.. list-table::
196-
:header-rows: 1
197-
:widths: 30 70
198-
199-
* - Use Case
200-
- Example
201-
* - Time Series Forecasting
202-
- `sktime_forecasting_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/integrations/sktime_forecasting_example.py>`_
203-
* - Time Series Classification
204-
- `sktime_tsc_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/integrations/sktime_tsc_example.py>`_
205-
206-
207-
Advanced Examples
208-
-----------------
209-
210-
Warm Starting Optimization
211-
^^^^^^^^^^^^^^^^^^^^^^^^^^
212-
213-
Start optimization from known good points:
214-
215-
.. literalinclude:: _snippets/examples/advanced_examples.py
216-
:language: python
217-
:start-after: # [start:warm_starting]
218-
:end-before: # [end:warm_starting]
219-
220-
221-
Comparing Optimizers
22270
^^^^^^^^^^^^^^^^^^^^
22371

224-
Compare different optimization strategies:
225-
226-
.. literalinclude:: _snippets/examples/advanced_examples.py
227-
:language: python
228-
:start-after: # [start:comparing_optimizers]
229-
:end-before: # [end:comparing_optimizers]
230-
72+
:ref:`examples_integrations`
73+
Time series optimization with sktime and other framework integrations.
23174

232-
Interactive Tutorial
233-
--------------------
23475

235-
For a comprehensive interactive tutorial, see the
236-
`Hyperactive Tutorial Notebook <https://nbviewer.org/github/SimonBlanke/hyperactive-tutorial/blob/main/notebooks/hyperactive_tutorial.ipynb>`_.
76+
Advanced Topics
77+
^^^^^^^^^^^^^^^
23778

238-
This Jupyter notebook covers:
79+
:ref:`examples_other`
80+
Advanced usage patterns including warm starting and optimizer comparison.
23981

240-
- Basic optimization concepts
241-
- All optimizer categories
242-
- Real-world ML examples
243-
- Best practices and tips
82+
:ref:`examples_interactive_tutorial`
83+
Comprehensive Jupyter notebook tutorial covering all Hyperactive features.

docs/source/examples/general.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
.. _examples_general:
2+
3+
================
4+
General Examples
5+
================
6+
7+
These examples demonstrate Hyperactive's core functionality with simple,
8+
illustrative use cases.
9+
10+
11+
Running Examples
12+
----------------
13+
14+
All examples are available in the
15+
`examples directory <https://github.com/SimonBlanke/Hyperactive/tree/master/examples>`_
16+
on GitHub. You can run any example directly:
17+
18+
.. code-block:: bash
19+
20+
# Clone the repository
21+
git clone https://github.com/SimonBlanke/Hyperactive.git
22+
cd Hyperactive/examples
23+
24+
# Run an example
25+
python gfo/hill_climbing_example.py
26+
27+
28+
Custom Function Optimization
29+
----------------------------
30+
31+
The simplest use case: optimizing a mathematical function.
32+
33+
.. literalinclude:: ../_snippets/examples/basic_examples.py
34+
:language: python
35+
:start-after: # [start:custom_function]
36+
:end-before: # [end:custom_function]
37+
38+
39+
Scikit-learn Model Tuning
40+
-------------------------
41+
42+
Hyperparameter optimization for machine learning models.
43+
44+
.. literalinclude:: ../_snippets/examples/basic_examples.py
45+
:language: python
46+
:start-after: # [start:sklearn_tuning]
47+
:end-before: # [end:sklearn_tuning]
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
.. _examples_global_search:
2+
3+
========================
4+
Global Search Algorithms
5+
========================
6+
7+
Global search algorithms explore the search space more broadly, using
8+
randomization or systematic patterns to avoid getting trapped in local optima.
9+
10+
11+
Algorithm Examples
12+
------------------
13+
14+
.. list-table::
15+
:header-rows: 1
16+
:widths: 30 70
17+
18+
* - Algorithm
19+
- Example
20+
* - Random Search
21+
- `random_search_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/random_search_example.py>`_
22+
* - Grid Search
23+
- `grid_search_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/grid_search_example.py>`_
24+
* - Random Restart Hill Climbing
25+
- `random_restart_hill_climbing_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/random_restart_hill_climbing_example.py>`_
26+
* - Stochastic Hill Climbing
27+
- `stochastic_hill_climbing_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/stochastic_hill_climbing_example.py>`_
28+
* - Powell's Method
29+
- `powells_method_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/powells_method_example.py>`_
30+
* - Pattern Search
31+
- `pattern_search_example.py <https://github.com/SimonBlanke/Hyperactive/blob/master/examples/gfo/pattern_search_example.py>`_
32+
33+
34+
When to Use Global Search
35+
-------------------------
36+
37+
Global search algorithms are best suited for:
38+
39+
- **Multimodal search spaces** with multiple local optima
40+
- **Initial exploration** before fine-tuning with local search
41+
- **Unknown search spaces** where the landscape is not well understood
42+
- **Baseline comparisons** (especially Random Search)
43+
44+
See :ref:`user_guide_optimizers` for detailed algorithm descriptions.

0 commit comments

Comments
 (0)