skml-json


Nameskml-json JSON
Version 1.0.2 PyPI version JSON
download
home_pageNone
SummaryExport scikit-learn>=1.4.0 model files to JSON for sharing or deploying predictive models with peace of mind. Original by Mathieu Rodrigue
upload_time2024-07-15 19:17:40
maintainerNone
docs_urlNone
authorNone
requires_python>=3.12
licenseMIT 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.
keywords sklearn json
VCS
bugtrack_url
requirements scikit-learn
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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`

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "skml-json",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.12",
    "maintainer_email": null,
    "keywords": "sklearn, json",
    "author": null,
    "author_email": "Sadio <sadio.ousmane@esp.sn>",
    "download_url": "https://files.pythonhosted.org/packages/2f/fa/62a018a4e97c416e362482288f3b418f638943d430e0f71d00cbdea14887/skml_json-1.0.2.tar.gz",
    "platform": null,
    "description": "# skml-json\r\nExport scikit-learn model files to JSON for sharing or deploying predictive models with peace of mind.\r\n\r\n# Why skml-json?\r\nOther 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/.\r\n\r\nskml-json is a safe and transparent solution for exporting scikit-learn model files.\r\n\r\n### Safe\r\nExport model files to 100% JSON which cannot execute code on deserialization.\r\n\r\n### Transparent\r\nModel files are serialized in JSON (i.e., not binary), so you have the ability to see exactly what's inside.\r\n\r\n# Getting Started\r\n\r\nmakes exporting model files to JSON simple.\r\n\r\n## Install\r\n```\r\npip install skml-json\r\n```\r\n## Example Usage\r\n\r\n```python\r\nimport skml_json as skmljson\r\nfrom sklearn.ensemble import RandomForestClassifier\r\n\r\nmodel = RandomForestClassifier(n_estimators=10, max_depth=5, random_state=0).fit(X, y)\r\n\r\nskmljson.to_json(model, file_name)\r\ndeserialized_model = skmljson.from_json(file_name)\r\n\r\ndeserialized_model.predict(X)\r\n```\r\n\r\n# Features\r\n\r\nskml-json requires scikit-learn >= 1.4.0.\r\n\r\n## Supported scikit-learn Models\r\n\r\n* Classification\r\n    * `sklearn.linear_model.LogisticRegression`\r\n    * `sklearn.linear_model.Perceptron`\r\n    * `sklearn.discriminant_analysis.LinearDiscriminantAnalysis`\r\n    * `sklearn.discriminant_analysis.QuadraticDiscriminantAnalysis`\r\n    * `sklearn.svm.SVC`\r\n    * `sklearn.naive_bayes.GaussianNB`\r\n    * `sklearn.naive_bayes.MultinomialNB`\r\n    * `sklearn.naive_bayes.ComplementNB`\r\n    * `sklearn.naive_bayes.BernoulliNB`\r\n    * `sklearn.tree.DecisionTreeClassifier`\r\n    * `sklearn.ensemble.RandomForestClassifier`\r\n    * `sklearn.ensemble.GradientBoostingClassifier`\r\n    * `sklearn.neural_network.MLPClassifier`\r\n\r\n* Regression\r\n    * `sklearn.linear_model.LinearRegression`\r\n    * `sklearn.linear_model.Ridge`\r\n    * `sklearn.linear_model.Lasso`\r\n    * `sklearn.svm.SVR`\r\n    * `sklearn.tree.DecisionTreeRegressor`\r\n    * `sklearn.ensemble.RandomForestRegressor`\r\n    * `sklearn.ensemble.GradientBoostingRegressor`\r\n    * `sklearn.neural_network.MLPRegressor`\r\n",
    "bugtrack_url": null,
    "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.",
    "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",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://github.com/osadio/skml-json"
    },
    "split_keywords": [
        "sklearn",
        " json"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "519426756c764361276cbfc053f3e1c2dec9750f2bfc0df0155a643cbbc9ecbd",
                "md5": "a12b1e7720cf2e0ad5a1a8dfd2605a0b",
                "sha256": "838e93e8a1a95c1e41417d80044be101fcfbb0664dcc997657eee9f25ac3767a"
            },
            "downloads": -1,
            "filename": "skml_json-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a12b1e7720cf2e0ad5a1a8dfd2605a0b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.12",
            "size": 10909,
            "upload_time": "2024-07-15T19:17:38",
            "upload_time_iso_8601": "2024-07-15T19:17:38.337537Z",
            "url": "https://files.pythonhosted.org/packages/51/94/26756c764361276cbfc053f3e1c2dec9750f2bfc0df0155a643cbbc9ecbd/skml_json-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2ffa62a018a4e97c416e362482288f3b418f638943d430e0f71d00cbdea14887",
                "md5": "d21220eed5e0c8479770ac8dacfead60",
                "sha256": "7202035dc42b6a61af0f90feed249ff764afa940d2ed004c6cf06dc0a14f23a0"
            },
            "downloads": -1,
            "filename": "skml_json-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "d21220eed5e0c8479770ac8dacfead60",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.12",
            "size": 9969,
            "upload_time": "2024-07-15T19:17:40",
            "upload_time_iso_8601": "2024-07-15T19:17:40.105157Z",
            "url": "https://files.pythonhosted.org/packages/2f/fa/62a018a4e97c416e362482288f3b418f638943d430e0f71d00cbdea14887/skml_json-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-07-15 19:17:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "osadio",
    "github_project": "skml-json",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "scikit-learn",
            "specs": [
                [
                    ">=",
                    "1.4.0"
                ]
            ]
        }
    ],
    "lcname": "skml-json"
}
        
Elapsed time: 3.08024s