I am having a tough time implementing all the steps of setting up support vector machine (SVM) for unsupervised learning. My data set is labelled but for educational purposes I am learning unsupervised methods especially how to use SVM in an unsupervised way.

Basically, in supervised learning we have a data set X that is split into Xtrain Xval and an independent Xtest which is never seen by the SVM during training. During training, the hyperparameters are learned using cross-validation (CV approach). My question is that for unsupervised learning should I need to have Xtrain, Xval and CV for learning the hyperparameters? The reason I ask is that theoretically in unsupervised learning we don't have any labelled dataset. Does this mean that we don't have Xtrain and Xval?

In the Matlab link, cross validation is done but it is unclear to me if that is done on part of the training data Xval

CVSVMModel = crossval(SVMModel);
[~,scorePred] = kfoldPredict(CVSVMModel);


1) Do we estimate the hyperparameters in SVM for unsupervised learning?

2) If yes, then this implies that we have access to labels when theoretically unsupervised learning is without knowing the labelled data set. This is contradictory to me.

How do I estimate the hyperparameters in unsupervised SVM without Xval and splitting the dataset using c = cvpartition(n,'KFold',k)

Can sombebody please suggest how to go about unsupervised learning. Thank you.

  • 1
    $\begingroup$ Can you elaborate how you are going to use an SVM for unsupervised learning? I have only seen this as supervised, since it requires target values. $\endgroup$
    – Wes
    Commented Feb 20, 2019 at 23:12
  • 1
    $\begingroup$ @Wes: I have put the Matlab link where the demo example shows how to use SVM for unsupervised learning. Basically, all the data samples are put into a single class type and SVM is trained on it. During testing, any example that the SVM had not seen before is classified as an outlier. $\endgroup$
    – Srishti M
    Commented Feb 21, 2019 at 0:37

1 Answer 1


For an unsupervised technique, if you have some metric of "goodness of fit", it makes sense to have a train-test split. In your case, it seems as though you'd want to split the data so that you can see if your SVM classifies the test data as outliers.

However, your goal is unclear. It might help if you clarify what you mean.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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