How do I partition my data into XTrain and YTrain with Code.

I want to learn how to partition data into XTrain and YTrain with code.
I usually do it manually, but I want to learn how to assign the last Row or Column as YTrain and the remaining as XTrain.
for example, I have 10 variables and I want to select the variable 1 - 9 as XTrain and 10 as YTrain

5 comentarios

u can use indexing. assuming your variables are in columns.
XTrain = Vars(:,1:9);
YTrain = Vars(:,10);
Thank you for your reply.
I case I have a block of data, I want to diivded in to
XTrain
XValidation
YTrain
YValidation
@ikeuwanuakwa, you can do that using indexing as Mohammad suggested.
xTrain = m(1:9, 1) this isolates rows 1:9 of column 1.
Thank you
Glad I could help!
Worthy of mentioning: cvpartition(), although it may not be useful for this particular problem based on your description.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Preguntada:

el 31 de Mzo. de 2020

Comentada:

el 22 de Abr. de 2020

Community Treasure Hunt

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

Start Hunting!

Translated by