From: rocky on 29 Nov 2009 21:46 >> clc >> clear %now i import a file from excel and give the matrix the name 'data' %each row is a sample, each column is a attribute >> input=data(:,1:13); output=data(:,14); [train,test]=crossvalind('holdout',output); input_train=input(train,:); output_train=output(train,:); input_test=input(test,:); output_test=output(test,:); t=classregtree(input_train,output_train,'names',{'CRIM' 'ZN' 'INDUS' 'CHAS' 'NOX' 'RM' 'AGE' 'DIS' 'RAD' 'TAX' 'PTRATIO' 'B' 'LSTAT'}); >> [cost,s,n,best] = test(t,'cross',input_train,output_train); ??? Indexing cannot yield multiple results. why have this problem, how can i solve it ?
From: Ilya Narsky on 30 Nov 2009 10:37 "rocky " <rockyguojing(a)gmail.com> wrote in message news:hevbla$bt4$1(a)fred.mathworks.com... >>> clc >>> clear > %now i import a file from excel and give the matrix the name 'data' > %each row is a sample, each column is a attribute >>> input=data(:,1:13); > output=data(:,14); > [train,test]=crossvalind('holdout',output); > input_train=input(train,:); > output_train=output(train,:); > input_test=input(test,:); > output_test=output(test,:); > t=classregtree(input_train,output_train,'names',{'CRIM' 'ZN' 'INDUS' > 'CHAS' 'NOX' 'RM' 'AGE' 'DIS' 'RAD' 'TAX' 'PTRATIO' 'B' 'LSTAT'}); >>> [cost,s,n,best] = test(t,'cross',input_train,output_train); > ??? Indexing cannot yield multiple results. > why have this problem, how can i solve it ? Can you try cost = t.test('cross',input_train,output_train); and let us know if it makes a difference? Also, the subject line says "decision tree for regression", but looks like your 'output' is categorical. If your 'output' is continuous, using crossvalind is not a good idea. Perhaps, what you really want is a classification tree. -Ilya
|
Pages: 1 Prev: How can plot signal by cwt? Next: OPQSK Modulation Issue - Simulink |