Filter löschen
Filter löschen

How can I determine the r-squared value for regression trees?

15 Ansichten (letzte 30 Tage)
I am using regression trees and I know that there is a way to determine an R^2 value for the tree, but I am not sure how to do it. I am using the function RegressionTree.fit with Matlab 2013a, but just downloaded 2014a on another computer. So I could use either version.

Akzeptierte Antwort

the cyclist
the cyclist am 9 Jun. 2014
Bearbeitet: the cyclist am 9 Jun. 2014
I don't think this is an output property of the model, but it is easy to calculate. Here is an example based on the one in the documentation for RegressionTree.fit:
load carsmall
tree = RegressionTree.fit([Weight, Cylinders],MPG,'MinParent',20,'PredictorNames',{'W','C'})
mpg_predicted = predict(tree,[Weight,Cylinders]);
RMSE = sqrt(nanmean((mpg_predicted-MPG).^2))
RMSE0 = nanstd(MPG-nanmean(MPG));
r_sq = 1 - (RMSE/RMSE0)
I would double-check all that, but you should be in the right direction.
  2 Kommentare
Janet Reimer
Janet Reimer am 9 Jun. 2014
I do not have a value that I would use as the MPG in this example. I have a 15,000 x 3 matrix of predictors and a vector for the response. so tree = RegressionTree.fit(X,y). How do I deal with the extra variable in the example?
the cyclist
the cyclist am 9 Jun. 2014
You might want to look at the example I mentioned. In that case, MPG is the response variable. So, I think in your case you are going to do
y_predicted = predict(tree,X);
RMSE = sqrt(nanmean((y_predicted-y).^2))
RMSE0 = nanstd(y-nanmean(y));
r_sq = 1 - (RMSE/RMSE0)

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Time Series finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by