Giter Site home page Giter Site logo

banjuede / jpmml-sparkml Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jpmml/jpmml-sparkml

0.0 2.0 0.0 7.15 MB

Java library and command-line application for converting Apache Spark ML pipelines to PMML

License: GNU Affero General Public License v3.0

Java 100.00%

jpmml-sparkml's Introduction

JPMML-SparkML

Java library and command-line application for converting Apache Spark ML pipelines to PMML.

Features

Prerequisites

  • Apache Spark version 1.5.X, 1.6.X, 2.0.X, 2.1.X, 2.2.X, 2.3.X or 2.4.X.

Installation

Library

JPMML-SparkML library JAR file (together with accompanying Java source and Javadocs JAR files) is released via Maven Central Repository.

The current version is 1.5.2 (7 April, 2019).

<dependency>
	<groupId>org.jpmml</groupId>
	<artifactId>jpmml-sparkml</artifactId>
	<version>1.5.2</version>
</dependency>

Compatibility matrix:

Apache Spark version JPMML-SparkML branch Status
1.5.X and 1.6.X 1.0.X Archived
2.0.X 1.1.X Archived
2.1.X 1.2.X Archived
2.2.X 1.3.X Active
2.3.X 1.4.X Active
2.4.X master Active

JPMML-SparkML depends on the latest and greatest version of the JPMML-Model library, which is in conflict with the legacy version that is part of Apache Spark version 2.0.X, 2.1.X and 2.2.X distributions.

This conflict is documented in SPARK-15526. For possible resolutions, please switch from this README.md file to the README.md file of some earlier JPMML-SparkML development branch.

Example application

Enter the project root directory and build using Apache Maven:

mvn clean install

The build produces two JAR files:

  • target/jpmml-sparkml-1.5-SNAPSHOT.jar - Library JAR file.
  • target/jpmml-sparkml-executable-1.5-SNAPSHOT.jar - Example application JAR file.

Usage

Library

Fitting a Spark ML pipeline that only makes use of supported Transformer types:

DataFrame irisData = ...;

StructType schema = irisData.schema();

RFormula formula = new RFormula()
	.setFormula("Species ~ .");

DecisionTreeClassifier classifier = new DecisionTreeClassifier()
	.setLabelCol(formula.getLabelCol())
	.setFeaturesCol(formula.getFeaturesCol());

Pipeline pipeline = new Pipeline()
	.setStages(new PipelineStage[]{formula, classifier});

PipelineModel pipelineModel = pipeline.fit(irisData);

Converting the Spark ML pipeline to PMML using the org.jpmml.sparkml.PMMLBuilder builder class:

PMML pmml = new PMMLBuilder(schema, pipelineModel)
	.build();

// Viewing the result
JAXBUtil.marshalPMML(pmml, new StreamResult(System.out));

Please refer to the following resources for more ideas and code examples:

Example application

The example application JAR file contains an executable class org.jpmml.sparkml.Main, which can be used to convert a pair of serialized org.apache.spark.sql.types.StructType and org.apache.spark.ml.PipelineModel objects to PMML.

The example application JAR file does not include Apache Spark runtime libraries. Therefore, this executable class must be executed using Apache Spark's spark-submit helper script.

For example, converting a pair of Spark ML schema and pipeline serialization files src/test/resources/schema/Iris.json and src/test/resources/pipeline/DecisionTreeIris.zip, respectively, to a PMML file DecisionTreeIris.pmml:

spark-submit --master local --class org.jpmml.sparkml.Main target/jpmml-sparkml-executable-1.5-SNAPSHOT.jar --schema-input src/test/resources/schema/Iris.json --pipeline-input src/test/resources/pipeline/DecisionTreeIris.zip --pmml-output DecisionTreeIris.pmml

Getting help:

spark-submit --master local --class org.jpmml.sparkml.Main target/jpmml-sparkml-executable-1.5-SNAPSHOT.jar --help

License

JPMML-SparkML is dual-licensed under the GNU Affero General Public License (AGPL) version 3.0, and a commercial license.

Additional information

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

Interested in using JPMML software in your application? Please contact [email protected]

jpmml-sparkml's People

Contributors

vruusmann avatar

Watchers

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