Upload New File

This commit is contained in:
Ragini.N
2020-10-22 09:41:16 +00:00
parent 0fbcee9626
commit 9b8f264ac6

View File

@@ -0,0 +1,12 @@
setDir = fullfile(toolboxdir('machine'),'machine data','imagesets');
imds = imageDatastore(setDir,'IncludeSubfolders',true,'LabelSource',...
'foldernames');
[trainingSet,testSet] = splitEachLabel(imds,0.3,'randomize');
bag = bagOfFeatures(trainingSet);
categoryClassifier = trainImageCategoryClassifier(trainingSet,bag);
confMatrix = evaluate(categoryClassifier,testSet)
mean(diag(confMatrix))
img = imread(fullfile(setDir,'negative','e_images_3.jpg'));
[labelIdx, score] = predict(categoryClassifier,img);
categoryClassifier.Labels(labelIdx)