def pearson(y_true, y_pred):
"""
Calculate Pearson product-moment correlation coefficient between ``y_true``
and ``y_pred``.
:param y_true: The true/actual/gold labels for the data.
:type y_true: array-like of float
:param y_pred: The predicted/observed labels for the data.
:type y_pred: array-like of float
:returns: Pearson product-moment correlation coefficient if well-defined,
else 0
"""
ret_score = pearsonr(y_true, y_pred)[0]
return ret_score if not np.isnan(ret_score) else 0.0
评论列表
文章目录