Export scikit-learn models to JSON for cross-language inference
Project description
skjson
Export scikit-learn models to JSON for cross-language inference.
Installation
pip install skjson
Quick Start
Check out the demo notebook for an example training a Random Forest on the Iris dataset:
from sklearn.datasets import load_iris
from sklearn.ensemble import RandomForestClassifier
from sklearn.model_selection import train_test_split
import skjson
# Load the Iris dataset and split
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)
# Train a Random Forest classifier
clf = RandomForestClassifier(random_state=42)
clf.fit(X_train, y_train)
# Export the trained model to JSON
skjson.save(clf, 'demo.json')
# Load and reuse the model
predictor = skjson.load("demo.json")
Support models for conversion
Linear Models (sklearn.linear_model)
LinearRegression,Ridge,Lasso,ElasticNetLogisticRegression
Tree-based Models (sklearn.tree, sklearn.ensemble)
DecisionTreeClassifier,DecisionTreeRegressorRandomForestClassifier,RandomForestRegressorGradientBoostingClassifier,GradientBoostingRegressor
Support Vector Machines (sklearn.svm)
SVC,SVR,LinearSVC
Neighbors (sklearn.neighbors)
KNeighborsClassifier,KNeighborsRegressor
Naive Bayes (sklearn.naive_bayes)
GaussianNB
Preprocessing (sklearn.preprocessing)
StandardScaler,MinMaxScaler,LabelEncoder
Future Directions
- Support for scikit-learn
Pipelineobjects and feature unions. - npm package for inference using our json models
- Support for sklearn.neural_network models
Note
- This project built with Google Gemini and Claude Opus.
- If you wish to contribute, please contact me.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file skjson-0.1.1.tar.gz.
File metadata
- Download URL: skjson-0.1.1.tar.gz
- Upload date:
- Size: 25.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e5133c65d6623e79a81ccf71624b00ecc9c58c56aa96e367f9e08c59ad51ae5
|
|
| MD5 |
6da43146dcea1d45f5b479bf0105afab
|
|
| BLAKE2b-256 |
fcd95fa48ce3eb3cfce78baef2d8d8145558b165af2f920be6c430cb3f1b536e
|
Provenance
The following attestation bundles were made for skjson-0.1.1.tar.gz:
Publisher:
publish.yml on hongyaok/skjson
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
skjson-0.1.1.tar.gz -
Subject digest:
5e5133c65d6623e79a81ccf71624b00ecc9c58c56aa96e367f9e08c59ad51ae5 - Sigstore transparency entry: 1704225981
- Sigstore integration time:
-
Permalink:
hongyaok/skjson@d5b3ec49d8b576eafaff00fa43efa7229afa03f3 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/hongyaok
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d5b3ec49d8b576eafaff00fa43efa7229afa03f3 -
Trigger Event:
release
-
Statement type:
File details
Details for the file skjson-0.1.1-py3-none-any.whl.
File metadata
- Download URL: skjson-0.1.1-py3-none-any.whl
- Upload date:
- Size: 15.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
304fc80dac0b6e9a362406450d0e63de0c41b49982db0aa0c2983ede186c8c52
|
|
| MD5 |
9e18cfdfa534a6ae339d0d0ff725ebf5
|
|
| BLAKE2b-256 |
57305e042443eda150ecf5121cfb3ca93169aac417831ab4316066471613d4c4
|
Provenance
The following attestation bundles were made for skjson-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on hongyaok/skjson
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
skjson-0.1.1-py3-none-any.whl -
Subject digest:
304fc80dac0b6e9a362406450d0e63de0c41b49982db0aa0c2983ede186c8c52 - Sigstore transparency entry: 1704226005
- Sigstore integration time:
-
Permalink:
hongyaok/skjson@d5b3ec49d8b576eafaff00fa43efa7229afa03f3 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/hongyaok
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@d5b3ec49d8b576eafaff00fa43efa7229afa03f3 -
Trigger Event:
release
-
Statement type: