Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Norrrrrrr lyn WAInjectBench joblib dump

From Leeroopedia
Revision as of 13:23, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Norrrrrrr_lyn_WAInjectBench_joblib_dump.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Knowledge Sources
Domains Machine_Learning, Model_Management
Last Updated 2026-02-14 16:00 GMT

Overview

Concrete tool for serializing trained LogisticRegression classifiers to .pkl files, provided by the joblib library as used in the WAInjectBench embedding trainers.

Description

Both text and image embedding trainers use joblib.dump(clf, save_path) to persist the fitted classifier. The save path is constructed as {output_dir}/{jsonl_stem}_logreg.pkl. The text variant also optionally saves embeddings to a separate JSONL file (save_emb=True by default).

Usage

Called as the final step of train_single_classifier after fitting the LogisticRegression model.

Code Reference

Source Location

  • Repository: WAInjectBench
  • File: train/embedding-t.py (L38), train/embedding-i.py (L59-60)

Signature

# Text variant (train/embedding-t.py:L36-38)
model_name = Path(jsonl_file).stem + "_logreg.pkl"
save_path = os.path.join(output_dir, model_name)
joblib.dump(clf, save_path)

# Image variant (train/embedding-i.py:L58-60)
model_name = Path(jsonl_file).stem + "_logreg.pkl"
save_path = os.path.join(output_dir, model_name)
joblib.dump(clf, save_path)

Import

import joblib

I/O Contract

Inputs

Name Type Required Description
clf LogisticRegression Yes Fitted classifier object
save_path str Yes Output file path ({output_dir}/{stem}_logreg.pkl)

Outputs

Name Type Description
.pkl file File Serialized classifier at the specified path

Usage Examples

Saving and Loading a Classifier

import joblib
from sklearn.linear_model import LogisticRegression

# Train classifier
clf = LogisticRegression(max_iter=1000)
clf.fit(embeddings, labels)

# Save
joblib.dump(clf, "models/dataset_logreg.pkl")

# Load for inference
loaded_clf = joblib.load("models/dataset_logreg.pkl")
predictions = loaded_clf.predict(new_embeddings)

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment