how to get AUROC of isolation forest #28556
Unanswered
rimannseye
asked this question in
Q&A
Replies: 1 comment
-
Hi @rimannseye, the positive class is abnormal (1), your trained model will aim at yielding a higher score for the anomalies and a lower score for the normal samples. Hence, the first method is the correct one. Otherwise, you'd be flipping the labels, and get a wrong AUC. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi team, could you help me with the following isolation forest question?
If X_train is the train data set, and y_train is the corresponding label, where 0 is normal and 1 is abnormal, after running the below code:
if_mdl = IsolationForest(**default_params)
if_mdl.fit(X_train)
score = -if_mdl.score_samples(X_train)
Which method is the right way to calculate AUROC:
method 1:
auc = roc_auc_score(y_train, score)
method 2:
y_train_update = [1 if label == 0 else 1 for label in y_train]
auc = roc_auc_score(y_train_update, score)
Beta Was this translation helpful? Give feedback.
All reactions