% author: M.M.Haji % email : mehdi.haji@gmail.com % function reformat_dtree(in_file, out_file) % in_file: name of the file that is generated by gen_text_data % out_file: name of the output file to be generated for dTree (a java application) % dTree treats the attributes value as strings, so float data of in_file % should be converted to discrete data. D = textread(in_file); outf = fopen(out_file,'w'); % write the attribute and target concept names as the first line of the file: fprintf(outf,'T: '); for i4 = 1:18 fprintf(outf,'f%d, ',i4); end fprintf(outf,'IsText;\r\n'); [nr nc] = size(D); for i1 = 1:nr fprintf(outf,'A: '); for i2 = 1:nc-1 if D(i1,i2) < -250 dsc = 'S3'; elseif D(i1,i2) < -150 dsc = 'S2'; elseif D(i1,i2) < -50 dsc = 'S1'; elseif D(i1,i2) < 50 dsc = 'CE'; elseif D(i1,i2) < 150 dsc = 'B1'; elseif D(i1,i2) < 250 dsc = 'B2'; else dsc = 'B3'; end fprintf(outf,'%s, ',dsc); end fprintf(outf,'%d;\r\n',D(i1,nc)); end fclose(outf);