フィルターのクリア

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

15 ビュー (過去 30 日間)
Janet Reimer
Janet Reimer 2014 年 6 月 9 日
コメント済み: the cyclist 2014 年 6 月 9 日
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.

採用された回答

the cyclist
the cyclist 2014 年 6 月 9 日
編集済み: the cyclist 2014 年 6 月 9 日
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 件のコメント
Janet Reimer
Janet Reimer 2014 年 6 月 9 日
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 2014 年 6 月 9 日
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)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTime Series についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by