treder / MVPA-Light

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

mv_classify_timextime_two_datasets not found and lda_classifier error #1

Closed fmeconiATuob closed 7 years ago

fmeconiATuob commented 7 years ago

Hi Matthias,

I would like also to use the function mv_classify_timextime_two_datasets as you mention in the documentation that should be appropriate for my case but I could not find this function anywhere.

So I have tried to use lda_classifier with two datasets: train_dataset = trials_train x channels matrix test_dataset = trials_test x channels matrix The number of trials of the two matrices is different. I use the function in this way: [label, dval, post] = lda_classifier(train_dataset, labels, test_dataset, 'auto').

I am performing also a cross validation and everything is done per each data point of the training and of the testing dataset.

I get this error:

In train_lda (line 56) In lda_classifier (line 39) Warning: Rank deficient, rank = 0, tol = 0.000000e+00. Error using NaN Input following 'like' is not a single or double array.

Error in cov (line 136) c = NaN(n,'like', x);

Error in train_lda (line 56) mu2= mean(X(idx2,:))';

Error in lda_classifier (line 39) cf = train_lda(struct('gamma',gamma),Xtrain,labels);

Do you have any suggestions on how to fix it?

Thanks in advance for your help,

Federica

treder commented 7 years ago

Hi Federica,

Yes indeed, this function is still missing. In fact, I wanted to extend mv_classify_timextime to work with two datasets as well. Maybe I manage tonight, I will let you know.

Please don't use the lda_classifier function, use train_lda and test_lda instead (I'm removing the function now).

Also I changed the class labels into 1 for class 1, and 2 for class 2 (it was 1 and -1 before). This is because it's more intuitive and in the future it's easier to extend it to multiclass.

For now, can you try code in the example "Training and testing by hand" (inserting your training and test data there). If you need a time x time matrix you need to do it by hand for now using two for loops. You need to do a GIT PULL first since I changed the code quite a bit!

Let me know if it works !

Best, Matthias

2017-09-05 11:34 GMT+01:00 fmeconiATuob notifications@github.com:

Hi Matthias,

I would like also to use the function mv_classify_timextime_two_datasets as you mention in the documentation that should be appropriate for my case but I could not find this function anywhere.

So I have tried to use lda_classifier with two datasets: train_dataset = trials_train x channels matrix test_dataset = trials_test x channels matrix The number of trials of the two matrices is different. I use the function in this way: [label, dval, post] = lda_classifier(train_dataset, labels, test_dataset, 'auto').

I am performing also a cross validation and everything is done per each data point of the training and of the testing dataset.

I get this error:

In train_lda (line 56) In lda_classifier (line 39) Warning: Rank deficient, rank = 0, tol = 0.000000e+00. Error using NaN Input following 'like' is not a single or double array.

Error in cov (line 136) c = NaN(n,'like', x);

Error in train_lda (line 56) mu2= mean(X(idx2,:))';

Error in lda_classifier (line 39) cf = train_lda(struct('gamma',gamma),Xtrain,labels);

Do you have any suggestions on how to fix it?

Thanks in advance for your help,

Federica

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/treder/MVPA-Light/issues/1, or mute the thread https://github.com/notifications/unsubscribe-auth/AGveSC8VGbeuP3ZIeRHcBjipMQqzd3Gqks5sfSO7gaJpZM4PMwRx .

-- Matthias Treder PhD Cognitive Psychology BSc Mathematics

School of Psychology University of Birmingham Edgbaston Park Rd Birmingham B15 2TT

fmeconiATuob commented 7 years ago

Hi Matthias, thank you very much for you help!

I have followed your suggestion and did the training-test by hand at each time point with two for loops. I have done that on several subsets of trials for the trainng and test it on several subsets of testing trials. I then used the function you have updated and got very very similar results! Is the cross validation not needed because the datasets for training and testing are different?

Thank you very much, bests,

Federica

treder commented 7 years ago

Hi Federica,

I'm happy it worked out. Yes you got it right, I'm assuming that the two datasets are independent, so you don't need cross-validation.

Best, Matthias

2017-09-06 13:45 GMT+01:00 fmeconiATuob notifications@github.com:

Hi Matthias, thank you very much for you help!

I have followed your suggestion and did the training-test by hand at each time point with two for loops. I have done that on several subsets of trials for the trainng and test it on several subsets of testing trials. I then used the function you have updated and got very very similar results! Is the cross validation not needed because the datasets for training and testing are different?

Thank you very much, bests,

Federica

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/treder/MVPA-Light/issues/1#issuecomment-327471788, or mute the thread https://github.com/notifications/unsubscribe-auth/AGveSJixRuDTd-k20o63q7W_6goZL_6oks5sfpPOgaJpZM4PMwRx .

-- Matthias Treder PhD Cognitive Psychology BSc Mathematics

Cardiff University Brain Research Imaging Centre School of Psychology Cardiff University Maindy Road Cardiff CF24 4HQ