spared.metrics.get_pearsonr
- spared.metrics.get_pearsonr(gt_mat: Tensor, pred_mat: Tensor, mask: Tensor, axis: int) Tuple[float, list][source]
This function receives 2 matrices of shapes (n_observations, n_variables) and computes the average Pearson correlation. To do that, it takes the i-th column of each matrix and computes the Pearson correlation between them. It finally returns the average of all the Pearson correlations computed.
- Parameters:
gt_mat (torch.Tensor) – Ground truth matrix of shape (n_observations, n_variables).
pred_mat (torch.Tensor) – Predicted matrix of shape (n_observations, n_variables).
mask (torch.Tensor) – Boolean mask with False in positions that must be ignored in metric computation (n_observations, n_variables).
axis (int) – wether to compute the pcc by columns (axis=0) ir by rows (axis=1)
- Returns:
Mean Pearson correlation computed by averaging the Pearson correlation for each patch. detalied_pcc (list): List of pcc for each one of the columns
- Return type:
mean_pcc (float)