{skjs●n}
is a Python library that exports scikit-learn models to standard JSON. Compatible with Joblib and ONNX natively.
Installation
pip install skjsonQuick Start
Export directly from `model.fit()` using `skjson.save(model, 'model.json')`.
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
import skjson
X, y = load_iris(return_X_y=True)
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2, random_state=42)
clf = RandomForestClassifier(random_state=42).fit(X_train, y_train)
# Export the trained model to JSON
skjson.save(clf, 'demo.json')Convert from Existing Models
Already saved your model? Convert from .joblib or .onnx directly to JSON without retraining.
import skjson
# Convert a joblib-serialized sklearn model to JSON
skjson.joblib_to_json("model.joblib")
# → Creates "model.json" in the same directorySupported Scikit-Learn Models
skjson natively exports the following models without additional configuration: