Giter Site home page Giter Site logo

flinkml / flink-jpmml Goto Github PK

View Code? Open in Web Editor NEW
96.0 13.0 30.0 368 KB

flink-jpmml is a fresh-made library for dynamic real time machine learning predictions built on top of PMML standard models and Apache Flink streaming engine

License: GNU Affero General Public License v3.0

Scala 100.00%
flink-jpmml apache-flink pmml prediction model-serving

flink-jpmml's People

Contributors

chobeat avatar maocorte avatar riccardo14 avatar stefanobaghino avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flink-jpmml's Issues

Unresolved Dependencies io.radicalbit#flink-streaming-spec_2.11;0.3.0: not found

Hi, I cloned the repo, release-0.6.2 branch and imported the project to intellij, the SBT build fails both.

[warn] 	::::::::::::::::::::::::::::::::::::::::::::::
[warn] 	::          UNRESOLVED DEPENDENCIES         ::
[warn] 	::::::::::::::::::::::::::::::::::::::::::::::
[warn] 	:: io.radicalbit#flink-streaming-spec_2.11;0.1.0: not found
[warn] 	::::::::::::::::::::::::::::::::::::::::::::::
[warn]
[warn] 	Note: Unresolved dependencies path:
[warn] 		io.radicalbit:flink-streaming-spec_2.11:0.1.0 (/Users/harishsridhar/Documents/Temp/flink-jpmml/flink-jpmml/build.sbt#L64)
[warn] 		  +- io.radicalbit:flink-jpmml-scala_2.11:0.6.2

Am I missing something?

Regards,
Harish.

Can't load models in a Flink Cluster setup

Hi,

I built a sample flink application that consumes events from Kafka Topic and evaluates the incoming events using a model present in the file system using ModelReader

val prediction = appsDataStream.evaluate(modelReader) {
      //Iris data and modelReader instance
      case (event, model) =>
        val vectorized = event.toDenseVector
        val prediction = model.predict(vectorized, Some(0.0))

        (event, prediction)
    }

This works on a flink local cluster. However this doesn't work when I deploy the applicatoin on a flink cluster with job manager and task manager running in separate nodes.

The reason for this not working is the PMML model along with application is packaged as a fat jar and uploaded to the job manager. The Job manager sends model evaluate task to the task managers and the task managers don't have the PMML model file available.

Currently flink-jpmml implementation only allows the path of the pmml model file to be provided as input and the library implements the model upload using the path. This doesn't work in cluster mode.
We may need additional implementation where by we can provide the whole PMML model file InputStream using which the library can upload the PMML models.

Regards,
Harish.

Handle additional dependencies

Hi,

In the flink-jpmml documentation, it is mentioned that the dependency to be added to projects is as follows.

"io.radicalbit" %% "flink-jpmml-scala" % "0.6.3"

But when I tried to build a simple example using the IRIS datasource, I figured that there needs to be additional dependencies for the project such as the following

"org.jpmml" % "pmml-evaluator" % "1.3.9",
 "org.glassfish.jaxb" % "jaxb-runtime" % "2.3.2"

I wanted to suggest to either add these additional manadatory dependencies to the library"io.radicalbit" %% "flink-jpmml-scala" % "0.6.3" or mention it alteast in README as a note under dependency section.

Regards,
Harish.

Evaluate removing hadoop dependencies

Since the lib relies to Flink underlying FS management we should not test whenever a PMML model is stored on top of HDFS, either any hadoop implementation. So my proposal is to remove the former dependencies; moreover, it will boost up performances.

Integer Type Target value not supported

Hi,

The model I used to test the flink-jpmml library had the target value as Integer type.
Following is the target field from the PMML model I used.

<DataDictionary>
		<DataField name="Label" optype="categorical" dataType="integer">
			<Value value="0"/>
			<Value value="1"/>

This resulted in EmptyPrediction for all my inputs.
When I debugged, I found that this is because the integer type target field is not supported in library implementation.

Following is the place where it breaks.

pmmlModel.scala method extractTarget

private[api] def extractTarget(evaluationResult: java.util.Map[FieldName, _]): Double = {
    val targets = extractTargetFields(evaluationResult)

    targets.headOption.flatMap {
      case (_, target) => extractTargetValue(target)
    } getOrElse (throw new JPMMLExtractionException("Target value is null."))

pipeline.scala method extractTargetValue

@throws(classOf[ClassCastException])
  protected def extractTargetValue(target: Any): Option[Double] = target match {
    case s: String => Some(s.toDouble)
    case d: Double => Some(d)
    case _ => None
  }

when I change the target value type to be double in the pmml model I get expected predictions.

Can you check this?

Regards,
Harish.

README.md - Library imports

Good morning.

I write this issue because I've had some trouble getting the library to work. The thing is, in the main README file, there is this piece of code:

// This will be all that you need
import io.radicalbit.flink.pmml.scala._

import org.apache.flink.ml.math.Vector
import org.apache.flink.streaming.api.scala._

object FlinkJpmmlExample {
  def main(args: Array[String]): Unit = {

    // your model can reside in any Flink supported backend
    val pathToPmml = "/even/to/distributed/systems"

    val env = StreamExecutionEnvironment.getExecutionEnvironment
    val events = env.yourInputStream

    //  a lazy reader implementation
    val reader = ModelReader(pathToPmml)

However, I couldn't get this piece of code to work. After searching through the repo, I found that an additional import was required:

import io.radicalbit.flink.pmml.scala.api.reader.ModelReader

Could this import be added to the README example? I know it's already in the examples, but not having it in the main README file could be misleading.

For reference, I tried this on an Ubuntu 18.04 VM, working with Flink 1.9.0 and Scala 2.11.12, compiled with sbt 1.0.

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.