Generate PMML for Various Models

The Predictive Model Markup Language (PMML) is an XML-based language which provides a way for applications to define machine learning, statistical and data mining models and to share models between PMML compliant applications. More information about the PMML industry standard and the Data Mining Group can be found at < https://dmg.org/>. The generated PMML can be imported into any PMML consuming application, such as Zementis Predictive Analytics products.


R package pmml - Generate PMML for Various Models

Package onCRAN CRAN RStudio mirrordownloads License Anaconda.org r-universestatus StackOverflow

This is the official home for the R package pmml (starting with version pmml_2.6.0). Previous versions can be found here.

Overview

The pmml package lets you train machine learning and statistical models in R and then export them using the Predictive Model Markup Language (PMML). Many commercial and open data mining platforms support PMML to exchange models. This includes Python’s scikit learn, Java, IBM SPSS Modeler, KNIME, Microsoft SQL Server, and SAS Enterprise Miner (see complete list).

Supported models include:

  • Anomaly Detection
  • Association Rules
  • Clustering
  • K Nearest Neighbors
  • Linear Models
  • Naive Bayes Classifiers
  • Neural Networks
  • Support Vector Machines
  • Time Series
  • Tree-based Models and Ensembles
  • Survival analysis models

Supported packages: ada, amap, arules, e1071, forecast, gbm, glmnet, isofor, kernlab, neighbr, stats, nnet, randomForest, rpart, survival, xgboost

For a description of the supported packages, see the vignette: Supported Packages and Additional Functions.

To cite package ‘pmml’ in publications use:

Hahsler M, Rodrigues B, Bolotov D, Jena T, Williams G, Lin W, Ishwaran H, Kogalur U, Guha R (2026). pmml: Generate PMML for Various Models. R package version 2.6.1, https://github.com/mhahsler/r-pmml.

@Manual{,
  title = {pmml: Generate PMML for Various Models},
  author = {Michael Hahsler and Bruno Rodrigues and Dmitriy Bolotov and Tridivesh Jena and Graham Williams and Wen-Ching Lin and Hemant Ishwaran and Udaya B. Kogalur and Rajarshi Guha},
  year = {2026},
  note = {R package version 2.6.1},
  url = {https://github.com/mhahsler/r-pmml},
}

Installation

Stable CRAN version: Install from within R with

install.packages("pmml")

Current development version: Install from r-universe.

install.packages("pmml",
    repos = c("https://mhahsler.r-universe.dev",
              "https://cloud.r-project.org/"))

Example

library(pmml)

# Build an lm model
iris_lm <- lm(Sepal.Length ~ ., data=iris)

# Convert to pmml
iris_lm_pmml <- pmml(iris_lm)

# The PMML model
iris_lm_pmml
#> <PMML version="4.4.1" xmlns="http://www.dmg.org/PMML-4_4" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.dmg.org/PMML-4_4 http://www.dmg.org/pmml/v4-4/pmml-4-4.xsd">
#>  <Header copyright="Copyright (c) 2026 mhahsler" description="Linear Regression Model">
#>   <Extension name="user" value="mhahsler" extender="R PMML Generator - Package pmml"/>
#>   <Application name="R PMML Generator - Package pmml" version="2.6.1"/>
#>   <Timestamp>2026-07-09 13:23:15.792675</Timestamp>
#>  </Header>
#>  <DataDictionary numberOfFields="5">
#>   <DataField name="Sepal.Length" optype="continuous" dataType="double"/>
#>   <DataField name="Sepal.Width" optype="continuous" dataType="double"/>
#>   <DataField name="Petal.Length" optype="continuous" dataType="double"/>
#>   <DataField name="Petal.Width" optype="continuous" dataType="double"/>
#>   <DataField name="Species" optype="categorical" dataType="string">
#>    <Value value="setosa"/>
#>    <Value value="versicolor"/>
#>    <Value value="virginica"/>
#>   </DataField>
#>  </DataDictionary>
#>  <RegressionModel modelName="lm_Model" functionName="regression" algorithmName="least squares">
#>   <MiningSchema>
#>    <MiningField name="Sepal.Length" usageType="predicted" invalidValueTreatment="returnInvalid"/>
#>    <MiningField name="Sepal.Width" usageType="active" invalidValueTreatment="returnInvalid"/>
#>    <MiningField name="Petal.Length" usageType="active" invalidValueTreatment="returnInvalid"/>
#>    <MiningField name="Petal.Width" usageType="active" invalidValueTreatment="returnInvalid"/>
#>    <MiningField name="Species" usageType="active" invalidValueTreatment="returnInvalid"/>
#>   </MiningSchema>
#>   <Output>
#>    <OutputField name="Predicted_Sepal.Length" optype="continuous" dataType="double" feature="predictedValue"/>
#>   </Output>
#>   <RegressionTable intercept="2.17126629215507">
#>    <NumericPredictor name="Sepal.Width" exponent="1" coefficient="0.495888938388551"/>
#>    <NumericPredictor name="Petal.Length" exponent="1" coefficient="0.829243912234806"/>
#>    <NumericPredictor name="Petal.Width" exponent="1" coefficient="-0.315155173326473"/>
#>    <CategoricalPredictor name="Species" value="setosa" coefficient="0"/>
#>    <CategoricalPredictor name="Species" value="versicolor" coefficient="-0.72356195778073"/>
#>    <CategoricalPredictor name="Species" value="virginica" coefficient="-1.02349781449083"/>
#>   </RegressionTable>
#>  </RegressionModel>
#> </PMML>

# Write to file: 
# save_pmml(iris_lm_pmml,"iris_lm.pmml")

Related Packages

Java

The Java library JMML can be used to read and execute models stored in PMML format. An R interface to the library to create PMML models is called r2pmml and available from CRAN. An R interface for the evaluator, called jpmml, can be installed from Github.

Python

sklearn-pmml-model can import models trained on R into Python’s scikit-learn framework.

References

Reference manual

It appears you don't have a PDF plugin for this browser. You can click here to download the reference manual.

install.packages("pmml")

2.6.1 by Michael Hahsler, 3 months ago


https://github.com/mhahsler/r-pmml


Report a bug at https://github.com/mhahsler/r-pmml/issues


Browse source code at https://github.com/cran/pmml


Authors: Michael Hahsler [aut, cre] , Bruno Rodrigues [aut] , Dmitriy Bolotov [aut] , Tridivesh Jena [aut] , Graham Williams [aut] , Wen-Ching Lin [aut] , Hemant Ishwaran [aut] , Udaya B. Kogalur [aut] , Rajarshi Guha [aut] , Software AG [cph]


Documentation:   PDF Manual  


GPL-3 | file LICENSE license


Imports methods, stats, utils, stringr

Depends on XML

Suggests ada, amap, arules, caret, clue, data.table, forecast, gbm, glmnet, magrittr, Matrix, nnet, rpart, randomForest, rattle, kernlab, e1071, testthat, survival, xgboost, knitr, rmarkdown, covr, tibble


Suggested by arules.


See at CRAN