def measure(self, example): class_to_supposition_results = self.case_profile_builder.suppose_multiple(example, self.possible_classes) class_to_scores = [(c, len(r.get(example, AddRemovalStore()).added.coverage_set)) for (c, r) in class_to_supposition_results] total = sum((el[1] for el in class_to_scores)) class_to_scores_normalized = [(c, score/total if total > 0 else score) for (c, score) in class_to_scores] mean, std = meanstdv([cov_len for (c, cov_len) in class_to_scores_normalized]) return std
def __calculate_size_deviation_pair(self, example, class_to_supposition_results): class_to_scores = [(c, len(r.get(example, AddRemovalStore()).added.coverage_set)) for (c, r) in class_to_supposition_results] total = sum((el[1] for el in class_to_scores)) mean, std = meanstdv([cov_len for (c, cov_len) in class_to_scores]) return (total, std)
def __init__(self, *args, **kwargs): TotalOp.__init__(self, lambda seq: meanstdv(seq)[1], *args, **kwargs)