Keras is a powerfulΒ easy-to-use Python library for developing and evaluatingΒ deep learningmodels.

It wraps the efficient numerical computation libraries Theano and TensorFlow and allows you to define and train neural network models in a few short lines of code.

Β

System Requirements :

Python 3 .6

TensofFlow

Keras

Dataset :

Pima Indians onset of diabetes dataset from UCI datasets respository

Β

Code :

Β

#1. Import Libraries

from keras.models import Sequential

from keras.layers import Dense

import numpy

import os

# fix random seed for reproducibility

numpy.random.seed(7)

os.chdir("D://DeepLearning//FirstExampleWithKeras//")

print(os.getcwd())

#2. load pima indians dataset

dataset = numpy.loadtxt("pima-indians-diabetes.data.txt", delimiter=",")

print(type(dataset))

# split into input (X) and output (Y) variables

X = dataset[:,0:8]

Y = dataset[:,8]

Β

#3. create model

model = Sequential()

model.add(Dense(12, input_dim=8, activation='relu'))

model.add(Dense(8, activation='relu'))

model.add(Dense(1, activation='sigmoid'))

Β

#4. Compile model

model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])

Β

#5. Fit the model

model.fit(X, Y, epochs=150, batch_size=10)

Β

#6. evaluate the model

scores = model.evaluate(X, Y)

print("\n%s: %.2f%%" % (model.metrics_names[1], scores[1]*100))

Β

Explaination :

The code is divided into following steps -

1. Load Data.

2. Define Model.

3. Compile Model.

4.Β Fit Model.

5.Β Evaluate Model.

Β

Reference :

https://machinelearningmastery.com/tutorial-first-neural-network-python-keras/

##### About Author

Dattatray Shinde have over 6+ years of experience in Software Design, Development & Maintenance of Web Based Applications; worked on Healthcare, Insurance, E-commerce and Learning Management System domains. Over 2.5 + years as Data Scientist worked mainly in predictive analytics, survey analytics, risk analytics platforms.