# TP 2 TS326
import numpy as np
import matplotlib.pyplot as plt
from sklearn import datasets
from sklearn.model_selection import StratifiedShuffleSplit
from sklearn.svm import SVC
from sklearn.metrics import accuracy_score

plt.close('all')

# Lecture des données d'apprentissage
XA = np.load('X_apprentissage.npy').astype('float32')
YA = np.load('Y_apprentissage.npy').astype('int64')
NbAttributs = 15
XA = XA[:, 0:NbAttributs]
NA = XA.shape[0] #Nombre d'échantillons d'apprentissage
Classes = np.unique(YA)
Nb_classes = np.unique(YA).shape[0] #Nombre de classes

#% Lecture des données de test                            
XT = np.load('X_test.npy').astype('float32')
YT = np.load('Y_test.npy').astype('int64')
XT = XT[:, 0:NbAttributs]
NT = XT.shape[0] # Nombre d'échantillons de test

#SVM
# define the SVM classifier with a Radial Basis Function (RBF) kernel (SVC) 

# train the classifier and keep track of the time for training (fit)

#prediction over test data

#evlauation of the performance (accuracy_score)

#matrice de confusion

#%% On Olivetti face dataset

faces = datasets.fetch_olivetti_faces()

im = faces.data[0].reshape(64, 64)
plt.figure()
plt.imshow(im)
plt.show()
print(faces.data.shape)

X = faces["data"]
imgs = faces["images"]
y = faces["target"]


# split data randomly into train & test sets by preserving train/test ratio across classes (StratifiedShuffleSplit)

# get the train and test indexes (next)


# split X and y into train & test sets


# define the SVM classifier with a Radial Basis Function (RBF) kernel (SVC)

# train the classifier and keep track of the time for training.

#prediction over test data

#evlauation of the performance





