Metadata-Version: 2.1
Name: skml-json
Version: 1.0.2
Summary: Export scikit-learn>=1.4.0 model files to JSON for sharing or deploying predictive models with peace of mind. Original by Mathieu Rodrigue
Author-email: Sadio <sadio.ousmane@esp.sn>
License: MIT License
        
        Copyright (c) 2024 osadio
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/osadio/skml-json
Keywords: sklearn,json
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: scikit-learn >=1.4.0

# 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

```python
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`
