How to reference Discontiguous data rows in a function? -from new user
1 view (last 30 days)
Show older comments
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!
0 Comments
Accepted Answer
Matt J
on 22 Sep 2014
Something like this, perhaps,
rows=[1:600,801:1000];
fitctree(T(rows,2:end),T(rows,1))
More Answers (0)
See Also
Categories
Find more on Categorical Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!