Naivebays
Naivebays
Naivebays
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
data=pd.read_csv('PlayTennis.csv')
data.head()
data.columns
X_train=pd.get_dummies(data[['Outlook','Temperature','Humidity','Wind']])
y_train=pd.get_dummies(data[['PlayTennis']])
print(y_train)
PlayTennis_No PlayTennis_Yes
0 1 0
1 1 0
2 0 1
3 0 1
4 0 1
5 1 0
6 0 1
7 1 0
8 0 1
9 0 1
10 0 1
11 0 1
12 0 1
13 1 0
print(X_train)
Wind_Strong Wind_Weak
0 0 1
1 1 0
2 0 1
3 0 1
4 0 1
5 1 0
6 1 0
7 0 1
8 0 1
9 0 1
10 1 0
11 1 0
12 0 1
13 1 0
y_train=pd.get_dummies(data['PlayTennis'],drop_first=True)
print(y_train)
Yes
0 0
1 0
2 1
3 1
4 1
5 0
6 1
7 0
8 1
9 1
10 1
11 1
12 1
13 0
model=GaussianNB()
model.fit(X_train,y_train)
predict=model.predict([[1,0,0,0,1,0,1,0,0,1]])
/usr/local/lib/python3.10/dist-packages/sklearn/base.py:439: UserWarning: X does not have valid feature names, but GaussianNB was fi
warnings.warn(
print(predict)
[1]