from pathlib import Path import matplotlib.pyplot as plt from benchopt import run_benchmark from benchopt.benchmark import Benchmark from benchopt.tests import SELECT_ONE_SIMULATED from benchopt.plotting import plot_benchmark, PLOT_KINDS BENCHMARK_PATH = Path(os.getcwd()).parent / 'benchmarks' / 'lasso' try: df = run_benchmark( Benchmark(BENCHMARK_PATH), ['Python-PGD[^-]*use_acceleration=False', 'R-PGD', 'Julia-PGD'], dataset_names=[SELECT_ONE_SIMULATED], objective_filters=['reg=0.5'], max_runs=100, timeout=100, n_repetitions=5, plot_result=False, show_progress=False) except RuntimeError: raise RuntimeError( "This example can only work when Lasso benchmark is cloned in the " "example folder. Please run:\n" "$ git clone https://github.com/benchopt/benchmark_lasso " f"{BENCHMARK_PATH.resolve()}") kinds = list(PLOT_KINDS.keys()) figs = plot_benchmark(df, benchmark=Benchmark(BENCHMARK_PATH), kinds=kinds) plt.show()
'-f', type=str, default=None, help="Specify the file to select in the benchmark. If it is " "not specified, take the latest on in the benchmark output " "folder.") @click.option('--kind', '-k', 'kinds', multiple=True, show_default=True, type=str, help="Specify the type of figure to plot:\n\n* " + "\n\n* ".join([ f"``{name}``: {func.__doc__.splitlines()[0]}" for name, func in PLOT_KINDS.items() ])) @click.option('--display/--no-display', default=True, help="Whether or not to display the plot on the screen.") @click.option('--plotly', is_flag=True, help="If this flag is set, generate figure as HTML with plotly. " "This option does not work with all plot kinds and requires " "to have installed `plotly`.") def plot(benchmark, filename=None, kinds=('suboptimality_curve', ), display=True, plotly=False):