- 'fitrgp' - https://www.mathworks.com/help/stats/fitrgp.html
- 'predict' - https://www.mathworks.com/help/stats/linearmodel.predict.html
Validate gaussian process regression model with leave-one-out cross validation
    10 visualizaciones (últimos 30 días)
  
       Mostrar comentarios más antiguos
    
Dear all,
I have a dataset with:
X = Torque (the input variable)
Y1 = Response 1
Y2 = Response 2
Y3 = Response 3
I want to use the method of leave-one-out cross-validation (LOOCV) to validate the gaussian process regression model. Then, I want to asses the quality of the model by using the root mean squared error (RMSE) and coefficient of determination (R2). How can I do this?
0 comentarios
Respuestas (1)
  Paras Gupta
      
 el 20 de Mayo de 2024
        
      Editada: Paras Gupta
      
 el 20 de Mayo de 2024
  
      Hi Tessa,
To validate and assess a Gaussian Process Regression (GPR) model using the LOOCV Method, you can iteratively compute the RMSE and R2 values for each of the respone variables. The following code illustrates one way to achieve the same for the response variable 'Y1':
load('dataset.mat');
Y = Y1;
n = length(Y); % Number of observations
predictions = zeros(n, 1); % Preallocate predictions vector
for i = 1:n
    % Indices for the training set (all data points except the ith)
    trainIdx = [1:i-1, i+1:n];
    % Create a Gaussian process regression model
    gprMdl = fitrgp(X(trainIdx, :), Y(trainIdx), 'Basis', 'constant', 'FitMethod', ...
        'exact', 'PredictMethod', 'exact');
    % Predict the left-out observation
    predictions(i) = predict(gprMdl, X(i, :));
end
% Calculate RMSE
rmse = sqrt(mean((Y - predictions).^2));
% Calculate R^2
SStot = sum((Y - mean(Y)).^2);
SSres = sum((Y - predictions).^2);
rSquared = 1 - (SSres / SStot);
fprintf('RMSE: %f\n', rmse);
fprintf('R^2: %f\n', rSquared);
You can refer to the following documentations for more information on the functions used in the code above:
Hope this answers your query.
0 comentarios
Ver también
Categorías
				Más información sobre Gaussian Process Regression en Help Center y File Exchange.
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

