Skip to content

Integer Type Target value not supported #63

@Harish-Sridhar

Description

@Harish-Sridhar

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.

Metadata

Metadata

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions