Last active
August 22, 2020 00:22
-
-
Save AniekanInyang/8336ed0a1569f003be6895e6448df3ed to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 22, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"name": "stdout", | |
"output_type": "stream", | |
"text": [ | |
"[GaussianNB] Accuracy: train = 0.9525310912594149, test = 0.6113445378151261\n" | |
] | |
}, | |
{ | |
"data": { | |
"text/plain": [ | |
] | |
}, | |
"execution_count": 22, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"from sklearn.naive_bayes import GaussianNB\n", | |
"\n", | |
"# Train a Guassian Naive Bayes classifier\n", | |
"nb = GaussianNB()\n", | |
"\n", | |
"nb.fit(features_train, y_train)\n", | |
"\n", | |
"# Calculate the mean accuracy score on training and test sets\n", | |
"print(\"[{}] Accuracy: train = {}, test = {}\".format(\n", | |
" nb.__class__.__name__,\n", | |
" nb.score(features_train, y_train),\n", | |
" nb.score(features_test, y_test)))\n" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3.7.6 64-bit", | |
"language": "python", | |
"name": "python37664bitf2b8979454eb492e8e911544bb13ab4b" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.7.6" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 4 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment