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 http://code.google.com/p/openscoring/.
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!