Issue
I try to learn machine learning from Udacity's Intro to machine learning course.
Lesson 2- Naive Bayes quiz 19: Gaussian NB Deployment on Terrain Data
I have to add some code in the classifyNB.py file which I have added
def classify(features_train, labels_train):
### import the sklearn module for GaussianNB
### create classifier
### fit the classifier on the training features and labels
### return the fit classifier
### your code goes here!
from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
clf.fit(features_train, labels_train)
return((features_train, labels_train)
But the code did not compile and threw some errors.
Any idea what should I write in order to return the fit classifier
Solution
I did the same exercise this way
def classify(features_train, labels_train):
### import the sklearn module for GaussianNB
### create classifier
### fit the classifier on the training features and labels
### return the fit classifier
### your code goes here!
from sklearn.naive_bayes import GaussianNB
clf = GaussianNB()
clf.fit(features_train, labels_train)
return clf
Answered By - Israel Veleces
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.