Skops

0.13.0 · active · verified Thu Apr 09

Skops is a set of tools designed for machine learning in production, focusing on model persistence, sharing, and documentation. It provides secure object dumping/loading, integrates with Hugging Face Hub for sharing, and helps generate Model Cards. The library is currently at version 0.13.0 and maintains a regular release cadence, typically monthly or bi-monthly, addressing bug fixes, enhancements, and security improvements.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to train a basic scikit-learn model, save it using `skops.io.dump`, and then load it back using `skops.io.load`. This is the most common use case for skops, providing a secure and robust way to persist machine learning models.

from sklearn.linear_model import LogisticRegression
from skops.io import dump, load

# Train a simple model
model = LogisticRegression(random_state=42)
model.fit([[0, 0], [0, 1], [1, 0], [1, 1]], [0, 0, 1, 1])

# Save the model securely
dump(model, 'model.skops')

# Load the model
loaded_model = load('model.skops')

# Make a prediction with the loaded model
prediction = loaded_model.predict([[0, 0]])
print(f"Original model class: {type(model).__name__}")
print(f"Loaded model class: {type(loaded_model).__name__}")
print(f"Prediction: {prediction[0]}")

view raw JSON →