Show HN: Skeights – Serialize sklearn models to safetensors and JSON, no pickle

Serialize fitted scikit-learn models to safetensors + JSON. No pickle. - carbon-re/skeights
3 points by alxhslm 108 days ago github.com 0 comments
Summary not yet generated for this article.

Original Text

We use sklearn in production for time series forecasting in industrial settings. Pickle was causing us constant pain: refactoring our wrapper classes invalidated saved models, and the binary blobs were completely opaque.

We built skeights to decompose a fitted estimator into two files. A JSON file for hyperparameters and structure, and a safetensors file for the numeric arrays. The JSON is human-readable and diffable, and safetensors is a well-established safe format from Hugging Face.

This allows you to trade models as config. The JSON is just data you can inspect, diff, and version alongside the rest of your config, rather than a binary artefact on the side.

It supports most common sklearn estimators (linear models, trees, random forests, gradient boosting, MLPs, pipelines), plus LightGBM and XGBoost. MIT licensed.

Blog post with a worked example: https://alxhslm.github.io/projects/skeights/

Repo: https://github.com/carbon-re/skeights

`pip install skeights`

Comments (0 of ) ⌛

Loading more comments... ⌛
Scroll down to load more comments
No comments available.
Type to search HN and engineering blog articles
Press Escape to close  |  ↑↓ to navigate  |  Enter to open