Note
This page is a reference documentation. It only explains the function signature, and not how to use it. Please refer to the user guide for the big picture.
nidl.metrics.pearson_r¶
- nidl.metrics.pearson_r(y_true, y_pred, sample_weight=None, multioutput='uniform_average', force_finite=False)[source]¶
Pearson correlation coefficient between 2 arrays y_true, y_pred. This score is symmetric between y_true and y_pred and is always between 1 (perfect correlation) and -1 (perfect anti-correlation).
- Parameters:
- y_true: array-like of shape (n_samples,) or (n_samples, n_outputs)
First input array.
- y_pred: array-like of shape (n_samples,) or (n_samples, n_outputs)
Second input array.
- sample_weightarray-like of shape (n_samples,), default=None
Sample weights for weighted Pearson’s correlation.
- multioutput{‘raw_values’, ‘uniform_average’} or array-like of shape (n_outputs,), optional
Defines aggregating of multiple output scores.
‘raw_values’: Returns a full set of scores in case of multioutput input.
‘uniform_average’: Scores of all outputs are averaged with uniform weight.
array-like: Defines weights used to average scores.
- force_finitebool, default=False
Flag indicating if
NaNand-Infscores resulting from constant data should be replaced with real numbers (1.0if prediction is perfect, i.e. all data are equal ,0.0otherwise). Default isFalsesince Pearson’s correlation is not defined for constant data (zero variance).
- Returns:
- pearson_r: float or array of floats
The correlation score or ndarray of scores if ‘multioutput’ is ‘raw_values’.