# How to apply SVM model to new data using libsvm in MATLAB?

Suppose that I have trained and tested an SVM classifier with the following code:

load('Model and Optimized SVM Parameters1.mat');
TrainData = double(model.Train(:,1:end-1));
TargetTrain = double(model.Train(:,end));
TestData = double(model.Test(:,1:end-1));
TargetTest = double(model.Test(:,end));
option = ['-h 0 -s 0 -t 2 -q -c ',num2str(20.6062),' -g ',num2str(0.2331)] ;
MODEL = svmtrain ( TargetTrain , TrainData , option ) ;
[OutputTest , ClassificationAccuracy , dec_values] = svmpredict ( TargetTest , TestData , MODEL ) ;


Now I have a dataset X as the same format as TrainData or TestData which has no label and I want to classify the entries of X with the classifier that is described in MODEL. Something like:

OutputLabel = svmpredict ( X, MODEL ) ;


but seems that svmpredict always takes the desired label as an argument (here)
How should I use the classifier described in MODEL for classifying a dataset (for example an Image) while I have no label for the data?

• OutputLabel = svmpredict (zeros(size(X,1),1), X, MODEL ) ; – DataD'oh Sep 5 '17 at 9:13
• I think the title is misleading, it should be something like "How to predict test data using libsvm in MATLAB when labels are not known" – DataD'oh Sep 5 '17 at 9:16