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

Added Onnx Export to PlattCalibratorTransformer #4699

Merged
merged 10 commits into from
Jan 27, 2020

Conversation

antoniovs1029
Copy link
Member

@antoniovs1029 antoniovs1029 commented Jan 24, 2020

PlattCalibrator already had a SaveAsOnnx method (link) which was called when saving to Onnx a PlattCalibrator through a CalibratedModelParameter class (such as in here). This would happen when saving a model produced by a calibrated binary classifier.

Besides being part of calibrated binary classifiers, a PlattCalibrator can also be used independently, through a PlattCalibratorTransformer. So in this PR I add the necessary code so to also make it possible to save as Onnx a model that used a PlattCalibratorTransformer.

I added 2 tests where a PlattCalibratorTransformer is added at the end of the model (in one test it's added on top of binary classifiers, in the other test no binary classifiers were used).

I also fixed a bug in the SaveAsOnnx method of PlattCalibrator. For some reason, it was hardcoded to use "-0.0000001f" as the value of the Offset, ignoring the actual offset that the calibrator had. This worked with the existing tests because in them the offset was actually "0", but that isn't always the case, and so in the tests that I am adding the offset is not 0.

@antoniovs1029 antoniovs1029 requested a review from a team as a code owner January 24, 2020 00:33
@antoniovs1029
Copy link
Member Author

By the way, I tried to add more tests using the optional parameters of the PlattCalibratorEstimator, such as scoreColumnName, but it seems that API is broken. I've opened issue #4700 about this. If that issue gets fixed, then it would be a good idea to add more OnnxConversion tests to cover those cases and see if the onnx conversion still works when using "non-default" names.

Copy link
Contributor

@harishsk harishsk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:shipit:

@@ -309,6 +309,40 @@ public void BinaryClassificationTrainersOnnxConversionTest()
Done();
}

[Fact]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This shouldn't be part of your changes. Maybe you did your merge steps wrong?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think I messed up, but it's fixed now

@codecov
Copy link

codecov bot commented Jan 25, 2020

Codecov Report

❗ No coverage uploaded for pull request base (master@9592641). Click here to learn what that means.
The diff coverage is 98.04%.

@@            Coverage Diff            @@
##             master    #4699   +/-   ##
=========================================
  Coverage          ?   75.86%           
=========================================
  Files             ?      951           
  Lines             ?   172526           
  Branches          ?    18629           
=========================================
  Hits              ?   130886           
  Misses            ?    36464           
  Partials          ?     5176
Flag Coverage Δ
#Debug 75.86% <98.04%> (?)
#production 71.44% <96.33%> (?)
#test 90.65% <100%> (?)
Impacted Files Coverage Δ
test/Microsoft.ML.Tests/OnnxConversionTest.cs 97.79% <100%> (ø)
....ML.Tests/Transformers/DateTimeTransformerTests.cs 100% <100%> (ø)
...rc/Microsoft.ML.Featurizers/DateTimeTransformer.cs 88.1% <96.05%> (ø)
src/Microsoft.ML.Mkl.Components/VectorWhitening.cs 81.7% <96.96%> (ø)

@antoniovs1029 antoniovs1029 merged commit 3b69b0d into dotnet:master Jan 27, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Mar 19, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants