Giter VIP home page Giter VIP logo

Comments (3)

vruusmann avatar vruusmann commented on August 18, 2024

What is the name/version of your PMML producer software? It is producing invalid results and should be replaced with something better.

The LogisticRegression file appears to represent a binary logistic classification model. The target field of a classification model should have a categorical operational type, and provide the list of target category names. So, the DataField element for field Attribute8 should look something like this:

<DataField name="Attribute8" optype="categorical" dataType="string"/>
  <Value value="0"/>
  <Value value="1"/>
</DataField>

Currently, the JPMML-Evaluator is throwing an exception (on line 119 in RegressionModelEvaluator.java), because it doesn't make sense to have a target field with continuous operational type.

Also, the ordering of two RegressionTable elements seems wrong to me. The first RegressionTable element should compute the probability of the event taking place (ie. targetCategory="1"), and the second RegressionTable element should be a constant (ie. targetCategory="0"). You have it exactly backwards. For extended discussion, see the description of the RegressionModel element (search for the phrase "Note that Binary logistic regression is a special case").

The LinearRegression file looks better. Still, the RegressionTable element should not specify the targetCategory attribute, as it is only applicable to classification-type models.

from jpmml-evaluator.

aminaaslam avatar aminaaslam commented on August 18, 2024

Thank you so much for your prompt reply. I am working on Linear Regression Classification problem and my xml is this:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<PMML xmlns="http://www.dmg.org/PMML-4_2">
    <DataDictionary numberOfFields="9">
        <DataField name="Attribute0" optype="continuous" dataType="double"/>
        <DataField name="Attribute1" optype="continuous" dataType="double"/>
        <DataField name="Attribute2" optype="continuous" dataType="double"/>
        <DataField name="Attribute3" optype="continuous" dataType="double"/>
        <DataField name="Attribute4" optype="continuous" dataType="double"/>
        <DataField name="Attribute5" optype="continuous" dataType="double"/>
        <DataField name="Attribute6" optype="continuous" dataType="double"/>
        <DataField name="Attribute7" optype="continuous" dataType="double"/>
        <DataField name="Attribute8" optype="categorical" dataType="double">
            <Value value="0.0"/>
            <Value value="1.0"/>
        </DataField>
    </DataDictionary>
    <RegressionModel functionName="classification" algorithmName="linearRegression">
        <MiningSchema>
            <MiningField name="Attribute0"/>
            <MiningField name="Attribute1"/>
            <MiningField name="Attribute2"/>
            <MiningField name="Attribute3"/>
            <MiningField name="Attribute4"/>
            <MiningField name="Attribute5"/>
            <MiningField name="Attribute6"/>
            <MiningField name="Attribute7"/>
            <MiningField name="Attribute8" usageType="target"/>
        </MiningSchema>
        <RegressionTable intercept="-8.397856251858588" targetCategory="0.0">
            <NumericPredictor name="Attribute0" coefficient="0.1230185712966992"/>
            <NumericPredictor name="Attribute1" coefficient="0.03514316177407176"/>
            <NumericPredictor name="Attribute2" coefficient="-0.013282878621280676"/>
            <NumericPredictor name="Attribute3" coefficient="6.631624570875322E-4"/>
            <NumericPredictor name="Attribute4" coefficient="-0.0011962985482762522"/>
            <NumericPredictor name="Attribute5" coefficient="0.08961636497438935"/>
            <NumericPredictor name="Attribute6" coefficient="0.943894934066085"/>
            <NumericPredictor name="Attribute7" coefficient="0.014842809237409734"/>
        </RegressionTable>

    </RegressionModel>
</PMML>

But it keeps complaining about Invalid Feature Exception. Here is my stack trace. Please guide me as to what is the problem.

org.jpmml.evaluator.InvalidFeatureException: DataField
    at org.jpmml.evaluator.RegressionModelEvaluator.evaluateClassification(RegressionModelEvaluator.java:134)
    at org.jpmml.evaluator.RegressionModelEvaluator.evaluate(RegressionModelEvaluator.java:69)
    at org.jpmml.evaluator.ModelEvaluator.evaluate(ModelEvaluator.java:406)
    at com.norkorm.blake.pmml.LinearRegressionClassificationPMMLTest.makePredictions(LinearRegressionClassificationPMMLTest.java:162)
    at com.norkorm.blake.pmml.LinearRegressionClassificationPMMLTest.testLinearPMML(LinearRegressionClassificationPMMLTest.java:134)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at junit.framework.TestCase.runTest(TestCase.java:176)
    at junit.framework.TestCase.runBare(TestCase.java:141)
    at junit.framework.TestResult$1.protect(TestResult.java:122)
    at junit.framework.TestResult.runProtected(TestResult.java:142)
    at junit.framework.TestResult.run(TestResult.java:125)
    at junit.framework.TestCase.run(TestCase.java:129)
    at junit.framework.TestSuite.runTest(TestSuite.java:255)
    at junit.framework.TestSuite.run(TestSuite.java:250)
    at org.junit.internal.runners.JUnit38ClassRunner.run(JUnit38ClassRunner.java:84)
    at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:86)
    at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:459)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
    at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)

from jpmml-evaluator.

vruusmann avatar vruusmann commented on August 18, 2024

If you open file pmml-evaluator/src/main/java/org/jpmml/evaluator/RegressionModelEvaluator.java and go to line 134, then you will be able to see the description of the "structural problem" that causes this InvalidFeatureException to be thrown.

In this case, it's about mismatch between the number of target category levels (two - "0.0" and "1.0") and the number of RegressionTable elements (one - "0.0"). You can solve this problem by adding an empty RegressionTable element for the second category:

<RegressionTable targetCategory="1.0" intercept="0.0"/>

from jpmml-evaluator.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.