def plot(benchmark, filename=None, kinds=('suboptimality_curve', ), no_display=False): output_folder = _get_output_folder(benchmark) all_csv_files = output_folder.glob("*.csv") all_csv_files = sorted(all_csv_files, key=lambda t: t.stat().st_mtime) if filename is not None: if (output_folder / filename).exists(): result_filename = output_folder / filename elif Path(filename).exists(): result_filename = Path(filename) else: all_csv_files = '\n- '.join([str(s) for s in all_csv_files]) raise FileNotFoundError( f"Could not find result file {filename}. Available result " f"files are:\n- {all_csv_files}") else: result_filename = all_csv_files[-1] df = pd.read_csv(result_filename) plot_benchmark(df, benchmark, kinds=kinds, display=not no_display)
import os from pathlib import Path import matplotlib.pyplot as plt from benchopt import run_benchmark from benchopt.viz import plot_benchmark, PLOT_KINDS BENCHMARK_PATH = Path(os.getcwd()).parent / 'benchmarks' / 'lasso' try: df = run_benchmark( str(BENCHMARK_PATH), ['Python-PGD*use_acceleration=False', 'R-PGD', 'Julia-PGD'], dataset_names=['Simulated*n_samples=100,n_features=500*'], 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=str(BENCHMARK_PATH), kinds=kinds) plt.show()
=========================== """ import os from pathlib import Path import matplotlib.pyplot as plt from benchopt import run_benchmark from benchopt.viz import plot_benchmark BENCHMARK_PATH = Path(os.getcwd()).parent / 'benchmarks' / 'logreg_l2' try: df = run_benchmark( str(BENCHMARK_PATH), ['sklearn', 'lightning'], dataset_names=['Simulated*n_samples=200,n_features=500*'], max_runs=100, timeout=20, n_repetitions=3, 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_logreg_l2 " f"{BENCHMARK_PATH.resolve()}") figs = plot_benchmark(df, benchmark=str(BENCHMARK_PATH)) plt.show()