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

조회 수: 1 (최근 30일)
Justin
Justin 2014년 9월 22일
댓글: Justin 2014년 9월 22일
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