def model_fit(x, y, n_neurons, n_epochs, n_batch_size, n_k_fold, reg):

    from sklearn.model_selection import KFold
    kfold = KFold(n_splits=n_k_fold, shuffle=False, random_state=None)
    cvscores = []
    from keras.initializers import glorot_uniform

    for train, test in kfold.split(x, y):
        model = Sequential()
        model.add(
            SimpleRNN(n_neurons,
                      activation='relu',
                      input_shape=(x.shape[1], x.shape[2]),
                      kernel_regularizer=reg))
        model.add(
            Dense(12,
                  activation="softmax",
                  kernel_initializer=glorot_uniform(
                      seed=set_fixed_random_seed(29))))
        model.compile(loss='binary_crossentropy',
                      optimizer='adam',
                      metrics=['accuracy'])

        #Fit the model
        model.fit(x[train], y[train], epochs=n_epochs, batch_size=n_batch_size)

        # Evaluate the model
        scores = model.evaluate(x[test], y[test], verbose=0)
        print("%s: %.2f%%" % (model.metrics_names[1], scores[1] * 100))
        cvscores.append(scores[1] * 100)
    return cvscores
import pandas as pd
import matplotlib.pyplot as plt
import itertools
from keras.models import Sequential
from keras import metrics
from keras.layers import Dense
from keras.layers import SimpleRNN
from keras.layers import LSTM
from keras.layers import GRU
from keras.regularizers import L1L2
from keras.callbacks import EarlyStopping
from keras.utils import np_utils
from numpy.random import seed
seed(29)
from cntk.cntk_py import set_fixed_random_seed
set_fixed_random_seed(98)

date = "20181031"

# Create Function to display confusion matrix
from sklearn.metrics import confusion_matrix


def plot_confusion_matrix(model,
                          n_epochs,
                          n_batch_size,
                          n_neurons,
                          cm,
                          classes,
                          normalize=False,
                          title='Confusion matrix',