def _multi_target_sk_metric(preds, target, adjusted, multioutput): sk_preds = preds.view(-1, num_targets).numpy() sk_target = target.view(-1, num_targets).numpy() r2_score = sk_r2score(sk_target, sk_preds, multioutput=multioutput) if adjusted != 0: r2_score = 1 - (1 - r2_score) * (sk_preds.shape[0] - 1) / (sk_preds.shape[0] - adjusted - 1) return r2_score
def _multi_target_sk_r2score(preds, target, adjusted=0, multioutput="raw_values"): """Compute R2 score over multiple outputs.""" sk_preds = preds.view(-1, num_targets).numpy() sk_target = target.view(-1, num_targets).numpy() r2_score = sk_r2score(sk_target, sk_preds, multioutput=multioutput) if adjusted != 0: r2_score = 1 - (1 - r2_score) * (sk_preds.shape[0] - 1) / ( sk_preds.shape[0] - adjusted - 1) return r2_score