Skip to main content

skml-json

Export scikit-learn model files to JSON for sharing or deploying predictive models with peace of mind.

Why skml-json?

Other methods for exporting scikit-learn models require Pickle or Joblib (based on Pickle). Serializing model files with Pickle provides a simple attack vector for malicious users-- they give an attacker the ability to execute arbitrary code wherever the file is deserialized. For an example see: https://www.smartfile.com/blog/python-pickle-security-problems-and-solutions/.

skml-json is a safe and transparent solution for exporting scikit-learn model files.

Safe

Export model files to 100% JSON which cannot execute code on deserialization.

Transparent

Model files are serialized in JSON (i.e., not binary), so you have the ability to see exactly what's inside.

Getting Started

makes exporting model files to JSON simple.

Install

pip install skml-json

Example Usage

import skml_json as skmljson
from sklearn.ensemble import RandomForestClassifier

model = RandomForestClassifier(n_estimators=10, max_depth=5, random_state=0).fit(X, y)

skmljson.to_json(model, file_name)
deserialized_model = skmljson.from_json(file_name)

deserialized_model.predict(X)

Features

skml-json requires scikit-learn >= 1.4.0.

Supported scikit-learn Models

  • Classification

    • sklearn.linear_model.LogisticRegression
    • sklearn.linear_model.Perceptron
    • sklearn.discriminant_analysis.LinearDiscriminantAnalysis
    • sklearn.discriminant_analysis.QuadraticDiscriminantAnalysis
    • sklearn.svm.SVC
    • sklearn.naive_bayes.GaussianNB
    • sklearn.naive_bayes.MultinomialNB
    • sklearn.naive_bayes.ComplementNB
    • sklearn.naive_bayes.BernoulliNB
    • sklearn.tree.DecisionTreeClassifier
    • sklearn.ensemble.RandomForestClassifier
    • sklearn.ensemble.GradientBoostingClassifier
    • sklearn.neural_network.MLPClassifier
  • Regression

    • sklearn.linear_model.LinearRegression
    • sklearn.linear_model.Ridge
    • sklearn.linear_model.Lasso
    • sklearn.svm.SVR
    • sklearn.tree.DecisionTreeRegressor
    • sklearn.ensemble.RandomForestRegressor
    • sklearn.ensemble.GradientBoostingRegressor
    • sklearn.neural_network.MLPRegressor

Metadata

Release files for skml-json 1.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for skml-json 1.0.2
File Size Uploaded Provenance Actions
skml_json-1.0.2.tar.gz 10.0 kB Without provenance Details for skml_json-1.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for skml-json 1.0.2
File Interpreter ABI Platform Actions
skml_json-1.0.2-py3-none-any.whl Python 3 none any Details for skml_json-1.0.2-py3-none-any.whl

Total release size: 20.9 kB

Release files / skml_json-1.0.2.tar.gz

Download URL skml_json-1.0.2.tar.gz
Size 10.0 kB
Tags Source
SHA-256 checksum
How to use checksums
7202035dc42b6a61af0f90feed249ff764afa940d2ed004c6cf06dc0a14f23a0
BLAKE2b-256 checksum
How to use checksums
2ffa62a018a4e97c416e362482288f3b418f638943d430e0f71d00cbdea14887
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.0

Release files / skml_json-1.0.2-py3-none-any.whl

Download URL skml_json-1.0.2-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
838e93e8a1a95c1e41417d80044be101fcfbb0664dcc997657eee9f25ac3767a
BLAKE2b-256 checksum
How to use checksums
519426756c764361276cbfc053f3e1c2dec9750f2bfc0df0155a643cbbc9ecbd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.0

Security for skml-json 1.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page