in privacy_lint/attack_results.py [0:0]
def get_accuracy(self, threshold: float) -> float:
"""
Given the maximum accuracy threshold, computes the accuracy of the attack.
"""
n_samples = self.scores_train.shape[0] + self.scores_test.shape[0]
n_true_positives = (self.scores_train > threshold).sum().float()
n_true_negatives = (self.scores_test <= threshold).sum().float()
accuracy = (n_true_positives + n_true_negatives) / n_samples
return accuracy