Error using cross validation with plsregress

Hi everyone,
I am running a PLS regression and try to perform cross validation (k-fold) with matlab data.
load spectra
X = NIR;
y = octane;
[XL,yl,XS,YS,beta,PCTVAR,MSE] = plsregress(X,y,10,'CV',10);
Unfortunately, this error appear:
Could you explain to me how to solve it please?
Thank you in advance for your help.
Bruno

댓글 수: 4

When I run the example code you shared, it runs smoothly in r2020b.
What release are you using?
You may have a file or function named "crossval" that is shadowing Matlab's crossval() function.
The line in the screenshot that indicates the error in that function contains variable names and commands that are not in the built-in crossval() function, at least not in r2020b. But that could also be explained by using an older release of Matlab.
To list functions with the name crossval,
which crossval -all
Thank you Adam for your kind answer. I've listed crossval function and and indeed, the main function of matlab is hidden by one of a toolbox:
>> which crossval -all
C:\Program Files\MATLAB\R2017a\toolbox\pls_toolbox_862\crossval.m
C:\Program Files\MATLAB\R2017a\toolbox\stats\stats\crossval.m % Shadowed
How can I fix it?
Thanks again,
Bruno
bruno ebel
bruno ebel 2020년 9월 24일
Ok, i've changed the order of the folder in the set up. Thanks again :-)
bruno ebel
bruno ebel 2020년 9월 24일
But errors are still here...

댓글을 달려면 로그인하십시오.

 채택된 답변

Adam Danz
Adam Danz 2020년 9월 24일
편집: Adam Danz 2020년 9월 28일

0 개 추천

Based on the results of
which crossval -all
a function with the same name from a 3rd party toolbox (pls toolbox) is shadowing Matlab's crossval function which is called by plsregress.
If you are not using the pls toolbox, remove it from your Matlab path using
rmpath('C:\Program Files\MATLAB\R2017a\toolbox\pls_toolbox_862')
% or
rmpath([matlabroot, '\toolbox\pls_toolbox_862'])
If you are using the pls toolbox, you can use Julian's answer explained here
It grabs the function handle from Matlab's crossval function and assigns it to a variable that you can use in addition to the crossval version in pls toolbox.

댓글 수: 3

bruno ebel
bruno ebel 2020년 9월 25일
And if i'm using it ?
Adam Danz
Adam Danz 2020년 9월 25일
편집: Adam Danz 2020년 9월 28일
In the past when I faced the same problem I used Julian's answer explained here
I'll update my answer to include this.
bruno ebel
bruno ebel 2020년 9월 29일
ok thank you!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2020년 9월 23일

댓글:

2020년 9월 29일

Community Treasure Hunt

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

Start Hunting!

Translated by