-
Notifications
You must be signed in to change notification settings - Fork 1.9k
PCA Anomaly Detection Threshold #4039
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
Conversation
@@ -267,7 +267,7 @@ public sealed class AnomalyPredictionTransformer<TModel> : SingleFeaturePredicti | |||
|
|||
[BestFriend] | |||
internal AnomalyPredictionTransformer(IHostEnvironment env, TModel model, DataViewSchema inputSchema, string featureColumn, | |||
float threshold = 0f, string thresholdColumn = DefaultColumnNames.Score) | |||
float threshold = 0.5f, string thresholdColumn = DefaultColumnNames.Score) |
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.
float threshold = 0.5f, [](start = 12, length = 23)
Why 0.5? Why not 0.1 or 0.05?
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.
As you point out it is arbitrary. What do you suggest?
/// <param name="model">A trained <see cref="AnomalyPredictionTransformer{TModel}"/>.</param> | ||
/// <param name="threshold">The new threshold value that will be used to determine the label of a data point | ||
/// based on the predicted score by the model.</param> | ||
public AnomalyPredictionTransformer<TModel> ChangeModelThreshold<TModel>(AnomalyPredictionTransformer<TModel> model, float threshold) |
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.
float threshold [](start = 125, length = 15)
I suggest to add the Threshold to option for constructor, like we do for majority of other transformers
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 can also add that to a constructor but that will change the signature of the constructor, so I can only a new one with this additional parameter. Is that what you would like me to do?
Where else are we setting the threshold from the constructor? I don't remember seeing that.
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.
Fixes #3990
In this PR I change the default threshold for PCA anomaly detection to 0.5 (see the issue for discussion on what that means).
I also add a method to change the threshold from MlContext in the same spirit as the BinaryClassification ChangeThreshold method.
I update the samples and add a test for the new method.