X

Blogs about Deep Learning, Machine Learning, AI, NLP, Security, Oracle Traffic Director,Oracle iPlanet WebServer

  • January 31, 2018

Simple Neural Network Model using Keras and Grid Search HyperParametersTuning

In this blog, I have explored using Keras and GridSearch and how we can automatically run different Neural Network models by tuning  hyperparameters (like epoch, batch sizes etc.).

I have used Jupyter Notebook for development.

Data set is UCI Cerdit Card Dataset which is available in csv format. Download the dataset from Kaggle https://www.kaggle.com/uciml/default-of-credit-card-clients-dataset  Description of fields is in https://archive.ics.uci.edu/ml/datasets/default+of+credit+card+clients

First step is to import relevant packages and load CSV file contents into dataframe. Check the shape of the data frame and inspect the column names.

1-keras

The output shown below

1out--keras

Dataset has 30000 records and 25 columns. We know that "ID" column is not relevant for modelling so we can remove it. We have put rest of the columns into an array called "X". The output is in column name "default.payment.next.month" so save it in variable called "Y".

2-keras

We have a function to create a model. For now I have used simple parameters. But we can fine tune it by adding more layers etc.

 

2.5-kerasthen we create a model and try to set some parameters like epoch, batch_size in the Grid Search.

3-keras

As we can see from the output window that above various combinations of epoch and batch_sizes were run. For now I have kept epoch very small because it was taking time. We should test higher values also.

We try to figure out when we get the best scores

4-keras

As you can see in the output given above the best score we got was when we use epoch 1 and batch size of 5000. We can try different parameters like different values of activation functions, momentum, learning rates, drop out rates, weight constraints, number of neurons, initializers, optimizer functions.

Full code is available here

Simplest kera code for MNIST dataset is here

Coding is very simple and easier if you use keras package.

I have posted this blog here as well.

References

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.