What are the inputs of fitcsvm to train a clasifier model?
1 view (last 30 days)
Show older comments
Can anyone tell me what will be the X and Y..i have read theory on Matab website but i do not understand..
SVMModel = fitcsvm(X,Y)
i am using bag of features approach...my algo so far is
1.Surf feature Extraction of dataset of images
2. clutering using k means
3. histogram representation of images
pls suggest according to my approach what should be inputs X and Y..i have to do binary classification my code is:
if true
% clc;
clear;
close all;
features = {};
folder = 'D:\Dataset\data1\data';
filePattern = fullfile(folder, '*.jpg');
f=dir(filePattern);
files={f.name};
imds = imageDatastore(folder ,'IncludeSubfolders',true,'LabelSource',...
'foldernames');
num_features = zeros(numel(files), 1); % New - for keeping track of # of features per image
for k=1:numel(files)
fullFileName = fullfile(folder, files{k});
H = fspecial('log');
image=imfilter(imread(fullFileName),H);
image=rgb2gray(image);
temp = detectSURFFeatures(image);
[im_features, temp] = extractFeatures(image, temp);
num_features(k) = size(im_features, 1); % New - # of features per image
features{k}= im_features;
end
features = vertcat(features{:});
num_clusters = 200;
[assignments,centers] = kmeans(double(features), num_clusters);
counter = 1;
features_hist = zeros(numel(files), num_clusters);
for k = 1 : numel(files)
a = assignments(counter : counter + num_features(k) - 1);
h = histcounts(a, 1 : num_clusters + 1);
features_hist(k, :) = h;
% Increment counter
counter = counter + num_features(k);
end
end
0 Comments
Answers (0)
See Also
Categories
Find more on Statistics and Machine Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!