# how can i plot R2(regression line) between target and prediction

38 ビュー (過去 30 日間)
NN 2021 年 6 月 20 日

Please explain how can i plot R2 as regression line between target and prediction in matlab
Can some one please share the code ?
i am attaching a sample graph.

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

### 回答 (2 件)

Divija Aleti 2021 年 6 月 24 日
Hi,
Firstly, as R2 is a scalar, it cannot be plotted.
To plot the regression line, follow the example shown in the link below:
However, to get a similar output as shown in the above graph, you will have to make changes in the example. Refer to the sample code given below which is an extension of the example given in the link.
[x,t] = simplefit_dataset;
net = feedforwardnet(10);
net = train(net,x,t);
y = net(x);
plotregression(y,t,'Regression') % Reversed the order of t and y, as we want Target on the y-axis and Prediction on the x-axis
% Customization of title, x-label and y-label
a=gca;
title(a,'Test Data, R^2=0.9893')
xlabel(a,'Prediction')
ylabel(a,'Target')
Output:
For calculating the value of R-squared(R2), which is given as the title of the graph, have a look at the following links:
Hope this helps!
Regards,
Divija
##### 0 件のコメント-2 件の古いコメントを表示-2 件の古いコメントを非表示

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

pathakunta 2024 年 1 月 26 日
Firstly, as R2 is a scalar, it cannot be plotted. To plot the regression line, follow the example shown in the link below: plotregression However, to get a similar output as shown in the above graph, you will have to make changes in the example. Refer to the sample code given below which is an extension of the example given in the link. [x,t] = simplefit_dataset; net = feedforwardnet(10); net = train(net,x,t); y = net(x); plotregression(y,t,'Regression') % Reversed the order of t and y, as we want Target on the y-axis and Prediction on the x-axis % Customization of title, x-label and y-label a=gca; title(a,'Test Data, R^2=0.9893') xlabel(a,'Prediction') ylabel(a,'Target') Output:
For calculating the value of R-squared(R2), which is given as the title of the graph, have a look at the following links: Linear Regression Coefficient of Determination (R-Squared) Hope this helps!

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

### カテゴリ

Help Center および File ExchangePattern Recognition についてさらに検索

### Community Treasure Hunt

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

Start Hunting!

Translated by