Package: sklearn2json
Sklearn2JSONPython library for exporting Scikit-Learn models to JSON.Installpython3.10:poetryaddsklearn2json@2023.1python3.7 - 3.8:poetryaddsklearn2json@2021.5Why to use Sklearn2JSON?Scikit-learn has an integrated function to export models. This functionality is dependent on the Pickle or Joblib (based
on Pickle) libraries. Pickle module can serialize almost any Python object, without any boilerplate or even
white-/black-listing (in the typical case). However, it is unsafe because it constructs arbitrary Python objects by
invoking random functions. Therefore, if one inner variable is refactored in your deployed machine learning model, it
cannot be loaded with the newest version ofscikit-learn. This can cause a maintenance overhead and headaches for
deployed machine learning-based projects.Moreover, 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 (example).Sklearn2JSON is a safe and transparent solution for exporting scikit-learn model files.SafeExport model files to 100% JSON which cannot execute code on deserialization.TransparentModel files are serialized in JSON (i.e., not binary), so you have the ability to see exactly what's inside.Easy careThe library saves the mathematical parameters (inner variables) of the trained machine learning model, which can be used
in the future with newer version of scikit-learn even when the class parameters have changed a bit.Example Usageimport sklearn2json as sk
    from sklearn.ensemble import RandomForestClassifier

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

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

    deserialized_model.predict(X)FeaturesThe list of supported models is growing. If you have a request for a model or feature, please reach out tosklearn2json@docutent.org.Sklearn2JSON is licensed under the terms and conditions of
theGNU Affero General Public License, Version 3.0.If you would like to use Sklearn2JSON in a proprietary software project, then it is possible to enter into a licensing
agreement which makes Sklearn2JSON available under the terms and conditions of
theBSD 3-Clause Licenseinstead.ContributingFor guidance on setting up a development environment and how to make a contribution to Sklearn2JSON, see
thecontributing guidelines.Additional informationThe concept of the project is based on the sklearn-json project. SkLearn2JSON is developed, supported and maintained by
MONTANA Knowledge Management LTD, Hungary. In order to grow the community of contributors and users, and allow the
maintainers to devote more time to the projects, [please donate today]donate.Interested in usingDocutentsoftware in your company? Please
contactinfo@docutent.orgSupported scikit-learn ModelsClassificationsklearn.linear_model.LogisticRegressionsklearn.linear_model.Perceptronsklearn.discriminant_analysis.LinearDiscriminantAnalysissklearn.discriminant_analysis.QuadraticDiscriminantAnalysissklearn.svm.SVCsklearn.svm.LinearSVCsklearn.naive_bayes.GaussianNBsklearn.naive_bayes.MultinomialNBsklearn.naive_bayes.ComplementNBsklearn.naive_bayes.BernoulliNBsklearn.tree.DecisionTreeClassifiersklearn.ensemble.RandomForestClassifiersklearn.ensemble.GradientBoostingClassifiersklearn.neural_network.MLPClassifierRegressionsklearn.linear_model.ElasticNetsklearn.linear_model.LinearRegressionsklearn.linear_model.Ridgesklearn.linear_model.Lassosklearn.svm.SVRsklearn.tree.DecisionTreeRegressorsklearn.ensemble.RandomForestRegressorsklearn.ensemble.GradientBoostingRegressorsklearn.neural_network.MLPRegressorClusteringsklearn.cluster.KMeanssklearn.cluster.DBSCANOthersklearn.feature_extraction.text.TfidfVectorizersklearn.decomposition.TruncatedSVDsklearn.preprocessing.LabelBinarizerscipy.sparse.csr_matrix