0
0
ML Pythonprogramming~10 mins

Naive Bayes classifier in ML Python - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Naive Bayes classifier from scikit-learn.

ML Python
from sklearn.naive_bayes import [1]
Drag options to blanks, or click blank then click option'
AGaussianNB
BDecisionTreeClassifier
CKNeighborsClassifier
DRandomForestClassifier
Attempts:
3 left
2fill in blank
medium

Complete the code to create a Gaussian Naive Bayes model instance.

ML Python
model = [1]()
Drag options to blanks, or click blank then click option'
ALogisticRegression
BSVC
CRandomForestClassifier
DGaussianNB
Attempts:
3 left
3fill in blank
hard

Fix the error in the code to train the Naive Bayes model on features X_train and labels y_train.

ML Python
model.[1](X_train, y_train)
Drag options to blanks, or click blank then click option'
Atransform
Bfit
Cpredict
Dscore
Attempts:
3 left
4fill in blank
hard

Fill both blanks to predict labels for X_test and calculate accuracy score.

ML Python
predictions = model.[1](X_test)
accuracy = accuracy_score(y_test, [2])
Drag options to blanks, or click blank then click option'
Apredict
Bpredictions
Cfit
Dtransform
Attempts:
3 left
5fill in blank
hard

Fill all three blanks to create a dictionary of class prior probabilities from the trained model.

ML Python
class_priors = {cls: prob for cls, prob in zip(model.[1], model.[2])}
print(class_priors[[3]])
Drag options to blanks, or click blank then click option'
Aclasses_
Bclass_prior_
C'spam'
Dpredict
Attempts:
3 left