Yapay sinir aglari ile satis tahmini problemi cozdugumde R2 degerinin negatif cikmasi ne ifade ediyor. R2 degeri hangi aralikta olmalidir?

1 view (last 30 days)
  5 Comments
John D'Errico
John D'Errico on 17 Dec 2022
Walter is correct. A negative R^2 is a typical symptom of a model that lacks a constant term, but in fact, it could really use a constant term. Essentially it tells you that your model predicts more poorly than just using a constant predictor for your model.
the cyclist
the cyclist on 17 Dec 2022
A minor correction for posterity:
It's not that negative R^2 indicates that the model is worse than random in predicting the data. It's worse than using the mean response as the prediction for all observations. This is the "horizontal line" mentioned in the documentation that @Walter Roberson quoted.
The reason the mean is relevant is that it is the baseline from which the "total sum of squares" of the data is calculated, which in turn enters into the calculation of R^2.

Sign in to comment.

Answers (1)

John D'Errico
John D'Errico on 19 Jan 2023
Let me give an example.
x = rand(100,1);
y = 5 - 3*x + randn(size(x));
plot(x,y,'o')
First, fit a LINEAR polynomial model to the data.
[mdl,gof] = fit(x,y,'poly1')
mdl =
Linear model Poly1: mdl(x) = p1*x + p2 Coefficients (with 95% confidence bounds): p1 = -2.891 (-3.556, -2.227) p2 = 4.757 (4.359, 5.155)
gof = struct with fields:
sse: 88.4065 rsquare: 0.4319 dfe: 98 adjrsquare: 0.4261 rmse: 0.9498
So this model has an r^2 value of 0.4319. Compare that to a model that completely lacks a constant term.
ft = fittype('a*x','indep','x');
[mdlnocon,gofnocon] = fit(x,y,ft)
Warning: Start point not provided, choosing random start point.
mdlnocon =
General model: mdlnocon(x) = a*x Coefficients (with 95% confidence bounds): a = 4.108 (3.295, 4.922)
gofnocon = struct with fields:
sse: 596.3427 rsquare: -2.8321 dfe: 99 adjrsquare: -2.8321 rmse: 2.4543
Here the R^2 is a strange looking -2.8. And yes, R^2 is always supposed to be between 0 and 1. But what you need to understand is that ONLY applies when you have a constant term in your model. Otherwise, R^2 is complete gibberish for a model with no constant term.

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!