Regression tree and prediction equation
1 回表示 (過去 30 日間)
古いコメントを表示
Suppose i have 3 independent variables A,B and C and dependent variable T. The variable A is discrete and B,C are continuous. The output variable T is also continuous. In such situation we need to create Regression tree. How can we generate prediction equation for such regression tree in MATLAB?
E.g.
A=[ 50 75 100 125 150 175 ];
B=[ 0.45 0.55 0.75 0.8 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1];
C=[3 4 5 6 7 8 9 10 11 12 13 14 15 16 ];
T= [ 1.2 1.8 2.1 2.3 2.5 2.7 2.8 3.1 3.2 3.3];
5 件のコメント
dpb
2022 年 11 月 4 日
A=[ 50 75 100 125 150 175 ];
B=[ 0.45 0.55 0.75 0.8 0.9 1 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1];
C=[3 4 5 6 7 8 9 10 11 12 13 14 15 16 ];
T= [ 1.2 1.8 2.1 2.3 2.5 2.7 2.8 3.1 3.2 3.3];
tABC=array2table([A;B(1:numel(A));C(1:numel(A));T(1:numel(A))].','VariableNames',{'A','B','C','T'})
mdl=fitlm(tABC,'categorical',{'A'})
While it runs, the toy dataset is deficient in that the three independent variables are all almost exact linear combinations of the first so there's only one of the three that is estimable...observe
corrcoef(tABC{:,:})
採用された回答
the cyclist
2022 年 11 月 5 日
This model is probably nonsense, because of the linear dependencies that @dpb points out. But perhaps your real data will yield a useful model. (Note that I transposed all your variables before putting them in a table.)
A = [ 50 75 100 125 150 175 ]';
Acat = categorical(A);
B = [ 0.45 0.55 0.75 0.8 0.9 1]';
C = [3 4 5 6 7 8]';
T= [ 1.2 1.8 2.1 2.3 2.5 2.7]';
tbl = table(Acat,B,C,T);
mdl=fitrtree(tbl,"T ~ Acat + B + C")
2 件のコメント
the cyclist
2022 年 11 月 5 日
The model the way I specified it should do what you want. You can then use that model's predict method to predict T for new values.
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!