################################################################################
################################################################################
#   IA 2022-2023
################################################################################
################################################################################

import numpy as np, numpy.linalg as alg
import idx2numpy
import matplotlib.pyplot as plt

################################################################################
#   BASE MNIST
################################################################################

imagefile = 'train-images.idx3-ubyte'
imagearray = idx2numpy.convert_from_file(imagefile)
labelfile=  'train-labels.idx1-ubyte'
labelarray = idx2numpy.convert_from_file(labelfile)

print("Image MNIST indice 4 :")
print(labelarray[4])
plt.imshow(imagearray[4], cmap=plt.cm.binary)
plt.show()

################################################################################
#   KNN
################################################################################


def majo(L):
    # A COMPLETER
    pass

def knn(k,X,A):
    # A COMPLETER
    pass


################################################################################
#   RECONNAISSANCE DE CARACTERES
################################################################################


k=11
t_mean_reco=[]
tn=[50,100,200,500,1000,2000,4000,5000]
for n in tn:
    t_knn=[]
    # A COMPLETER
    t_mean_reco.append(np.mean(t_knn))

plt.plot(tn,t_mean_reco)
plt.xlabel("Taille de la base d'apprentissage")
plt.ylabel("Taux de reconnaissnance")
plt.show()



