フィルターのクリア

How to get RMSE, R-squared, and p-values from fitrgp?

17 ビュー (過去 30 日間)
Tobenna Uzuegbunam
Tobenna Uzuegbunam 2022 年 4 月 7 日
回答済み: Anurag 2023 年 10 月 23 日
I have trained a model on a table including dependent variable 'Arm' and 6 independent variables 'duration' + 'heading' + 'speed' + 'cur_speed' + 'tidalrange' + 'Hs', using the code below.
How to get the RMSE, R-squared value, and p-values from the model?
I have tried using 'gprMdl.Rsquared.Ordinary' and 'gprMdl.Rsquared.Adjusted' but it doesn't seem to work
gprMdl = fitrgp(tableTest,'Arms~duration+heading+speed+cur_speed+tidalrange+Hs',...
'KernelFunction','squaredexponential','FitMethod','exact','PredictMethod',...
'exact','Standardize',1)
yPredict = predict(gprMdl,tableTest) % Create model predictions
yActual = tableTest.Arms % Observed data
residuals = yActual - yPredict % Calculate residuals

回答 (1 件)

Anurag
Anurag 2023 年 10 月 23 日
Hi Tobenna,
I understand that being unable to use the inbuilt metrics you want to find a way to calculate RMSE, R-squared and p-values from your code. Refer to the following code for doing the same:
% Calculate RMSE (Root Mean Square Error)
RMSE = sqrt(mean(residuals.^2));
% Calculate R-squared
SSR = sum((yPredict - mean(yActual)).^2); % Regression sum of squares
SST = sum((yActual - mean(yActual)).^2); % Total sum of squares
R2 = SSR / SST;
Lastly, for p-values, you would typically need to use linear regression models or other models that provide statistical tests for variable significance. GPR doesn't inherently provide p-values because it's not a linear regression model.
Hope this helped,
Regards,
Anurag

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by