How to calculate the coefficient of determination R^2 of a Neural Network?
조회 수: 47(최근 30일)
I want to calculate the coefficient of determination R^2 of a Neural Network by myself.
This is the Regression plot that Neural Network Training Tool:
but I want to calculate it in a way so I can "confirm" what I see on NN Training Tool.
As you can see below I have plot the Target (X) and the Prediction (Y) as Y = A*X
but the Regression Plot is way different, Prediction (Y) = 0.99*Target+0.0044 as Y=A*X+B
I understand that Weights and Biases are A and B respectively, but how can I find it and do it by myself, since they are Weights on Input Layer and Hidden Layer as well.
Also how can I draw the line that represents the middle of my data points?
title('Coefficient of Determination R^2');
the cyclist 2022년 12월 4일
The formula is in the documentation here (for fitlm).It is not always the best goodness-of-fit measure for all models, but you should always be able to calculate it like this:
% Some pretend predicted and actual Y values
y_actual = [2.1; 3.2; 5.3; 7.1; 11.9];
y_predicted = [2.9; 2.7; 5.0; 7.2; 11.1];
% Plot them
% Sum of squared residuals
SSR = sum((y_predicted - y_actual).^2);
% Total sum of squares
TSS = sum(((y_actual - mean(y_actual)).^2));
% R squared
Rsquared = 1 - SSR/TSS