Comments (7)
Thanks @sudarshan1413 for your feedback! I will be releasing an updated sklearn2pmml
package later today, so you should be able to export corrected models straight from your Python scripts soon.
As for XGBoost problems, then it must be something else than the data type/precision of split thresholds. XGBoost does all its computations using the float
data type exclusively. The most common cause for R/XGBoost vs. (J)PMML mismatches is that the XGBoost feature map has been generated incorrectly. For example, see jpmml/r2pmml#26
from jpmml-converter.
In Python Tree:
The print-out of Python Tree does not use correct numeric type for representing numeric values. For Python Tree, all values are double
, but they should be either float
or int
(and never double
).
In above case 526225.988222 getting changed in to 526226 ...
Feature "AA.SUB" is an integer value, so 526226
is a correct representation.
... and 5192.53104377 into 5192.5312
Feature "BB.SUB" is a 32-bit floating-point value, so 5192.5312
is a correct representation.
I have analyzed the source code of jpmml-converter and found that the way converting Float values to Double is wrong.( in ValueUtil.java ).
JPMML-Converter does not perform arbitrary data type conversions. If the underlying ML framework uses 32-bit math, then all values are represented in PMML using Float#toString()
.
Can you please analyze and see if this is the issue.
This is not an issue. The JPMML software stack is behaving correctly, the generated PMML document is both syntactically and semantically correct, and when evaluated using the JPMML-Evaluator library (don't know about other PMML engines) gives exactly the same predictions as Scikit-Learn.
from jpmml-converter.
@vruusmann you say "JPMML-Converter does not perform arbitrary data type conversions. If the underlying ML framework uses 32-bit math, then all values are represented in PMML using Float#toString()." but jpmml-sklearn casts tree thresholds to single-precision float here.
from jpmml-converter.
but jpmml-sklearn casts tree thresholds to single-precision float here.
@jnothman But isn't it the case that Scikit-Learn stores threshold values as float64
, but evaluates them as float32
? The X
argument of predict(X)
and predict_proba(X)
methods is explicitly cast into float32
array type, so it would only make sense to compare them against float32
thresholds as well.
The PMML markup holds evaluation-time value representations, so float32
(as implemented by Float#toString()
) is correct (I've got integration tests - with Float#toString()
everything passes cleanly, but with Double#toString()
there is around 1 to 3% bad predictions).
As pointed out in scikit-learn/scikit-learn#9636 (comment), the probable cause for bad predictions in the current case is "pretty formatting of integer-valued floats as integers". Must be the case that 526225.988222
is a special float value, which is declared to be integer-valued by com.google.common.math.DoubleMath#isMathematicalInteger(double)
, but actually isn't so. The problem is that this method gives correct results for Java's double
values, but not for (double)float
values (as returned by Float#doubleValue()
).
Reopening - the pretty formatting code is a bad/premature optimization, and needs to go.
from jpmml-converter.
from jpmml-converter.
@AkshayTilekar, @sudarshan1413 - Can you check out the HEAD
version of the JPMML-SkLearn library, build the executable uber-JAR file, and use it to convert your previously problematic Scikit-Learn pipelines?
Does the commit jpmml/jpmml-sklearn@8c1b208 resolve your problem with mismatching predictions (between Scikit-Learn and (J)PMML) or not?
from jpmml-converter.
Hi vruusmann , thanks a lot for that. It is working fine for us and we were able to match results perfectly with the compiled jar from your HEAD version.
We are facing similar problem with r2pmml also , where we are converting xgboost model to pmml and then trying to match its result with R predictor. Here also we are seeing precision issue similar to that of Python . May be similar issue is happening with r2pmml (jpmml-r) also.... Any thoughts?
from jpmml-converter.
Related Issues (20)
- Can you provide a parameter to control the Separator of output result HOT 3
- Support for transformer-only pipelines HOT 3
- SVM's classificationMethod is always "OneAgainstOne" HOT 3
- Ability to show/hide default attribute values
- Option to choose the carrier data format (XML vs. JSON vs. YAML) in all end user-facing converter tools HOT 2
- Support for transforming labels
- Reusable visitor for (re-)generating score distributions from leaf elements
- PMML version in xmlns tag does not match version tag HOT 1
- Controlling scientific notation in PMML document HOT 2
- Support for `forecast::ets` models
- Version of jpmml-converter correspond to version of spark HOT 1
- Failing to prune XGBoost tree models HOT 3
- Error on a pipeline with OneHotEncoder and xgboost HOT 2
- Streaming conversion mode
- Request Support for 'survival::coxph' models HOT 1
- StackOverflowError HOT 15
- support tensorflow HOT 14
- Support for more complex workflows HOT 1
- Constant elements should require a data type hint
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jpmml-converter.