# Interpreting distance from hyperplane in SVM

I have a few doubts in understanding SVMs intuitively. Assume we have trained a SVM model for classification using some standard tool like SVMLight or LibSVM.

1. When we use this model for prediction on test data, the model generates a file having "alpha" values for each test point. If alpha value is positive the test point belongs to Class 1, else it belongs to Class 2. Now, can we say that a test point with greater "alpha" value belongs to corresponding class with "higher" probability?

2. Similar to first question, when we have a SVM trained. The SV's lie very near to the hyper-plane. So does that mean that SV's belong to that class with high probability? Can we relate the probability of a point belonging to a class with it's distance from the "hyperplane"? Does "alpha" value represent distance from "hyperplane"?

Thanks for your input.

• I think the answer is "no", but I'm not enough into SVMs to give you a full answer. My gut answer is that when you're on the East side of the Berlin Wall, well you're just on the wrong side, no matter how far your are from it. – Arthur Aug 27 '11 at 13:12
• scikits.learn has predict_proba for SVC and linear_model.SGDClassifier, I believe for binary classifiers only; I haven't used it though. – denis Aug 27 '11 at 15:25

## 1 Answer

Let me first answer your question in general. The SVM is not a probabilistic model. One reason is that it does not correspond to a normalizable likelihood. For example in regularized least squares you have the loss function $\sum_i \|y_i - \langle w, x_i\rangle - b\|_2^2$ and the regularizer $\|w\|_2^2$. The weight vector is obtained by minimizing the sum of the two. However this is equivalent to maximizing the log-posterior of $w$ given the data $p(w|(y_1,x_1),...,(y_m,x_m)) \propto 1/Z \exp(-\|w\|_2^2)\prod_i \exp(\|y_i - \langle w, x_i\rangle - b\|_2^2)$ which you can see to be product of a Gaussian likelihood and a Gaussian prior on $w$ ($Z$ makes sure that it normalizes). You get to the Gaussian likelihood from the loss function by flipping its sign and exponentiating it. However, if you do that with the loss-function of the SVM, the log-likelihood is not a normalizeable probabilistic model.

There are attempts to turn SVM into one. The most notable one, which is-I think-also implemented in libsvm is:

John Platt: Probabilistic outputs for Support Vector Machines and Comparison to Regularized Likelihood Methods (NIPS 1999): http://www.cs.colorado.edu/~mozer/Teaching/syllabi/6622/papers/Platt1999.pdf

To answer your question more specificly: The idea in SVMs indeed is that the further a test vector is from the hyperplane the more it belongs to a certain class (except when it's on the wrong side of course). In that sense, support vectors do not belong to the class with high probability because they either are the ones closest to or on the wrong side of the hyperplane. The $\alpha$ value that you get from libsvm has nothing to do with the $\alpha$ in the decision function. It is rather the output of the decision function $\sum_{i \in SV}\alpha_i k(x,x_i) + b$ (and should therefore be properly called $y$). Since $y = \sum_{i \in SV}\alpha_i k(x,x_i) + b = \langle w, \phi(x) \rangle_{\mathcal H} + b$ where $w$ lives in the reproducing kernel Hilbert space, $y$ is proportional to the signed distance to the hyperplane. It would be if you divide by the norm of $w$, which in kernel terms is $\|w\|_{H} = \sqrt{\sum_{i,j\in SV} \alpha_i \alpha_j k(x_i,x_j)}$.

• thnx for your explanation...will read the paper – Amit Aug 28 '11 at 6:12
{"ft_lang_label":"__label__en","ft_lang_prob":0.8816781,"math_prob":0.97113764,"size":2188,"snap":"2019-35-2019-39","text_gpt3_token_len":592,"char_repetition_ratio":0.09661172,"word_repetition_ratio":0.011560693,"special_character_ratio":0.26919562,"punctuation_ratio":0.1006865,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9988115,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2019-08-21T23:29:42Z\",\"WARC-Record-ID\":\"<urn:uuid:6b720e4b-6833-44d7-a159-0da5272e2f76>\",\"Content-Length\":\"138434\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:2bc4134d-5af6-4663-8959-29e107633edd>\",\"WARC-Concurrent-To\":\"<urn:uuid:6f11481b-6ccb-4215-8259-4231e2e634cd>\",\"WARC-IP-Address\":\"151.101.1.69\",\"WARC-Target-URI\":\"https://stats.stackexchange.com/questions/14876/interpreting-distance-from-hyperplane-in-svm/14881\",\"WARC-Payload-Digest\":\"sha1:M2DAKZRKWXPWPZT3OZKISCHRZF6OOBP6\",\"WARC-Block-Digest\":\"sha1:M37VW334TLNFR3KCKZYEQL5FA7RDCWHY\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2019/CC-MAIN-2019-35/CC-MAIN-2019-35_segments_1566027316549.78_warc_CC-MAIN-20190821220456-20190822002456-00488.warc.gz\"}"}