import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
from util import *
from ann import *
from sklearn.metrics import confusion_matrix
from sklearn.model_selection import KFold

# def load_data():
#     dataset = pd.read_csv("data/features_30_sec.csv")
#     X = dataset.iloc[:, 1:59].values
#     y = dataset.iloc[:, 59].values

#     #importing the dataset
#     from sklearn.model_selection import train_test_split
#     X_train, X_test = train_test_split(X, test_size=0.25, random_state= 0)
#     y_train, y_test = train_test_split(y, test_size=0.25, random_state= 0)

#     #splitting our data set into training set and test set
#     from sklearn.model_selection import train_test_split
#     X_train, X_test = train_test_split(X, test_size=0.25, random_state= 0)
#     y_train, y_test = train_test_split(y, test_size=0.25, random_state= 0)

#     #feature scaling
#     from sklearn.preprocessing import StandardScaler
#     sc_X = StandardScaler()
#     X_train = sc_X.fit_transform(X_train)
#     X_test = sc_X.transform(X_test)

#     return X_train, X_test, y_train, y_test
    
# def get_accuracy(cm):
#     sum = 0
#     for i in range(cm.shape[0]):
#         sum = sum + cm[i][i]
#     return 100*(sum/np.sum(cm))

# def fit_predict_print(fit_predict_function, X_train, y_train, X_test, y_test):
#     y_pred = fit_predict_function(X_train, y_train, X_test)
#     cm = confusion_matrix(y_test, y_pred)
#     #print(cm)
#     print(get_accuracy(cm))

X_train, X_test, y_train, y_test = load_scale_xy_with_25p_split()
X, y = load_preprocess_xy(0, True, True, True)

kf=KFold(n_splits=5)

for train_index,test_index in kf.split(X):
  X_train,X_test,y_train,y_test=X[train_index],X[test_index],y[train_index],y[test_index]
  fit_predict_print(nn_fit_predict,X_train,y_train,X_test,y_test)

# y_pred = rf_fit_predict(X_train, y_train, X_test)
# cm = confusion_matrix(y_test, y_pred)
# #print(cm)
# print(get_accuracy(cm))

# fit_predict_print(randomized_search_cv_rf_fit_predict, X_train, y_train, X_test, y_test)

#fit_predict_print(randomized_search_cv_rf_fit_predict, X_train, y_train, X_test, y_test)

# fit_predict_print(rf_fit_predict, X_train, y_train, X_test, y_test)

# y_pred = randomized_search_fold_size_rf_fit_predict(X_train, y_train, X_test)
pass
#fit_predict_print(nn_fit_predict, X_train, y_train, X_test, y_test)

# cm = confusion_matrix(y_test, y_pred)
# #print(cm)
# print(get_accuracy(cm))



# plt.matshow(cm)
# plt.show()





pass
