How to apply the created model using PLSregress on test data?

6 次查看(过去 30 天)
Hi, I am using PLSRegress for 40 spectra with 150 features vs. some chemical data associated with each spectra. I can get the R-square for the regression but I am not able to get the model that is created using my training data. I want to apply the model to my test data to predict the chemical content. Anyone can help me about applying the model on my test data? This is the code I am using for training part: [Xloadings,Yloadings,Xscores,Yscores,betaPLS] = plsregress(X_Train,Y_Train,17,'CV',10);
[n,m] = size(X_Train);
yfitPLS = [ones(n,1) X_Train]*betaPLS;
plot(Y_Train,yfitPLS,'bo');
xlabel('Mg (Ground reference)');
ylabel('Mg (Prediction)');
TSS = sum((Y_Train-mean(Y_Train)).^2);
RSS_PLS = sum((Y_Train-yfitPLS).^2);
rsquaredPLS = 1 - RSS_PLS/TSS
Now I need to apply the created model on my test data which I couldn't figure out how!
Thanks

回答(1 个)

Ali Farmanesh
Ali Farmanesh 2017-6-25
Hello, I think this script maybe can help you.
X=X_test; yval=Y_test; beta=betaPLS (you find this in your model) yvalfit = [ones(size(X,1),1) X]*beta;
TSSVal = sum((yval-mean(yval)).^2); RSSVal = sum((yval-yvalfit).^2); RsquaredVal = 1 - RSSVal/TSSVal

类别

Help CenterFile Exchange 中查找有关 Gaussian Process Regression 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by