I am using scikit-learn r2_score function and I would like to understand what the option 'variance_weighted' calculates. In the documentation page it tells: Scores of all outputs are averaged, weighted by the variances of each individual output. Does it mean that the output is a weighted average whose weights are the variances of data of which score has to be calculated ?
>>> y_true = [[0.5, 1], [-1, 1], [7, -6]] >>> y_pred = [[0, 2], [-1, 2], [8, -5]] >>> r2_score(y_true, y_pred, multioutput='variance_weighted')
Here the variance for the first individual output means the variance of [0.5, 1, 0, 2] ?
Thanks in advance.
EDIT: the question has been answered from a computational point of view here in StackOverflow. So it calculates the r2 score between each element corresponding to each axis, so in this case between [0.5,-1,7] and [0,-1,8], [1,1,-6] and [2,2,-5] and the variances, that represent the weights I was looking for, are the variances corresponding to the true values and so the variance of [0.5,-1,7] and of [1,1,-6].
At this point my doubt is: why do they weigh the r2 scores results using the variance of true values ? In this way, a higher variance in true values would lead to a higher importance of the r2 score value computed between such true values and the corresponding predicted values...