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?

  • $\begingroup$ OutputLabel = svmpredict (zeros(size(X,1),1), X, MODEL ) ; $\endgroup$ – Krrr Sep 5 '17 at 9:13
  • $\begingroup$ 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" $\endgroup$ – Krrr Sep 5 '17 at 9:16

From the libsvm readme:

If labels of test data are unknown, simply use any random values.

So just use a vector of ones or zeroes or whatever you are using for labels. You won't be able to trust the classification accuracy output but the predictions will be usable.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.