jpmml / jpmml-sparkml

Java library and command-line application for converting Apache Spark ML pipelines to PMML
GNU Affero General Public License v3.0
267 stars 80 forks source link

Got an exception while loading pmml with jpmml-evaluator #112

Closed BurrowsWang closed 3 years ago

BurrowsWang commented 3 years ago

Environment:

java=1.8.0
spark=2.4.7
jpmml-sparkml=1.5.12
jpmml-evaluator=1.4.x, 1.5.x

Here is the PMML file I generated with jpmml-sparkml-1.5.12:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PMML xmlns="http://www.dmg.org/PMML-4_4" xmlns:data="http://jpmml.org/jpmml-model/InlineTable" version="4.4">
    <Header>
        <Application name="JPMML-SparkML" version="1.5.12"/>
        <Timestamp>2021-04-27T12:37:19Z</Timestamp>
    </Header>
    <DataDictionary>
        <DataField name="x0" optype="continuous" dataType="double"/>
    </DataDictionary>
    <TransformationDictionary>
        <DerivedField name="bin_x0" optype="categorical" dataType="integer">
            <Discretize field="x0" dataType="integer">
                <DiscretizeBin binValue="0">
                    <Interval closure="closedOpen" rightMargin="-0.616452"/>
                </DiscretizeBin>
                <DiscretizeBin binValue="1">
                    <Interval closure="closedOpen" leftMargin="-0.616452" rightMargin="0.253137"/>
                </DiscretizeBin>
                <DiscretizeBin binValue="2">
                    <Interval closure="closedClosed" leftMargin="0.253137"/>
                </DiscretizeBin>
            </Discretize>
        </DerivedField>
    </TransformationDictionary>
</PMML>

yet when I load this PMML file with jpmml-evaluator, the following Exception raised:

org.jpmml.evaluator.MissingElementException: Required element PMML/<Model>@isScorable=true is not defined
vruusmann commented 3 years ago

Required element PMML/@isScorable=true is not defined

The exception message says it all - you're trying to create a model evaluator using a PMML document that does not contain a model element.

Please re-run your Apache Spark experiment so that the pipeline would contain a model-type estimator.

killua-zyk commented 3 years ago

Yes, it seems the problem of incompatible scala version, when I changed the scala verison from 2.1 to 2.3, it works!