Code Monkey home page Code Monkey logo

Comments (5)

vruusmann avatar vruusmann commented on September 15, 2024

This issue is a functional duplicate of jpmml/jpmml-evaluator#84

In brief, your testing data is not "compatible" with the training data - for some categorical feature(s), the testing data contains category values that were not present in training data. The JPMML-Evaluator library then refuses to score such data records, because the prediction would be non-sensical.

from jpmml-sparkml.

vruusmann avatar vruusmann commented on September 15, 2024

Also, what is your Apache Spark ML version, and how is the StringIndexer transformation configured?

For example, in Apache Spark ML version 2.2 it is possible to specify how invalid values should be handled by setting the StringIndexer@handleInvalid attribute. In this case, the value of this attribute should be set to "keep".

from jpmml-sparkml.

LittileFatNoRun avatar LittileFatNoRun commented on September 15, 2024

I am using Spark ML version 2.2.0
This is my StringIndexer configuration.

def getStringIndexer(columnNames:Array[String]):Array[PipelineStage]={
   var stringIndexers : Array[PipelineStage] = new Array[PipelineStage](0)
    for (i <- 0 until  columnNames.length)
    {
      val indexer = new StringIndexer()
        .setInputCol(columnNames(i))
        .setOutputCol(columnNames(i)+"Indexer")
      stringIndexers = stringIndexers:+indexer
    }
    stringIndexers
  }

from jpmml-sparkml.

vruusmann avatar vruusmann commented on September 15, 2024

This is my StringIndexer configuration.

You're using the default StringIndexer@handleInvalid attribute value, which is "error". Check Apache Spark ML documentation - it is a scoring error (implemented as InvalidResultException in the JPMML-Evaluator library) if the input contains a previously unseen category value.

Please note that the native Apache Spark ML workflow would also fail to make a prediction in this case.

You need to do the following to make unseen categories scorable:

val indexer = new StringIndexer()
  .setInputCol(columnNames(i))
  .setOutputCol(columnNames(i) + "Indexer")
  .setHandleInvalid("keep"); // THIS!

from jpmml-sparkml.

LittileFatNoRun avatar LittileFatNoRun commented on September 15, 2024

Thanks a lot @vruusmann ! That's really helpful. ^O^

from jpmml-sparkml.

Related Issues (20)

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.