How to reference Discontiguous data rows in a function? -from new user

1 次查看(过去 30 天)
I have imported a data set to model a decision tree using fitctree function.
My overall aim is to model a training sample from the data, and predict the remainder as out-of-sample - but I want to determine out-of-sample prediction for the entire dataset, so my approach is to model 4/5 of data as training (say, rows 1-800), and record prediction for the other 1/5 (rows 801-1000).
My problem is that I then want the fitctree fucntion to use rows 1-600 AND rows 801-1000 as the training sample, so that I can record tree.predict for rows 601-800, and so on until I can record predicted values for 5 sets of test data to populate results for the entire 1000 row set.
My firt function looked similar to this: fitctree(T(1:800,2:end),T(1:800,1)) X values are in columns 2:end, and the Y values are in column 1.
Any tips would be great! Thanks!

采纳的回答

Matt J
Matt J 2014-9-22
Something like this, perhaps,
rows=[1:600,801:1000];
fitctree(T(rows,2:end),T(rows,1))

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Categorical Arrays 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by