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

10 Ansichten (letzte 30 Tage)
Sanaz J
Sanaz J am 15 Jan. 2016
Beantwortet: Ali Farmanesh am 25 Jun. 2017
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

Antworten (1)

Ali Farmanesh
Ali Farmanesh am 25 Jun. 2017
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

Kategorien

Mehr zu Chemistry finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by