# Scikit-Learn SVC Porbability Function

I use scikit-learn to train a SVC with 'poly'-Kernel and propability-paramter enabled.

Most of the time the prediction and the probability assigned to the prediction is correct. That means:

y_pred = self.clf_.predict(feat_scaled)  # y_pred=1
probs = self.clf_.predict_proba(feat_scaled) # probs=[0.01, 0.9, 0.08, 0.01]


but sometimes the prediction and the probabilities are not the same:

y_pred = self.clf_.predict(feat_scaled)  # y_pred=2
probs = self.clf_.predict_proba(feat_scaled) # probs=[0.8, 0.05, 0.1, 0.05]


As you can see the predcition should be class-0 since it has the largest probability but somehow it is classified as class-2.

What is happening here?

The decision of SVC is not based on the probabilities it produces. In fact, support-vector machine is a non-probabilistic classifier, but there is a way of transforming the outputs of classifiers into probabilities $$-$$ Platt calibration. This method is used when you set probability=True, and yes, sometimes the results of predict_proba are inconsistent with the predictions of SVC. See the documentation.
{"ft_lang_label":"__label__en","ft_lang_prob":0.8032113,"math_prob":0.94510317,"size":675,"snap":"2023-40-2023-50","text_gpt3_token_len":197,"char_repetition_ratio":0.1490313,"word_repetition_ratio":0.0,"special_character_ratio":0.29777777,"punctuation_ratio":0.19310345,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.99378765,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-12-01T08:09:21Z\",\"WARC-Record-ID\":\"<urn:uuid:ab711e5e-8fde-46ed-9724-b2756df66499>\",\"Content-Length\":\"157280\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:02edbfed-190a-4e4d-aedd-3f30ae9d768e>\",\"WARC-Concurrent-To\":\"<urn:uuid:5ff4a900-0b79-4fb0-96e7-004dc725dcbd>\",\"WARC-IP-Address\":\"104.18.43.226\",\"WARC-Target-URI\":\"https://stats.stackexchange.com/questions/411814/scikit-learn-svc-porbability-function\",\"WARC-Payload-Digest\":\"sha1:CZRFNG6DFNA6TB6KOSSAXI3IJOPFKWMN\",\"WARC-Block-Digest\":\"sha1:SX7F5263H5Q2G2IJWFLSP64UIX2JZOW2\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-50/CC-MAIN-2023-50_segments_1700679100276.12_warc_CC-MAIN-20231201053039-20231201083039-00030.warc.gz\"}"}