Code Monkey home page Code Monkey logo

Comments (7)

vruusmann avatar vruusmann commented on May 14, 2024

As the exception shows, the failing construct is the Apply element on lines 21 -- 24:

<Apply function="equal">
	<FieldRef field="raw_result"/>
	<Constant dataType="string">noRuleFound</Constant> 
</Apply>

According to the PMML specification, the "equal" built-in function takes two arguments, which have to be both non-null. In your case, one (or both) of the arguments is null.

Most likely, the missing argument is <FieldRef field="raw_result">, which references the prediction of the rule set model. This model is very naive, and it's easy to see that it will return a null prediction every time when the value of the value input field is something other than 0.

In conclusion, the scoring will succeed if you pass value=0 as input, and fail otherwise. The Openscoring REST service is working properly.

from openscoring.

jverre avatar jverre commented on May 14, 2024

Given that I have provided a default score, shouldn't the raw_result field (which is the predicted field) never be null ?

from openscoring.

vruusmann avatar vruusmann commented on May 14, 2024

The contents of the "result" output field, expressed as Java code:

if(raw_result.equals("noRuleFound")){
  return default_value;
} else {
  return raw_result;
}

It can be seen that the "if" condition has to execute successfully (and produce a true value) before the default_value could be selected. You have a situation where the "if" condition fails (by throwing a NullPointerException).

from openscoring.

vruusmann avatar vruusmann commented on May 14, 2024

As a workaround, you can check the "missingness" state of the raw_result field:

<Apply function="if">
	<Apply function="or">
		<Apply function="isMissing">
			<FieldRef field="raw_result"/>
		</Apply>
		<Apply function="equal">
			<FieldRef field="raw_result"/>
			<Constant>noRuleFound</Constant>
		</Apply>
	</Apply>
</Apply>

from openscoring.

jverre avatar jverre commented on May 14, 2024

Thanks for the help !
I gave the two workarounds a try but they didn't actually solve my issue unfortunately.

The issue I have is that the code:

  • Will run on machine 1 but not machine 2 if I use:
         <OutputField name="ruleId" optype="continuous" dataType="double" feature="entityId"/> 
          <OutputField name="result" feature = "transformedValue">
            <Apply function="if">
              <Apply function="equal">
                <FieldRef field="raw_result"/>
                <Constant dataType="string">noRuleFound</Constant> 
              </Apply>
              <FieldRef field="default_value"/>
              <FieldRef field="raw_result"/>  
            </Apply>
          </OutputField>
        </Output>
  • Will run on machine 2 but not machine 1 if I use:
         <OutputField name="raw_result" optype="categorical" dataType="string" feature="predictedValue"/> 
         <OutputField name="ruleId" optype="continuous" dataType="double" feature="entityId"/> 
         <OutputField name="result" feature = "transformedValue">
            <Apply function="if">
              <Apply function="equal">
                <FieldRef field="raw_result"/>
                <Constant dataType="string">noRuleFound</Constant> 
              </Apply>
              <FieldRef field="default_value"/>
              <FieldRef field="raw_result"/>  
            </Apply>
          </OutputField>
        </Output>

Both machines use the same version of openscoring.

from openscoring.

vruusmann avatar vruusmann commented on May 14, 2024

Both machines use the same version of openscoring.

Are you absolutely positively sure about that?

The difference between two code examples is this:

<OutputField name="raw_result" optype="categorical" dataType="string" feature="predictedValue"/> 

Newer versions of openscoring (1.3.X) will fail if the prediction hasn't been imported into output scope using a specialized output field (<OutputField feature="predictedValue"/>), whereas older version (1.2.X) silently work around it.

Therefore, it must be the case that you use older version on machine 1, and newer version on machine 2. Whatever the case, please upgrade to the latest version of openscoring on both machines to remove all doubt.

from openscoring.

jverre avatar jverre commented on May 14, 2024

Thanks, this must be the reason. I will investigate tomorrow morning.

Thanks again for all the support !

from openscoring.

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.