Skip to content

Instantly share code, notes, and snippets.

@FranciscusRenatus
Created July 21, 2017 13:10
Show Gist options
  • Save FranciscusRenatus/c0f1c7c01b52136d51c49ce38795a338 to your computer and use it in GitHub Desktop.
Save FranciscusRenatus/c0f1c7c01b52136d51c49ce38795a338 to your computer and use it in GitHub Desktop.
# Splitting the dataset into the Training set and Test set
from sklearn.cross_validation import train_test_split
X_train, X_test, y_train, y_test = train_test_split(X, y, test_size = 0.20, random_state = 0)
# Fitting Naive Bayes to the Training set
from sklearn.naive_bayes import GaussianNB
classifier = GaussianNB()
classifier.fit(X_train, y_train)
# Predicting the Test set results
y_pred = classifier.predict(X_test)
# Making the Confusion Matrix
from sklearn.metrics import confusion_matrix
cm = confusion_matrix(y_test, y_pred)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment