spared.metrics.get_r2_score

spared.metrics.get_r2_score(gt_mat: ~torch.Tensor, pred_mat: ~torch.Tensor, mask: ~torch.Tensor, axis=<class 'int'>) Tuple[float, list][source]

This function receives 2 matrices of shapes (n_observations, n_variables) and computes the average R2 score. To do that, it takes the i-th column of each matrix and computes the R2 score between them. It finally returns the average of all the R2 scores 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 R2 score computed by averaging the R2 score for each column in the matrices. detalied_r2_score (list): List of r2 scores for each one of the columns

Return type:

mean_r2_score (float)