flink-jpmml icon indicating copy to clipboard operation
flink-jpmml copied to clipboard

Integer Type Target value not supported

Open Harish-Sridhar opened this issue 5 years ago • 1 comments

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.

Harish-Sridhar avatar Mar 07 '19 13:03 Harish-Sridhar

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

spi-x-i avatar Mar 14 '19 16:03 spi-x-i