Skip to content

Commit c2449ae

Browse files
committed
DEPLOY documentation benchopt 1.8.1
1 parent 5223cd4 commit c2449ae

347 files changed

Lines changed: 50824 additions & 2149 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1.8.1/.buildinfo

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Sphinx build info version 1
2+
# This file records the configuration used when building these files. When it is not found, a full rebuild will be done.
3+
config: 1f09ef5088c562aae7273f3a1348bacd
4+
tags: 645f666f9bcd5a90fca523b33c5a78b7
Binary file not shown.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""
2+
============================
3+
Demo benchmark with R/Python
4+
============================
5+
6+
"""
7+
8+
from pathlib import Path
9+
import matplotlib.pyplot as plt
10+
from benchopt import run_benchmark
11+
from benchopt.benchmark import Benchmark
12+
from benchopt.plotting import plot_benchmark
13+
from benchopt.plotting.helpers import reset_solver_styles
14+
15+
16+
BENCHMARK_PATH = Path().resolve().parent / 'benchmarks' / 'benchmark_lasso'
17+
18+
if not BENCHMARK_PATH.exists():
19+
raise RuntimeError(
20+
"This example can only work when Lasso benchmark is cloned in the "
21+
"example folder. Please run:\n"
22+
"$ git clone https://github.com/benchopt/benchmark_lasso "
23+
f"{BENCHMARK_PATH.resolve()}"
24+
)
25+
26+
save_file = run_benchmark(
27+
BENCHMARK_PATH,
28+
solver_names=['Python-PGD[use_acceleration=False]', 'R-PGD'],
29+
dataset_names=["Simulated[n_features=5000,n_samples=100,rho=0]"],
30+
objective_filters=['*[fit_intercept=False,reg=0.5]'],
31+
max_runs=100, timeout=100, n_repetitions=5,
32+
plot_result=False, show_progress=False
33+
)
34+
35+
reset_solver_styles()
36+
37+
figs = plot_benchmark(
38+
save_file, benchmark=Benchmark(BENCHMARK_PATH), html=False
39+
)
40+
plt.show()
Binary file not shown.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Running an existing benchmark\n\nThis Example demonstrates how to run an existing benchmark with benchopt.\nIt uses the `benchopt_run` helper function to run the benchmark, which runs\nprogrammatically the equivalent of the command line interface:\n"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": null,
13+
"metadata": {
14+
"collapsed": false
15+
},
16+
"outputs": [],
17+
"source": [
18+
"from benchopt.helpers.run_examples import benchopt_run"
19+
]
20+
},
21+
{
22+
"cell_type": "markdown",
23+
"metadata": {},
24+
"source": [
25+
"To run the benchmark, just execute:\n\n\n"
26+
]
27+
},
28+
{
29+
"cell_type": "code",
30+
"execution_count": null,
31+
"metadata": {
32+
"collapsed": false
33+
},
34+
"outputs": [],
35+
"source": [
36+
"benchopt_run('minimal_benchmark', n=20, r=2)"
37+
]
38+
},
39+
{
40+
"cell_type": "markdown",
41+
"metadata": {},
42+
"source": [
43+
"This runs the benchmark named ``minimal_benchmark`` located in the\n``examples`` folder.\n\nThe parameters ``n`` controls the number of point on the curves, while ``r``\ncontrols the number of repetitions for each solver. The repetitions are used\nto compute the median and quartiles of the curves.\n\nTo get a more precise curve, you can increase ``n`` and ``r``:\n\n"
44+
]
45+
},
46+
{
47+
"cell_type": "code",
48+
"execution_count": null,
49+
"metadata": {
50+
"collapsed": false
51+
},
52+
"outputs": [],
53+
"source": [
54+
"benchopt_run('minimal_benchmark', n=30, r=5)"
55+
]
56+
},
57+
{
58+
"cell_type": "markdown",
59+
"metadata": {},
60+
"source": [
61+
"Here, the display is not ideal because both solvers reach convergence very\nquickly. You can change the display by selecting the scale of the axis in\nthe plot configuration panel.\nGo to the *Change plot* banner at the top of the HTML file, and change the\nscale to ``loglog`` on the drop down menu.\n\nNote that for convenience, this can be saved as a view in the configuration\nof the benchmark. See `here <plot_configs>` for more details.\nHere, clicking on ``Subopt. (log)`` in the *Available plots* above the\nfigure will take you to a view with the right scale, and looking at\nsuboptimality instead of objective value.\n\n"
62+
]
63+
}
64+
],
65+
"metadata": {
66+
"kernelspec": {
67+
"display_name": "Python 3",
68+
"language": "python",
69+
"name": "python3"
70+
},
71+
"language_info": {
72+
"codemirror_mode": {
73+
"name": "ipython",
74+
"version": 3
75+
},
76+
"file_extension": ".py",
77+
"mimetype": "text/x-python",
78+
"name": "python",
79+
"nbconvert_exporter": "python",
80+
"pygments_lexer": "ipython3",
81+
"version": "3.10.19"
82+
}
83+
},
84+
"nbformat": 4,
85+
"nbformat_minor": 0
86+
}
Binary file not shown.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
"""Running an existing benchmark
2+
=============================
3+
4+
This Example demonstrates how to run an existing benchmark with benchopt.
5+
It uses the `benchopt_run` helper function to run the benchmark, which runs
6+
programmatically the equivalent of the command line interface:
7+
"""
8+
9+
from benchopt.helpers.run_examples import benchopt_run
10+
11+
# %%
12+
# To run the benchmark, just execute:
13+
#
14+
15+
benchopt_run('minimal_benchmark', n=20, r=2)
16+
17+
# %%
18+
# This runs the benchmark named ``minimal_benchmark`` located in the
19+
# ``examples`` folder.
20+
#
21+
# The parameters ``n`` controls the number of point on the curves, while ``r``
22+
# controls the number of repetitions for each solver. The repetitions are used
23+
# to compute the median and quartiles of the curves.
24+
#
25+
# To get a more precise curve, you can increase ``n`` and ``r``:
26+
27+
benchopt_run('minimal_benchmark', n=30, r=5)
28+
29+
# %%
30+
# Here, the display is not ideal because both solvers reach convergence very
31+
# quickly. You can change the display by selecting the scale of the axis in
32+
# the plot configuration panel.
33+
# Go to the *Change plot* banner at the top of the HTML file, and change the
34+
# scale to ``loglog`` on the drop down menu.
35+
#
36+
# Note that for convenience, this can be saved as a view in the configuration
37+
# of the benchmark. See :ref:`here <plot_configs>` for more details.
38+
# Here, clicking on ``Subopt. (log)`` in the *Available plots* above the
39+
# figure will take you to a view with the right scale, and looking at
40+
# suboptimality instead of objective value.
Binary file not shown.
Binary file not shown.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"\n# Run benchmark from a script\n"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": null,
13+
"metadata": {
14+
"collapsed": false
15+
},
16+
"outputs": [],
17+
"source": [
18+
"from pathlib import Path\nimport matplotlib.pyplot as plt\nfrom benchopt import run_benchmark\nfrom benchopt.benchmark import Benchmark\nfrom benchopt.plotting import plot_benchmark\nfrom benchopt.plotting.helpers import reset_solver_styles\n\n\nBENCHMARK_PATH = (\n Path().resolve().parent / 'benchmarks' / 'benchmark_logreg_l2'\n)\n\ntry:\n\n save_file = run_benchmark(\n BENCHMARK_PATH,\n solver_names=['sklearn[liblinear]', 'sklearn[newton-cg]', 'lightning'],\n dataset_names=[\"Simulated[n_features=500,n_samples=200]\"],\n objective_filters=['L2 Logistic Regression[lmbd=1.0]'],\n max_runs=100, timeout=20, n_repetitions=15,\n plot_result=False, show_progress=True\n )\n\nexcept RuntimeError:\n raise RuntimeError(\n \"This example can only work when Logreg-l2 benchmark is cloned in a \"\n \"`benchmarks` folder. Please run:\\n\"\n \"$ git clone https://github.com/benchopt/benchmark_logreg_l2 \"\n f\"{BENCHMARK_PATH.resolve()}\"\n )\n\nreset_solver_styles()\n\nfigs = plot_benchmark(\n save_file, benchmark=Benchmark(BENCHMARK_PATH), html=False\n)\nplt.show()"
19+
]
20+
}
21+
],
22+
"metadata": {
23+
"kernelspec": {
24+
"display_name": "Python 3",
25+
"language": "python",
26+
"name": "python3"
27+
},
28+
"language_info": {
29+
"codemirror_mode": {
30+
"name": "ipython",
31+
"version": 3
32+
},
33+
"file_extension": ".py",
34+
"mimetype": "text/x-python",
35+
"name": "python",
36+
"nbconvert_exporter": "python",
37+
"pygments_lexer": "ipython3",
38+
"version": "3.10.19"
39+
}
40+
},
41+
"nbformat": 4,
42+
"nbformat_minor": 0
43+
}

0 commit comments

Comments
 (0)