Classification using test and train datasets.

6 vues (au cours des 30 derniers jours)
Silpa K
Silpa K le 7 Nov 2019
Commenté : Silpa K le 8 Nov 2019
For classifcation using decision tree and finding the accuracy of the classification I used the code below, but I am getting error messages. How can I find the classifcation and accuracy of the classification? Please help me.
trainData = xlsread('arrtrain.xlsx');
testData = xlsread('arrtest.xlsx');
tr = fitctree(trainData(:,2:end),trainData(:,1));
predictLabels = predict(tr,testData(:,2:end));
trueLabels = testData(:,1);
testAccuracy = sum(predictLabels == trueLabels)/length(trueLabels)*100;
The datasets are attached here.
  1 commentaire
Silpa K
Silpa K le 8 Nov 2019
clc
clear
b=zeros(36,1);
ts = xlsread('ArrowHead_TRAIN.xlsx');
l=length(ts);
for i = 1:36
p=ts(i,:);
fa = movstd(p,20,1);
secarray=movstd(fa,20,1);
k=maxk(secarray,10);
mpt=find(p);
mp=p(mpt(round(numel(mpt)/2)));
G=min(abs(mp-k));
[~,ii] = min(abs(p(:) - k(:)'));
out = p(unique(ii));
for i = 1 : size(ts,1)
b = 30;
p = ts(i,:);
n = numel(p);
Z = mat2cell(p, 1, diff([0:b:n-1,n]));
end
A = [];
for ii = 1:length(Z)
if any(ismember(Z{ii},out))
if (k-mp<=G+l/2)
A{end+1} = Z{ii};
aa = ii;
end
end
end
z=Z{ii};
idx=p(1:1);
q=[idx z];
data = q;
cellReference = sprintf('A%d', i);
xlswrite('tra.xlsx', data, 1, cellReference);
end
I used the above code for getting the datasets.How can I write all the needed rows in excel.

Connectez-vous pour commenter.

Réponses (1)

Image Analyst
Image Analyst le 7 Nov 2019
You need to give it data.
Your workbooks are completely empty except for a single number in one cell way down at row 175.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by