# Download the attached NaïveBayes Classifier steps and theory. Read through the theoryto understand problem solution manually. Copy the python code given inthesteps document and run the code. The resul

#Defining Dataset # Assigning features and label variables weather=['Sunny','Sunny','Overcast','Rainy','Rainy','Rainy','Overcast','Sunny','Sunny', 'Rainy','Sunny','Overcast','Overcast','Rain y'] temp=['Hot','Hot','Hot','Mild','Cool','Cool','Cool','Mild','Cool','Mild','Mild','Mild','Hot','Mild'] play=['No','No','Yes','Yes','Yes','No','Yes','No','Yes','Yes','Yes','Yes','Yes','No'] #Encoding Features # Import LabelEncoder from sklearn import pr eprocessing #creating labelEncoder le = preprocessing.LabelEncoder() # Converting string labels into numbers. wheather_encoded=le.fit_transform(wheather) print wheather_encoded # Converting string labels into numbers temp_encoded=le.fit_transform(temp) label=le.fit_transform(play) print "Temp:",temp_encoded print "Play:",label #Combining Features #Combinig weather and temp into single listof tuples features=zip(weather_encoded,temp_encoded) print features #Generating Model #Generate a model using naive bayes classifier in the following steps: #Create naive bayes classifier #Fit the dataset on classifier #Perform prediction #Import Gaussian Naive Bayes model from sklearn.naive_bayes import GaussianNB #Create a Gaussi an Classifier model = GaussianNB() # Train the model using the training sets model.fit(features,label) #Predict Output predicted= model.predict([[0,2]]) # 0:Overcast, 2:Mild print "Predicted Value:", predicted