June 2020
Intermediate to advanced
382 pages
11h 39m
English
Now, let's use the naive Bayes algorithm to solve the classifiers challenge:
First, we import the GaussianNB() function and use it to train the model:
from sklearn.naive_bayes import GaussianNBclassifier = GaussianNB()classifier.fit(X_train, y_train)
Now, let's use the trained model to predict the results. We will use it to predict the labels for our test partition, which is X_test:
Predicting the Test set resultsy_pred = classifier.predict(X_test)cm = metrics.confusion_matrix(y_test, y_pred)cm
Now, let's print the confusion matrix:

Now, let's print the performance matrices ...
Read now
Unlock full access