treder / MVPA-Light

Matlab toolbox for classification and regression of multi-dimensional data
MIT License
70 stars 35 forks source link

Error in example2_crossvalidate.m #21

Closed Sanjeevnara closed 3 years ago

Sanjeevnara commented 3 years ago

Hi Mathhias,

I came back to test the examples after long time. He is bug appearing in example2.


Repetition #1. Fold 1 Error using .* Matrix dimensions must agree.

Error in train_logreg (line 332) sumyxN = sum(param.weights .* YX)'/N;

Error in mv_crossvalidate (line 114) cf= train_fun(cfg.hyperparameter, Xtrain, trainlabel);

Error in example2_crossvalidate (line 47) [acc_LR, result_LR] = mv_crossvalidate(cfg_LR, X, clabel);


I am using 2020 version of your code with MATLAB 2014B. May i request you to have a lok at it.

Thanks

treder commented 3 years ago

Hi Sanjeev, does the problem persist when you use mv_classify instead of mv_crossvalidate?

I'm phasing out mv_crossvalidate (and will remove it from the toolbox some time in the future) because all its functionality is contained within mv_classify. On a similar note, a new set of examples will soon be released (and mv_crossvalidate will not appear in the examples any more).

Sanjeevnara commented 3 years ago

Hi Matthias

Happy New Year :)

I think the issue is not with mv_crossvalidate. The issue is with Logistic Regression classifier. I run example3_classify_across_time.m . In this example as well the LDA classifier (Line 31) runs perfectly fine however the Logistic Regression classifier (Line 32) pops up the same error. Here is the error for example 3.


Repetition #1. Fold 1 Error using .* Matrix dimensions must agree.

Error in train_logreg (line 332) sumyxN = sum(param.weights .* YX)'/N;

Error in mv_classify_across_time (line 132) cf= train_fun(cfg.hyperparameter, Xtrain_tt, trainlabel);

Error in example3_classify_across_time (line 32) [acc_LR, result_LR] = mv_classify_across_time(cfg_LR, dat.trial, clabel);


May i ask when are you planning to release the new examples.

Thanks

treder commented 3 years ago

Happy New Year Sanjeev. I cannot replicate the error you report (it works fine on my computer). Can you pull the latest version of the toolbox and try again? If the problem persists, can you try a different Matlab version? I'm trying to narrow down the issue.

Btw I just pushed a new set of examples.

Sanjeevnara commented 3 years ago

HI Matthias, I tried with Matlab 2012B , it also shows the same error. Below is the error :

Repetition #1. Fold 1 Error using .* Matrix dimensions must agree.

Error in train_logreg (line 332) sumyxN = sum(param.weights .* YX)'/N;

Error in mv_classify (line 389) cf= train_fun(cfg.hyperparameter, X_ix, trainlabel);

Error in getting_started_with_classification (line 205) perf = mv_classify(cfg, X, clabel);

Thanks

Best regards Sanjeev

treder commented 3 years ago

What happens if you change the classifier, the function (eg mv_classy_across_time instead of mv_classify), or change the dataset?

treder commented 3 years ago

Any news on this issue?

Sanjeevnara commented 3 years ago

Hi Matthias,

Apologies for the delay.

If i change the function, mv_crossvalidate with mv_classify, the error remains the same. When i change the classifier to lda from logreg, it works fine with both mv_crossvalidate and mv_classify. I have tried this with both Matlab 2012B and 2014B. Both the versions fail to run logreg as a classifier in any function.

I found a trick to use libsvm in both the version by running the "make" script before using any function. So its only logreg which is not working.

Thanks

treder commented 3 years ago

It appears like the error was a broadcasting problem in some Matlab versions, I now broadcast explicitly using bsxfun. Can you update and try again?

Sanjeev-nara commented 3 years ago

Hey matthias, I just tried to use the logistic regression classifier with Matlab 2014b version and it computed without any error. I think the bug is resolved with using bsxfun.

Thanks

Best regards Sanjeev

treder commented 3 years ago

Great, glad it's resolved - with this I will close the call.