# jpmml-statsmodels **Repository Path**: mirrors_jpmml/jpmml-statsmodels ## Basic Information - **Project Name**: jpmml-statsmodels - **Description**: Java library and command-line application for converting StatsModels models to PMML - **Primary Language**: Unknown - **License**: AGPL-3.0 - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-09 - **Last Updated**: 2026-09-12 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README JPMML-StatsModels [![Build Status](https://github.com/jpmml/jpmml-statsmodels/workflows/maven/badge.svg)](https://github.com/jpmml/jpmml-statsmodels/actions?query=workflow%3A%22maven%22) ================= Java library and command-line application for converting [StatsModels](https://www.statsmodels.org/) models to PMML. # Features # * Supported model types: * Linear Regression: * [Ordinary Least Squares](https://www.statsmodels.org/dev/generated/statsmodels.regression.linear_model.OLS.html) * [Quantile Regression](https://www.statsmodels.org/dev/generated/statsmodels.regression.quantile_regression.QuantReg.html) * [Weighted Least Squares](https://www.statsmodels.org/dev/generated/statsmodels.regression.linear_model.WLS.html) * Generalized Linear Regression: * [Generalized Linear Models](https://www.statsmodels.org/stable/generated/statsmodels.genmod.generalized_linear_model.GLM.html): * Families: `Binomial`, `Gaussian`, `Poisson` * Link Functions: `identity`, `Log`, `Logit` * Regression with Discrete Dependent Variable: * [Logit](https://www.statsmodels.org/dev/generated/statsmodels.discrete.discrete_model.Logit.html) * [Multinomial Logit](https://www.statsmodels.org/dev/generated/statsmodels.discrete.discrete_model.MNLogit.html) * [Poisson](https://www.statsmodels.org/dev/generated/statsmodels.discrete.discrete_model.Poisson.html) * [OrderedModel](https://www.statsmodels.org/dev/generated/statsmodels.miscmodels.ordinal_model.OrderedModel.html): * Distributions: `logit`, `probit` * Univariate Time-Series Analysis: * [ARIMA](https://www.statsmodels.org/dev/generated/statsmodels.tsa.arima.model.ARIMA.html) * Production quality: * Complete test coverage. * Fully compliant with the [JPMML-Evaluator](https://github.com/jpmml/jpmml-evaluator) library. # Installation # Enter the project root directory and build using [Apache Maven](https://maven.apache.org/): ``` mvn clean install ``` The build produces a library JAR file `pmml-statsmodels/target/pmml-statsmodels-1.3-SNAPSHOT.jar`, and an executable uber-JAR file `pmml-statsmodels-example/target/pmml-statsmodels-example-executable-1.3-SNAPSHOT.jar`. # Usage # A typical workflow can be summarized as follows: 1. Use Python to fit a model. 2. Save the model fitting results in `pickle` data format to a file in a local filesystem. 3. Use the JPMML-StatsModels command-line converter application to turn the Pickle file to a PMML file. ### The Python side of operations Loading data to a `pandas.DataFrame` object: ```python import pandas auto_df = pandas.read_csv("Auto.csv") ``` Fitting a regression model using an R-style formula: ```python from statsmodels.formula.api import ols model = ols(formula = "mpg ~ C(cylinders) + displacement + horsepower + weight + acceleration + C(model_year) + C(origin)", data = auto_df) results = model.fit() print(results.summary()) ``` Storing the fitted `RegressionResults(Wrapper)` object in `pickle` data format: ```python results.save("model.pkl", remove_data = True) ``` ### The JPMML-StatsModels side of operations Converting the model fitting results Pickle file `model.pkl` to a PMML file `model.pmml`: ``` java -jar pmml-statsmodels-example/target/pmml-statsmodels-example-executable-1.3-SNAPSHOT.jar --pkl-input model.pkl --pmml-output model.pmml ``` Getting help: ``` java -jar pmml-statsmodels-example/target/pmml-statsmodels-example-executable-1.3-SNAPSHOT.jar --help ``` # Documentation # * [Training Scikit-Learn GridSearchCV StatsModels pipelines](https://openscoring.io/blog/2023/10/15/sklearn_statsmodels_gridsearchcv_pipeline/) * [Training Scikit-Learn StatsModels pipelines](https://openscoring.io/blog/2023/03/28/sklearn_statsmodels_pipeline/) # License # JPMML-StatsModels is licensed under the terms and conditions of the [GNU Affero General Public License, Version 3.0](https://www.gnu.org/licenses/agpl-3.0.html). If you would like to use JPMML-StatsModels in a proprietary software project, then it is possible to enter into a licensing agreement which makes JPMML-StatsModels available under the terms and conditions of the [BSD 3-Clause License](https://opensource.org/licenses/BSD-3-Clause) instead. # Additional information # JPMML-StatsModels is developed and maintained by Openscoring Ltd, Estonia. Interested in using [Java PMML API](https://github.com/jpmml) software in your company? Please contact [info@openscoring.io](mailto:info@openscoring.io)