classification using decision tree
조회 수: 7 (최근 30일)
이전 댓글 표시
I have A=[0.0218 -0.0324 -0.0107 -0.0324 0.0001 -0.0107 -0.0107 -0.0324 -0.0216 0.0001 -0.0162 -0.0324 0.0055 -0.0541 0.0272 -0.0324
0.1355 0.0001 0.0542 0.0651 0.0651 0.0272 0.0542 0.0163 -0.0053 -0.0053].How can I do classification using decision tree using these points my dataset is attached here.The A is the set extracted from Train set.
댓글 수: 0
채택된 답변
Jyothis Gireesh
2019년 10월 9일
I am assuming that there may be some problem with the file names as the file ‘ECGFiveDays_TRAIN.xlsx’ contains only 23 records and ‘ECGFiveDays_TEST.xlsx’ contains 861 records. It may not be optimal to fit the decision tree using just 23 records and then evaluate the resulting model on a bigger dataset.
So, for the following code I have taken the liberty of using the bigger dataset as the training data. Please make use of the following code snippet to perform the classification using decision trees.
clear;
trainData = xlsread('ECGFiveDays_TEST.xlsx');
testData = xlsread('ECGFiveDays_TRAIN.xlsx');
tree = fitctree(trainData(:,2:end),trainData(:,1)); %Fit the dataset using decision tree
predictLabels = predict(tree,testData(:,2:end)); %Evaluate on test dataset
trueLabels = testData(:,1);
testAccuracy = sum(predictLabels == trueLabels)/length(trueLabels);
Please go through the following documentation link on “fitctree()” if you need any further clarifications on the same
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!