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)
Show older comments
5 Comments
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
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.
Answers (1)
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')
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)
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.
0 Comments
See Also
Categories
Find more on Regression in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!