Skip to content

Instantly share code, notes, and snippets.

@vijayanandrp
Created October 31, 2017 03:37
Show Gist options
  • Save vijayanandrp/3a60b49890522a5bfe6bfae9094dc0c3 to your computer and use it in GitHub Desktop.
Save vijayanandrp/3a60b49890522a5bfe6bfae9094dc0c3 to your computer and use it in GitHub Desktop.
Topic Classification using naive bayes with simple example.
Accuracy of MultinomialNB (naive Bayes) - 83.48868175765645
Accuracy (after tuning) of MultinomialNB (naive Bayes) - 88.34886817576565
Grid Search best score -
0.945059813912
Grid Search best parameters -
{'clf__alpha': 0.5,
'clf__fit_prior': False,
'tfidf__use_idf': True,
'vect__ngram_range': (1, 1)}
Metrics classification report
precision recall f1-score support
alt.atheism 0.97 0.60 0.74 319
comp.graphics 0.96 0.89 0.92 389
sci.med 0.97 0.81 0.88 396
soc.religion.christian 0.65 0.99 0.78 398
avg / total 0.88 0.83 0.84 1502
Metric Confusion matrix
[[192 2 6 119]
[ 2 347 4 36]
[ 2 11 322 61]
[ 2 2 1 393]]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment