Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integer Type Target value not supported #63

Open
Harish-Sridhar opened this issue Mar 7, 2019 · 1 comment
Open

Integer Type Target value not supported #63

Harish-Sridhar opened this issue Mar 7, 2019 · 1 comment

Comments

@Harish-Sridhar
Copy link

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.

@spi-x-i
Copy link
Collaborator

spi-x-i commented Mar 14, 2019

Hi @Harish-Sridhar,

yes, we should support also integers and additional output types. For instance, we can add also Float and Long. @francescofrontera can provide a solution within one week. If you want to provide a solution before you're more than welcome!

Thank you, Andrea

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants