Skip to content

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

Merged
merged 4 commits into from
Aug 2, 2019
Merged

PCA Anomaly Detection Threshold #4039

merged 4 commits into from
Aug 2, 2019

Conversation

artidoro
Copy link
Contributor

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.

@artidoro artidoro requested review from codemzs, wschin and ganik July 25, 2019 23:14
@artidoro artidoro self-assigned this Jul 25, 2019
@@ -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)
Copy link
Member

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?

Copy link
Contributor Author

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)
Copy link
Member

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

Copy link
Contributor Author

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.

Copy link
Member

@ganik ganik left a comment

Choose a reason for hiding this comment

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

:shipit:

@artidoro artidoro merged commit bb00e07 into dotnet:master Aug 2, 2019
@ghost ghost locked as resolved and limited conversation to collaborators Mar 21, 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.

PredictedLabel is always true for Anomaly Detection
2 participants