OpenScoring: Open Source Scoring of PMML Models via REST

November 27, 2012

(This article was first published on Advanced Analytics Blog by Scott Mutchler, and kindly contributed to R-bloggers)

The other day I stumbled accross an amazing PMML model API called jpmml.  It’s written in Java and supports PMML 4.1 (and older).  Neural networks, random forests, regression and trees PMML models can be consumed and used for scoring.

I decided to write a REST interface that wraps the jpmml engine.  This allows remote clients, written in just about any language, to have a simple interface to “cloud” scoring.

You can develop your predictive models in R, export them to PMML and score the models directly from client applications.  I’m a big fan of Rattle for the first two steps.

OpenScoring can be dowloaded from

To install the OpenScoring web application in Tomcat, copy the OpenScoring.war file to the $TOMCAT_HOME\webapps directory.

To invoke the scoring service, you perform an HTTP POST to http://localhost:8080/OpenScoring/Scoring.  The format of the post is XML.  Here is a sample POST to score against a Neural Network PMML model using the well-known iris data set.

Here is the sample XML input:

The pmml_url element is a http, file or ftp URL that points to the PMML XML file.  The csv_input_rows element contains the records to score.  The rows are comma separated values with pipe delimited rows.

Here is the response XML:

It’s a bit hard to read but the response contains all the input data with an additional column $PREDICTED.  The $PREDICTED column contains the species prediction propensities.
There is also a Java API.  Here is sample code to call the REST scoring service from Java:
StringBuffer csvInputRows = new StringBuffer();

ScoringRequest req = new ScoringRequest(
null, // model name (null = default)
null, // user id for basic authentication
null, // password for basic authentication

ScoringResponse res = ScoringClient.score(req);

The output CSV in Excel is:
The software is currently in alpha release v0.1.   It’s distributed under a GPL v3 license.  
If you are interested in contributing to this software please feel free to join in!

To leave a comment for the author, please follow the link and comment on their blog: Advanced Analytics Blog by Scott Mutchler. offers daily e-mail updates about R news and tutorials on topics such as: Data science, Big Data, R jobs, visualization (ggplot2, Boxplots, maps, animation), programming (RStudio, Sweave, LaTeX, SQL, Eclipse, git, hadoop, Web Scraping) statistics (regression, PCA, time series, trading) and more...

If you got this far, why not subscribe for updates from the site? Choose your flavor: e-mail, twitter, RSS, or facebook...

Comments are closed.


Mango solutions

RStudio homepage

Zero Inflated Models and Generalized Linear Mixed Models with R

Quantide: statistical consulting and training



CRC R books series

Six Sigma Online Training

Contact us if you wish to help support R-bloggers, and place your banner here.

Never miss an update!
Subscribe to R-bloggers to receive
e-mails with the latest R posts.
(You will not see this message again.)

Click here to close (This popup will not appear again)