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

조회 수: 3 (최근 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 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