How does a trained classifier label a picture by its own?

How does a trained classifier label a picture by its own? Let's say I have a training set, train it using the LDA classifier and it shows me the accuracy/similarities. How do I use this to apply on the picture I want to label?

 Accepted Answer

You have to do that in separate steps afterwards. Your classifier should give you some kinds of instructions for classifying pixels, for example, pixels darker than 130 are background, and pixels brighter than 130 are foreground.

8 Comments

If let's say my training data is much smaller than the actual training data, how much will it affect the classifier? Will it affect the dimensions of the output?
That doesn't make sense. How can the training data be smaller than the training data (smaller than itself)????
Obviously the more data you have to train it with, the better your classifier will be, up to a point I guess. After a while, adding training data will not significantly alter the decision parameters - you've essentially reached a steady state, as good as you're going to get.
Dimensions of the output - I don't know. I don't know what kind of output your classifier produces and if it changes with the number of training data points. I would doubt that changing the number of training data points would give a different classifier, it would just refine the parameters of the current model. For example if your model is a line y=ax+b, it will be a line no matter how many points you trained (fit) the line to, but you'll get small adjustments in the values of a and b.
My training data is small due to insufficient memory, hence due to this problem I have to reduce the training data to make it work. Any advice?
I don't know what to suggest other than get more memory or try to change your program to use smaller chunks of data and then recombine. http://www.mathworks.com/support/tech-notes/1100/1107.html
If I want to use smaller chunks of data, I have to add them one after another right? Let's say I have the following data split from LDA data:
Trial data
Trial data2
So, in the program I will have to run both in the program or separately?
I'm not sure you've supplied enough info to answer, but I'd say yes. Run both sets of data and run them separately because you said that your data is so gigantic (I'm thinking several GB or more) that it won't fit into memory.
Thanks for the guidance, Im trying it now and might get back to you later.
Yup, calculated it to be 100+ GB. Pardon for being a newbie at this, but by running separately, do you mean this? Or should I put in as another GUI button?
data = importdata('Trial data4.mat');
features=data(:,1:end-1); %split data without labels
lable=data(:,end); %get the labels
trainSamples = im2double(features);%training samples
trainClasses = im2double(lable);%training labels
testSamples = im2double(features);%test samples
lableimage = reshape(handles.lableimage,[],1);
testClasses = im2double(handles.lableimage);%test labels
disp('GUI: trainSamples is')
class(trainSamples)
disp('GUI: testSamples is')
class(testSamples)
mLDA = LDA(trainSamples, trainClasses');
mLDA.Compute();
clear data
transformedTrainSamples = mLDA.Transform(trainSamples, 1);
transformedTestSamples = mLDA.Transform(testSamples, 1);
calculatedClasses = knnclassify(transformedTestSamples, transformedTrainSamples, trainClasses);
simmilarity = [];
for i = 1 : 1 : length(testClasses)
similarity(i) = (testClasses(i)==calculatedClasses(i));
end
accuracy = sum(similarity) / length(testClasses);
fprintf('Testing: Accuracy is: %f %%\n', accuracy*100);
data = importdata('Trial data5.mat');
features=data(:,1:end-1); %split data without labels
lable=data(:,end); %get the labels
trainSamples = im2double(features);%training samples
trainClasses = im2double(lable);%training labels
testSamples = im2double(features);%test samples
lableimage = reshape(handles.lableimage,[],1);
testClasses = im2double(handles.lableimage);%test labels
disp('GUI: trainSamples is')
class(trainSamples)
disp('GUI: testSamples is')
class(testSamples)
mLDA = LDA(trainSamples, trainClasses');
mLDA.Compute();
clear data
transformedTrainSamples = mLDA.Transform(trainSamples, 1);
transformedTestSamples = mLDA.Transform(testSamples, 1);
calculatedClasses = knnclassify(transformedTestSamples, transformedTrainSamples, trainClasses);
simmilarity = [];
for i = 1 : 1 : length(testClasses)
similarity(i) = (testClasses(i)==calculatedClasses(i));
end
accuracy = sum(similarity) / length(testClasses);
fprintf('Testing: Accuracy is: %f %%\n', accuracy*100);
guidata(hObject, handles);

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!