Pickle / joblib serialisation
Save a trained model to a .pkl file. Load it later without retraining.
Code example
import joblib
# save
joblib.dump(model, 'rf_model.pkl')
# load (could be in a different process / server)
model = joblib.load('rf_model.pkl')
preds = model.predict(X_new)
How it works
Training a model can take minutes or hours; predicting takes milliseconds. Pickle/joblib serialises the trained model object (including learned weights, hyperparameters, feature importances) into a binary file. You can then load that file in a different process and call predict() without retraining. OpenBenchML's whole upload flow is built on this: users train locally, dump to .pkl, upload the .pkl, and the server loads it for benchmarking. joblib is preferred over pickle for sklearn models because it handles numpy arrays more efficiently.
🔍 Where this is used in OpenBenchML
app/routes/models.py — upload endpoint receives .pkl. app/routes/benchmark.py — joblib.load() then predict().