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

9 visualizaciones (últimos 30 días)
Sanaz J
Sanaz J el 15 de En. de 2016
Respondida: Ali Farmanesh el 25 de Jun. de 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

Respuestas (1)

Ali Farmanesh
Ali Farmanesh el 25 de Jun. de 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

Categorías

Más información sobre Chemistry en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by