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

14 ビュー (過去 30 日間)
Sanaz J
Sanaz J 2016 年 1 月 15 日
回答済み: Ali Farmanesh 2017 年 6 月 25 日
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 Center および File ExchangeGaussian Process Regression についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by