Code Monkey home page Code Monkey logo

jpmml-model's Introduction

JPMML-Model Build Status

Java Class Model API for Predictive Model Markup Language (PMML).

Features

  • Full support for PMML 3.0, 3.1, 3.2, 4.0, 4.1 and 4.2 schemas:
    • Schema version annotations.
  • Enhanced API:
    • Class hierarchy.
    • Value constructors.
    • Method chaining.
  • [Visitor pattern] (http://en.wikipedia.org/wiki/Visitor_pattern):
    • Validation agents.
    • Optimization and transformation agents.
  • Memory efficient:
    • Optional SAX Locator information
  • GWT compatible

Prerequisites

  • Java 1.7 or newer

Installation

JPMML-Model library JAR files (together with accompanying Java source and Javadocs JAR files) are released via [Maven Central Repository] (http://repo1.maven.org/maven2/org/jpmml/). Please join the [JPMML mailing list] (https://groups.google.com/forum/#!forum/jpmml) for release announcements.

The current version is 1.2.2 (26 May, 2015).

<dependency>
	<groupId>org.jpmml</groupId>
	<artifactId>pmml-model</artifactId>
	<version>1.2.2</version>
</dependency>

Usage

The class model consists of two types of classes. There is a small number of manually crafted classes that are used for structuring the class hierarchy. They are permanently stored in the Java sources directory /pmml-model/src/main/java. Additionally, there is a much greater number of automatically generated classes that represent actual PMML elements. They can be found in the generated Java sources directory /pmml-model/target/generated-sources/xjc after a successful build operation.

All class model classes descend from class org.dmg.pmml.PMMLObject. Additional class hierarchy levels, if any, represent common behaviour and/or features. For example, all model classes descend from class org.dmg.pmml.Model.

The class model should be self-explanatory. The application developer is advised to consult with the latest [PMML specification] (http://www.dmg.org/v4-2-1/GeneralStructure.html) about the specifics of individual PMML elements and attributes.

Unmarshalling

Load any PMML schema version 3.X or 4.X document into live org.dmg.pmml.PMML instance:

public PMML load(InputStream is) throws Exception {
  InputSource source = new InputSource(is);

  // Use SAX filtering to transform PMML schema version 3.X and 4.X documents to PMML schema version 4.2 document
  SAXSource transformedSource = ImportFilter.apply(source);

  return JAXBUtil.unmarshalPMML(transformedSource);
}

Important: It is the responsibility of the application developer to ensure that the XML document does not contain malicious content (eg. XEE and XXE attacks).

Applying visitors

Delete SAX Locator information from the class model:

public void optimize(PMML pmml){
  LocatorNullifier nullifier = new LocatorNullifier();
  nullifier.applyTo(pmml);
}

Marshalling

Store live org.dmg.pmml.PMML instance into PMML schema version 4.2 document:

public void store(PMML pmml, OutputStream os) throws Exception {
  StreamResult result = new StreamResult(os);

  JAXBUtil.marshalPMML(pmml, result);
}

Example applications

Module pmml-model-example exemplifies the use of JPMML-Model library.

This module can be built using [Apache Maven] (http://maven.apache.org/):

mvn clean install

The resulting uber-JAR file target/example-1.2-SNAPSHOT.jar contains the following command-line applications:

For example, checking the validity of model.pmml:

java -cp target/example-1.2-SNAPSHOT.jar org.jpmml.model.ValidationExample --input model.pmml

License

JPMML-Model is licensed under the [BSD 3-Clause License] (http://opensource.org/licenses/BSD-3-Clause).

Additional information

Please contact [[email protected]] (mailto:[email protected])

jpmml-model's People

Contributors

vruusmann avatar

Watchers

James Cloos avatar JohnYang avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.