-
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
Changes from all commits
591d2dd
7c0d757
843f63a
ea62c2f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -703,6 +703,22 @@ public AnomalyDetectionMetrics Evaluate(IDataView data, string labelColumnName = | |
var eval = new AnomalyDetectionEvaluator(Environment, args); | ||
return eval.Evaluate(data, labelColumnName, scoreColumnName, predictedLabelColumnName); | ||
} | ||
|
||
/// <summary> | ||
/// Creates a new <see cref="AnomalyPredictionTransformer{TModel}"/> with the specified <paramref name="threshold"/>. | ||
/// If the provided <paramref name="threshold"/> is the same as the <paramref name="model"/> threshold it simply returns <paramref name="model"/>. | ||
/// Note that by default the threshold is 0.5 and valid scores range from 0 to 1. | ||
/// </summary> | ||
/// <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 commentThe reason will be displayed to describe this comment to others. Learn more.
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 commentThe 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. |
||
where TModel : class | ||
{ | ||
if (model.Threshold == threshold) | ||
return model; | ||
return new AnomalyPredictionTransformer<TModel>(Environment, model.Model, model.TrainSchema, model.FeatureColumnName, threshold, model.ThresholdColumn); | ||
} | ||
} | ||
|
||
/// <summary> | ||
|
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.
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?