[docs]@staticmethoddefscore_for_metric(metric:ClassificationMetric,predicted_y,predicted_proba_y,true_y,classes):""" Note: when providing label classes, make sure the 'positive class' is sorted last. This sorting should be done automatically when accessing Label.values """fn=MetricUtil.get_metric_fn(metric)true_y,predicted_y=Util.binarize_label_classes(true_y=true_y,predicted_y=predicted_y,classes=classes)try:ifmetricinClassificationMetric.get_probability_based_metric_types():predictions=predicted_proba_yifpredicted_proba_yisNone:warnings.warn(f"MLMethodAssessment: metric {metric} is specified, but the chosen ML method does not output "f"class probabilities. Using predicted classes instead...")predictions=predicted_yelse:predictions=predicted_yif'labels'ininspect.getfullargspec(fn).kwonlyargsor'labels'ininspect.getfullargspec(fn).args:score=fn(true_y,predictions,labels=classes)else:score=fn(true_y,predictions)exceptValueErroraserr:warnings.warn(f"MLMethodAssessment: score for metric {metric.name} could not be calculated."f"\nPredicted values: {predicted_y}\nTrue values: {true_y}.\nMore details: {err}",RuntimeWarning)score=Constants.NOT_COMPUTEDreturnscore