I am using SVM from sklearn (Python 3). The predicted class probability is lesser than the highest probability among all classes. Can somebody explain this.
clf = Pipeline([('vect', TfidfVectorizer()), ('clf', svm.SVC())])
parameters = {'vect__ngram_range': [(1, 2)], 'vect__stop_words': ['english'],
'vect__lowercase': [True], 'clf__C': [1,2, 5, 10, 20, 100],
'clf__kernel': [str('linear')], 'clf__class_weight':['balanced'],
'clf__probability': [True]}
vec_clf = GridSearchCV(clf, parameters, scoring='f1_weighted')
vec_clf.fit(x_train, y_train)
Print statements.
pred_data = model.predict(input_series)
probability_lst = model.predict_proba(input_series)[0]
print ("probability lst: ", probability_lst)
print ("predicted data: ", pred_data)
print ("classes: ", model.best_estimator_.classes_)
This is the code I am using. Please find the below print output.
probability lst: [ 0.29004279 0.38866277 0.04441053 0.1173824 0.0300703 0.0983329 0.03109831]
predicted data: ['1']
classes: ['1' '2' '3' '4' '5' '6' '7']
Logically it should predict class "2" as it has highest probability. Please explain this output