Save benchmark results + compare models
Run benchmarks on multiple models, save results to a DataFrame, compare side-by-side. This is how leaderboards work.
script.py
v3.1
Python output
click Run to execute
Click "Run" to execute the code on the left.
The output will appear here.
The output will appear here.
🧠 How it works
This is how a LEADERBOARD works: (1) Define multiple models to compare. (2) Benchmark each — train time, inference time, metrics. (3) Store results in a pandas DataFrame. (4) Save to CSV (or a database table). (5) Load + sort by metric to show the leaderboard. The benchmark function is the SAME for all models — that's the point. You can add XGBoost, LightGBM, neural nets — same function, same DataFrame, same leaderboard. In OpenBenchML, the DataFrame is stored in a database (LeaderboardEntry table) and rendered as an HTML table on the /leaderboard page. WebSocket pushes update it live.
✏️ Try these changes
-
Add from sklearn.neighbors import KNeighborsRegressor; models['KNN'] = KNeighborsRegressor(n_neighbors=5)→ another model in the comparison -
Change the sort from R2 to MAE (ascending=True for errors)→ leaderboard sorted by lowest error -
Add a 'memory_mb' column using psutil.Process().memory_info().rss→ tracks RAM usage per model -
Wrap the benchmark loop in cross_validate for more honest results→ 5-fold CV per model