# -*- coding: utf-8 -*-
"""
Created on Fri Oct  9 17:37:24 2020

@author: Samuel Osorio Gutiérrez
"""
import LDA
import numpy as np
from time import time
np.random.seed(1234)


#base de datos de prueba
from sklearn.datasets import load_digits,load_iris, load_wine, load_breast_cancer
from sklearn.model_selection import train_test_split

iris=load_iris()
wine=load_wine()
digits=load_digits()
breast_cancer=load_breast_cancer()
#features_train, features_test, targets_train, targets_test=train_test_split(iris['data'],  iris['target'])
features_train, features_test, targets_train, targets_test=train_test_split(wine['data'],  wine['target'])
#features_train, features_test, targets_train, targets_test=train_test_split(digits['data'],  digits['target'])
#features_train, features_test, targets_train, targets_test=train_test_split(breast_cancer['data'],  breast_cancer['target'])


t_inicial=time()
S_inv,m_k,pi_k=LDA.train(features_train,targets_train, pLDA=True,Terminal=False)
t_final=time()
print("\nTiempo de entrenamiento con " + str(features_train.shape[0]) + " muestras: " + str((t_final-t_inicial)*1000) + " ms")
prediction=LDA.classification(S_inv,m_k,pi_k,features_train)
acc=LDA.accuracy(prediction,targets_train)
print("\nExactitud en el conjunto de entrenamiento: " + str(acc*100) + " %")
t_inicial=time()
prediction=LDA.classification(S_inv,m_k,pi_k,features_test)
t_final=time()
acc=LDA.accuracy(prediction,targets_test)
print("\nExactitud en el conjunto de prueba: " + str(acc*100) + " %")
print("\nTiempo de clasificación (una muestra): " + str((t_final-t_inicial)*1000/features_test.shape[0]) + " ms")

