0
$\begingroup$

I have two Naïve Bayes classifiers

nb_classifier = MultinomialNB(alpha=0.05, fit_prior=True)
nb_classifier.fit(X_train, y_train)

and

nb_classifier = MultinomialNB(alpha=1, fit_prior=True)
nb_classifier.fit(X_train, y_train)

where the only difference is the alpha value.

How do I choose the classifier that performs best?

I guess I should both classifiers with my test data set, but what should I look for when I claim one of them to be better than the other?

Should I use

nb_classifier.score(X_test, y_test)
$\endgroup$
0
$\begingroup$

Yes, the classifier that performs the best with your test data is very likely to be the best classifier.

If you want to get more fancy, you can use cross-validation scoring to see if your modes are accurate to similar degrees using different train/test datasets:

skl_cv.cross_val_predict(nb_classifier, X = X, y = y, cv = 5)

Use your full X and y data, rather than X_train and y_train. The method will split your data into train and test data automatically, and will return an array of scores for each different train/test split. This should help you identify how robust the model is.

| cite | improve this answer | |
$\endgroup$
  • $\begingroup$ But I don't know what the output means. I just get a vector with a lot of numbers $\endgroup$ – Jamgreen Nov 8 '16 at 7:13
  • $\begingroup$ then read the documentation, scikit learn has quite a good one $\endgroup$ – rep_ho Jan 25 '19 at 11:38

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.