Effacer les filtres
Effacer les filtres

How one can assign the indices of train and test data manually?

4 vues (au cours des 30 derniers jours)
RZM
RZM le 5 Juil 2018
Commenté : GIULIA CISOTTO le 27 Juil 2020
The function "cvpartition" randomly chooses a subset of data for train and the rest for test in K-Fold cross validation. However, it is not possible to change the index of each data partition in a defined cvpartition object. I was wondering if someone here knows a way to do it. For example if we had a dataset with 300 samples (observations), the following code makes 10 random distinct partitions for train and test data.
CVO = cvpartition(300,'k',10)
Now if I want to assign first 270 samples as train and the rest as test for the first partition I would do this:
CVO.training(1) = logical([ones(270,1);zeros(30,1)])
Which does not work and returns an error:
Assignment not supported because the result of method 'training' is a temporary value.
Any suggestion is greatly appreciated!
  1 commentaire
GIULIA CISOTTO
GIULIA CISOTTO le 27 Juil 2020
Did you find solution to this problem? If yes, could you kindly share it.. It would be very useful! Thanks

Connectez-vous pour commenter.

Réponses (0)

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by