# -*- coding: utf-8 -*-
"""Practica5.ipynb

Automatically generated by Colaboratory.

Original file is located at
    https://colab.research.google.com/drive/1rMwuSrLy1k8SPMWucKBP-VOLh2egYlNN
"""

import sklearn
import numpy as np
import pandas as pd
import seaborn as sns
import matplotlib as mpl
import matplotlib.pyplot as plt
from sklearn.datasets import load_iris
from sklearn.model_selection import train_test_split
from sklearn.metrics import confusion_matrix
from sklearn.metrics import accuracy_score
#Librerias para funciones
from sklearn.naive_bayes import MultinomialNB
from sklearn.naive_bayes import GaussianNB
from sklearn.metrics import plot_confusion_matrix

#Modelando arbol de decision y dividiendo dataset
iris = load_iris()
X = iris.data[:,:4]
y = iris.target
X_train,X_test,y_train,y_test = train_test_split(X, y, test_size=0.25, random_state=25)

#GaussianNB
classifier = GaussianNB()
classifier.fit(X_train, y_train)
y_pred = classifier.predict(X_test)
#Prediccion 
acurracy = accuracy_score(y_test, y_pred)
print("Precision GaussianNB : ", acurracy)
#Creando matriz de confusion
ConfMtx = confusion_matrix(y_test, y_pred)
print("Matriz Confusion GaussianNB: ",ConfMtx)

# Grafica ilustrada 
plot_confusion_matrix(classifier, X_test, y_test)  
plt.show()

#MultinomialDB
classifier = MultinomialNB()
classifier.fit(X_train, y_train)
y_pred = classifier.predict(X_test)
#Prediccion 
acurracy = accuracy_score(y_test, y_pred)
print("Precision MultinomialNB : ", acurracy)
#Creando matriz de confusion
ConfMtx = confusion_matrix(y_test, y_pred)
print("Matriz Confusion MultinomialNB: ",ConfMtx)

# Grafica ilustrada 

plot_confusion_matrix(classifier, X_test, y_test)  
plt.show()

