Skip to content

jpmml/jpmml-statsmodels

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 
 
 
 
 

JPMML-StatsModels Build Status

Java library and command-line application for converting StatsModels models to PMML.

Features

Installation

Enter the project root directory and build using Apache Maven:

mvn clean install

The build produces a library JAR file pmml-statsmodels/target/pmml-statsmodels-1.0-SNAPSHOT.jar, and an executable uber-JAR file pmml-statsmodels-example/target/pmml-statsmodels-example-executable-1.0-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:

import pandas

auto_df = pandas.read_csv("Auto.csv")

Fitting a regression model using an R-style formula:

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:

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.0-SNAPSHOT.jar --pkl-input model.pkl --pmml-output model.pmml

Getting help:

java -jar pmml-statsmodels-example/target/pmml-statsmodels-example-executable-1.0-SNAPSHOT.jar --help

License

JPMML-StatsModels is licensed under the terms and conditions of the GNU Affero General Public License, Version 3.0.

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 instead.

Additional information

JPMML-StatsModels is developed and maintained by Openscoring Ltd, Estonia.

Interested in using Java PMML API software in your company? Please contact info@openscoring.io

About

Java library and command-line application for converting StatsModels models to PMML

Resources

License

Stars

Watchers

Forks

Packages

No packages published