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!