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

Changed Binarizer node to be cast to the type of the predicted label … #4818

Merged
merged 3 commits into from Feb 11, 2020

Conversation

@harishsk
Copy link
Member

harishsk commented Feb 8, 2020

…column's data type

In BinaryClassifierScorer's SaveAsOnnxCore function we were always casting the output of the Binarizer to a bool. But in some cases BinaryClassifierScorer can output a key value (uint) and in this case we should cast the output to a uint. This fix changes the cast to be dependent on the output type of the predicted label.

@harishsk harishsk requested a review from Lynx1820 Feb 8, 2020
@harishsk harishsk requested a review from dotnet/mlnet-core as a code owner Feb 8, 2020
@harishsk harishsk requested a review from ganik Feb 8, 2020
var t = InternalDataKindExtensions.ToInternalDataKind(DataKind.Boolean).ToType();
node.AddAttribute("to", t);
var predictedLabelCol = OutputSchema.GetColumnOrNull(outColumnNames[0]);
node.AddAttribute("to", predictedLabelCol.HasValue ? predictedLabelCol.Value.Type.RawType : typeof(bool));

This comment has been minimized.

Copy link
@yaeldekel

yaeldekel Feb 10, 2020

Member

predictedLabelCol.HasValue [](start = 36, length = 26)

Doesn't it always have a value?
Or, if it doesn't - should we be adding the ONNX node at all? #Resolved

This comment has been minimized.

Copy link
@harishsk

harishsk Feb 10, 2020

Author Member

I have added an Assert to capture that and fixed the next line.


In reply to: 376929923 [](ancestors = 376929923)

@yaeldekel

This comment has been minimized.

Copy link
Member

yaeldekel commented Feb 10, 2020

         */

I know this isn't related to the change in this PR, but is this correct? The binary classifier scorer has a _threshold field, and in the constructor you can specify which column (score/probability) you want to apply the threshold to.

While I could not find a way in the public API to change which column is used (by default it is actually the score column, even if the probability column exists), there is a public API to change the threshold value: ChangeModelThreshold #Resolved


Refers to: src/Microsoft.ML.Data/Scorers/BinaryClassifierScorer.cs:203 in fc1925c. [](commit_id = fc1925c, deletion_comment = False)

@ganik

This comment has been minimized.

Copy link
Member

ganik commented Feb 10, 2020

         */

Yep, this is not correct. Predicted label has to be based off threshold.
ONNX code should mimic what GetPredictedLabelCore(..) does on Line 274


In reply to: 584023200 [](ancestors = 584023200)


Refers to: src/Microsoft.ML.Data/Scorers/BinaryClassifierScorer.cs:203 in fc1925c. [](commit_id = fc1925c, deletion_comment = False)

…ulting baseline changes
@harishsk

This comment has been minimized.

Copy link
Member Author

harishsk commented Feb 10, 2020

         */

You are right! I have fixed it in the next commit.


In reply to: 584286522 [](ancestors = 584286522,584023200)


Refers to: src/Microsoft.ML.Data/Scorers/BinaryClassifierScorer.cs:203 in fc1925c. [](commit_id = fc1925c, deletion_comment = False)

@ganik
ganik approved these changes Feb 11, 2020
…to the probability column
@harishsk harishsk merged commit dc4e5f8 into dotnet:master Feb 11, 2020
17 checks passed
17 checks passed
MachineLearning-CI Build #20200211.1 succeeded
Details
MachineLearning-CI (Centos_x64_NetCoreApp30 Debug_Build) Centos_x64_NetCoreApp30 Debug_Build succeeded
Details
MachineLearning-CI (Centos_x64_NetCoreApp30 Release_Build) Centos_x64_NetCoreApp30 Release_Build succeeded
Details
MachineLearning-CI (MacOS_x64_NetCoreApp21 Debug_Build) MacOS_x64_NetCoreApp21 Debug_Build succeeded
Details
MachineLearning-CI (MacOS_x64_NetCoreApp21 Release_Build) MacOS_x64_NetCoreApp21 Release_Build succeeded
Details
MachineLearning-CI (Ubuntu_x64_NetCoreApp21 Debug_Build) Ubuntu_x64_NetCoreApp21 Debug_Build succeeded
Details
MachineLearning-CI (Ubuntu_x64_NetCoreApp21 Release_Build) Ubuntu_x64_NetCoreApp21 Release_Build succeeded
Details
MachineLearning-CI (Windows_x64_NetCoreApp21 Debug_Build) Windows_x64_NetCoreApp21 Debug_Build succeeded
Details
MachineLearning-CI (Windows_x64_NetCoreApp21 Release_Build) Windows_x64_NetCoreApp21 Release_Build succeeded
Details
MachineLearning-CI (Windows_x64_NetCoreApp30 Debug_Build) Windows_x64_NetCoreApp30 Debug_Build succeeded
Details
MachineLearning-CI (Windows_x64_NetCoreApp30 Release_Build) Windows_x64_NetCoreApp30 Release_Build succeeded
Details
MachineLearning-CI (Windows_x64_NetFx461 Debug_Build) Windows_x64_NetFx461 Debug_Build succeeded
Details
MachineLearning-CI (Windows_x64_NetFx461 Release_Build) Windows_x64_NetFx461 Release_Build succeeded
Details
MachineLearning-CI (Windows_x86_NetCoreApp21 Debug_Build) Windows_x86_NetCoreApp21 Debug_Build succeeded
Details
MachineLearning-CI (Windows_x86_NetCoreApp21 Release_Build) Windows_x86_NetCoreApp21 Release_Build succeeded
Details
WIP Ready for review
Details
license/cla All CLA requirements met.
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

3 participants
You can’t perform that action at this time.