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));
predictLabels = predict(tree,testData(:,2:end));
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
Best Answer