in privacy_lint/attack_results.py [0:0]
def balance(self):
"""
Returns AttackResults with balanced scores that hate the same number of
elements by balancing the train and test scores so that they have the same
number of elements by upsampling the smallest set.
"""
scores_train = self.scores_train
scores_test = self.scores_test
n_train = len(scores_train)
n_test = len(scores_test)
delta = n_train - n_test
if delta > 0:
scores_test = AttackResults._upsample(scores_test, delta)
else:
scores_train = AttackResults._upsample(scores_train, -delta)
return AttackResults(scores_train, scores_test)