from sklearn.datasets import load_iris
import pandas as pd
import numpy as np
from matplotlib import pyplot as plt
data = pd.DataFrame(load_iris().data)
data
labels = load_iris().target
labels
data.hist()
plt.show()
plt.scatter(x = data[0],y = data[1],c = labels)
plt.show()
plt.scatter(x = data[2],y = data[3],c = labels)
plt.show()
from sklearn.naive_bayes import MultinomialNB,BernoulliNB,GaussianNB
from sklearn.tree import DecisionTreeClassifier
from sklearn.metrics import classification_report
from sklearn.model_selection import train_test_split
x_train,x_test,y_train,y_test = train_test_split(data,labels,test_size=0.25)
x_train,x_test,y_train,y_test
model_1 = GaussianNB()
model_1.fit(x_train,y_train)
model_2 = DecisionTreeClassifier()
model_2.fit(x_train,y_train)
y_predict_1 = model_1.predict(x_test)
y_predict_1
array([0, 2, 0, 2, 2, 2, 0, 0, 1, 0, 2, 2, 0, 1, 1, 0, 2, 1, 0, 1, 1, 2,
0, 0, 0, 0, 1, 2, 1, 2, 0, 2, 1, 0, 1, 1, 2, 2])
y_predict_2 = model_2.predict(x_test)
y_predict_2
array([0, 2, 0, 2, 2, 2, 0, 0, 1, 0, 2, 2, 0, 1, 2, 0, 2, 1, 0, 1, 1, 2,
0, 0, 0, 0, 1, 2, 1, 2, 0, 2, 1, 0, 1, 1, 2, 2])