I have got a GAE model trained with data pyg_graph_train.
Then, I use pyg_graph_test for model prediction.
I tried this:
pred, score = model.predict( pyg_graph_test, label = pyg_graph_test.label, return_score=True )
And I got "Recall 0.7490 | Precision 0.7490 | AP 0.6226 | F1 0.7490"
But when I check the pred and score:
f1_score(y_true=pyg_graph_test.label, y_pred=pred)
I got 0.34680888045878483, which is inconsistent.
I found that the returned pred from the predict function is not the same as that in the logger function (pygod.utls.utility), because of different threshold values.
In the logger function:
contamination = sum(target) / len(target)
threshold = np.percentile(score, 100 * (1 - contamination))
pred = (score > threshold).long()
In contrast, in the predict function (pygod.detector.base):
if return_pred:
pred = (score > self.threshold_).long()
The "self.threshold_" is determined in _process_decision_score as:
self.threshold_ = np.percentile(self.decision_score_, 100 * (1 - self.contamination))
So, which prediction (i.e. which threshold value) is correct? Or is there something I may have missed/overlooked instead?
I have got a GAE model trained with data pyg_graph_train.
Then, I use pyg_graph_test for model prediction.
I tried this:
pred, score = model.predict( pyg_graph_test, label = pyg_graph_test.label, return_score=True )And I got "Recall 0.7490 | Precision 0.7490 | AP 0.6226 | F1 0.7490"
But when I check the pred and score:
f1_score(y_true=pyg_graph_test.label, y_pred=pred)I got 0.34680888045878483, which is inconsistent.
I found that the returned pred from the predict function is not the same as that in the logger function (pygod.utls.utility), because of different threshold values.
In the logger function:
contamination = sum(target) / len(target)threshold = np.percentile(score, 100 * (1 - contamination))pred = (score > threshold).long()In contrast, in the predict function (pygod.detector.base):
if return_pred:pred = (score > self.threshold_).long()The "self.threshold_" is determined in _process_decision_score as:
self.threshold_ = np.percentile(self.decision_score_, 100 * (1 - self.contamination))So, which prediction (i.e. which threshold value) is correct? Or is there something I may have missed/overlooked instead?