-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Fix PFI issue in binary classification #4587
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4587 +/- ##
==========================================
+ Coverage 75.62% 75.64% +0.02%
==========================================
Files 938 938
Lines 168618 168649 +31
Branches 18208 18224 +16
==========================================
+ Hits 127523 127582 +59
+ Misses 36066 36041 -25
+ Partials 5029 5026 -3
|
@@ -171,6 +199,23 @@ public static class PermutationFeatureImportanceExtensions | |||
auprc: a.AreaUnderPrecisionRecallCurve - b.AreaUnderPrecisionRecallCurve); | |||
} | |||
|
|||
private static CalibratedBinaryClassificationMetrics CalibratedBinaryClassifierDelta( | |||
CalibratedBinaryClassificationMetrics a, CalibratedBinaryClassificationMetrics b) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I open this PR in Visual Studio I can see that this new method has 0 references. Is this intended?
Particularly, notice that the BinaryClassifierDelta
(which already existed) gets a reference in the PermutationFeatureImportance<TModel>
method you modified whether isCalibratedModel
is true or not. So I was wondering when/where is the CalibratedBinaryClassifierDelta
method supposed to be called? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have removed it (I added it initially before we decided not to add calibrated metrics to PFI).
In reply to: 359531828 [](ancestors = 359531828)
So based on the ML.NET documentation on PFI, it seems that if you were to take the more time-intensive route of exposing the LogLoss, LogLossReduction, and Entropy metrics, there would be an additional way for users to compare the importance of features (rather than simply R^2)? What's a situation where R^2 would not be sufficient for doing PFI well? |
For the record, R^2 is not included as a metric inside So the PR here would only affect Binary Classification. Currently So, the question remains if it's worth it to make breaking changes in the API to also include LogLoss, LogLossReduction, and Entropy metrics when using PFI with a Binary Classification Calibrated model, by using |
predictionTransformer, | ||
data, | ||
() => new BinaryClassificationMetricsStatistics(), | ||
idv => catalog.EvaluateNonCalibrated(idv, labelColumnName), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small Nit:
The only difference between the if (isCalibratedModel)
and the else case is the idv parameter. Is it possible to make this a bit more readable by factoring out just that line and using a single call to the PermutationFeatureImportance constructor? #Resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolving this comment, since isCalibratedModel
has been removed.
In reply to: 362685943 [](ancestors = 362685943)
@@ -305,6 +305,18 @@ public void TestPfiBinaryClassificationOnSparseFeatures(bool saveModel) | |||
|
|||
Done(); | |||
} | |||
|
|||
[Fact] | |||
public void TestBinaryClassificationWithoutCalibrator() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The test does not Assert anything. Can you please include Asserts for the relevant results that this test is supposed to verify? #Resolved
Breaking the API has a high bar and I think this does not meet that bar. I would suggest leaving it as is or adding a new API that returns the calibrated metrics. |
I will leave it as is for now, and make a change that ensures the existing API doesn't break only in case we get customer asks. In reply to: 570431913 [](ancestors = 570431913) |
|
||
[BestFriend] | ||
internal CalibratedBinaryClassificationMetrics(double auc, double accuracy, double positivePrecision, double positiveRecall, | ||
double negativePrecision, double negativeRecall, double f1Score, double auprc, double logLoss, double logLossReduction, double entropy) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I believe this constructor is no longer used (after you removed the other code handling the calibrated case). Is there a reason the keep this constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In general it LGTM, only I have the question about if we should keep the CalibratedBinaryClassificationMetrics constructor that is added in this PR.
This change adds support for running PFI on binary classification models that do not contain a calibrator. Fixes #4517 .