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

Facing Typed check exception org.jpmml.evaluator.TypeCheckException: Expected FLOAT, but got DOUBLE (3.4) #48

Closed
Purvihana opened this issue Mar 3, 2017 · 1 comment
Labels

Comments

@Purvihana
Copy link

Purvihana commented Mar 3, 2017

While trying to read the pmml file created using sklearn2pmml using jpmml evaluator for prediction facing this error:

org.jpmml.evaluator.TypeCheckException: Expected FLOAT, but got DOUBLE (3.4)
	at org.jpmml.evaluator.TypeUtil.toFloat(TypeUtil.java:419)
	at org.jpmml.evaluator.TypeUtil.cast(TypeUtil.java:333)

I am using the version 1.3.5 of the evaluator. PFB the mapper used while creating the pmml file no transformation was specified

iris_pipeline = PMMLPipeline([
  ("mapper", DataFrameMapper([
    (["Sepal.Length", "Sepal.Width", "Petal.Length", "Petal.Width"], [ContinuousDomain(), Imputer()])
  ])),
  ("classifier", RandomForestClassifier(n_estimators = 100))
])
@vruusmann
Copy link
Member

There's something wrong with your environment (outdated sklearn2pmml package?). Or you have manually modified the PMML file, thereby making it invalid.

I executed your Python script, converted the fitted pipeline to PMML (using JPMML-SkLearn version 1.2.10), and scored the Iris dataset (using JPMML-Evaluator version 1.3.5). The scoring was successful, there were no exceptions being thrown.

If you open a random forest classifier's PMML file in text editor, then it's possible to see that it's fully type safe:

First, input fields are of double data type:

<DataDictionary>
	<DataField name="Sepal.Length" optype="continuous" dataType="double">
		<Interval closure="closedClosed" leftMargin="4.3" rightMargin="7.9"/>
	</DataField>
</DataDictionary>

Second, input fields are cast from double to float data type:

<TransformationDictionary>
	<DerivedField name="float(Sepal.Length)" optype="continuous" dataType="float">
		<FieldRef field="Sepal.Length"/>
	</DerivedField>
</TransformationDictionary>

Finally, the random forest model accesses derived float values:

<Node id="11" score="virginica" recordCount="3.0">
	<SimplePredicate field="float(Sepal.Length)" operator="lessOrEqual" value="6.2"/>
	<ScoreDistribution value="setosa" recordCount="0.0"/>
	<ScoreDistribution value="versicolor" recordCount="0.0"/>
	<ScoreDistribution value="virginica" recordCount="3.0"/>
</Node>

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

No branches or pull requests

2 participants