cvpartition object with manual input

1 vue (au cours des 30 derniers jours)
Eduardo Maristany de Las Casas
I want to be able to define manually/beforehand which indices go to train and which ones go to test in the cvpartition object.
How can I achieve this?

Réponses (1)

Prince Kumar
Prince Kumar le 12 Avr 2022
Hi,
You can slice the data as per your need.
Look at the following example :
load ionosphere
v2 = X(1:4,:);
v2 = [v2; X(10:14,:)];
disp(v2);
Columns 1 through 22 1.0000 0 0.9954 -0.0589 0.8524 0.0231 0.8340 -0.3771 1.0000 0.0376 0.8524 -0.1776 0.5976 -0.4495 0.6054 -0.3822 0.8436 -0.3854 0.5821 -0.3219 0.5697 -0.2967 1.0000 0 1.0000 -0.1883 0.9304 -0.3616 -0.1087 -0.9360 1.0000 -0.0455 0.5087 -0.6774 0.3443 -0.6971 -0.5169 -0.9751 0.0550 -0.6224 0.3311 -1.0000 -0.1315 -0.4530 1.0000 0 1.0000 -0.0336 1.0000 0.0049 1.0000 -0.1206 0.8897 0.0120 0.7308 0.0535 0.8544 0.0083 0.5459 0.0030 0.8377 -0.1364 0.7553 -0.0854 0.7089 -0.2750 1.0000 0 1.0000 -0.4516 1.0000 1.0000 0.7122 -1.0000 0 0 0 0 0 0 -1.0000 0.1452 0.5409 -0.3933 -1.0000 -0.5447 -0.6997 1.0000 1.0000 0 -0.0186 -0.0846 0 0 0 0 0.1147 -0.2681 -0.4566 -0.3817 0 0 -0.3366 0.3860 -0.3713 0.1502 0.6373 0.2212 0 0 1.0000 0 1.0000 0.0665 1.0000 -0.1839 1.0000 -0.2732 1.0000 -0.4311 1.0000 -0.4135 0.9623 -0.5187 0.9071 -0.5902 0.8923 -0.6647 0.6988 -0.7100 0.7065 -0.7632 1.0000 0 1.0000 -0.5421 1.0000 -1.0000 1.0000 -1.0000 1.0000 0.3622 1.0000 -0.4112 1.0000 1.0000 1.0000 -1.0000 1.0000 -0.2935 1.0000 -0.9360 1.0000 1.0000 1.0000 0 1.0000 -0.1632 1.0000 -0.1017 1.0000 -0.1520 1.0000 -0.1928 0.9405 -0.3515 0.9574 -0.2979 0.9372 -0.3441 0.9449 -0.2811 0.9014 -0.4338 0.8604 -0.4731 1.0000 0 1.0000 -0.8670 1.0000 0.2228 0.8549 -0.3990 1.0000 -0.1209 1.0000 0.3515 1.0000 0.0777 1.0000 -0.1477 1.0000 -1.0000 1.0000 -1.0000 0.6183 0.1580 Columns 23 through 34 0.3695 -0.4736 0.5681 -0.5117 0.4108 -0.4617 0.2127 -0.3409 0.4227 -0.5449 0.1864 -0.4530 -0.1806 -0.3573 -0.2033 -0.2657 -0.2047 -0.1840 -0.1904 -0.1159 -0.1663 -0.0629 -0.1374 -0.0245 0.4339 -0.1206 0.5753 -0.4022 0.5898 -0.2215 0.4310 -0.1736 0.6044 -0.2418 0.5605 -0.3824 0 0 1.0000 0.9070 0.5161 1.0000 1.0000 -0.2010 0.2568 1.0000 -0.3238 1.0000 0 0 -0.1480 -0.0133 0.2064 -0.0229 0 0 0.1659 0.2409 -0.0821 0.3806 0.6308 -0.8054 0.5587 -0.8913 0.4721 -0.8650 0.4030 -0.8367 0.3100 -0.8909 0.2299 -0.8916 1.0000 1.0000 1.0000 -0.4089 1.0000 -0.6274 1.0000 -1.0000 1.0000 -1.0000 1.0000 -1.0000 0.8299 -0.5122 0.8408 -0.4714 0.7622 -0.5837 0.6572 -0.6879 0.6871 -0.6454 0.6473 -0.6723 1.0000 0.6235 1.0000 -0.1701 1.0000 0.3592 1.0000 -0.6649 1.0000 0.8843 1.0000 -0.1883
Here "v2" will contain the data with your choice of indices.
For more information please look indexing documentation.
Hope this helps!

Catégories

En savoir plus sur Sequence and Numeric Feature Data Workflows dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by