Neural Network and deep-learning are the buzzwords lately. Machine learning has been in vogue for some time, but the easy availability of storage and processing power has made it popular. The interest is palpable in business schools as well. The ML related techniques have not percolated much from the IT departments to business, but everybody seems to be interested. So, let us build a Neural Network model in 10 minutes.

Computer Programming

This is the scenario:

You have a collection of independent variables (IV) that predict a dependent variable (DV). You have a theoretical model and want to know if it is good enough. Remember, we are not testing the model. We are just checking how good the IVs are in predicting DV. If they are not good predictors to start with, why waste time conjuring a fancy model! Sounds familiar? Let’s get started.


Do you have some preliminary knowledge of python? If not spend another 10 minutes here learning python. Now you have to spend some time to set up your system once. Just follow these instructions.


The first step is to import few modules. If you don’t know what these are, just copy paste and ignore. Consider them as a header that you require.

Create a CSV file with your data with the last column as your DV. Now import that file.

nrows and ncols are the numbers of rows and columns. Now separate DV (y) from IVs (X) as below.

In most cases, you will be trying to predict a rare event. So add some oversampling for taste 🙂

Create, compile and fit the model.

The three model.add statements represent the three layers in Neural Network. The number after Dense is the number of neurons in each layer. You can play with these values a bit. These settings should work in most business cases. Read this for more information.

Now evaluate the model.

Put this code in a file (say and use it as below.


Just use QRMine. is in there.

Operationalizing Neural Network models

Shortly, I will show you how to operationalize a model using flask.

Follow Me

Bell Eapen

Techie Dermatologist, Programmer geek,Information Systems Ph.D. candidate, OpenMRS supporter, armchair philosopher, loves Canadian wine and beer,believes in coding to save lives. [Resume]
Follow Me