Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
# -*- coding: utf-8 -*-
"""
Created on Thu Oct 29 16:22:11 2020
@author: jaych
"""
#%%
#print("test")
import time
start = time.time()
import tensorflow as tf
#assert tf.__version__ >= "2.0"
# Common imports
import numpy as np
import os
#import numpy as np
from numpy import loadtxt
from keras.models import Sequential
from keras.layers import Dense
# to make this notebook's output stable across runs
np.random.seed(42)
# To plot pretty figures
#%matplotlib inline
import matplotlib as mpl
import matplotlib.pyplot as plt
# mpl.rc('axes', labelsize=14)
# mpl.rc('xtick', labelsize=12)
# mpl.rc('ytick', labelsize=12)
#%%
dataset = loadtxt('pima-indians-diabetes.csv.txt', delimiter=',')
print(dataset.shape)
X = dataset[:,0:8]
y = dataset[:,8]
#%%
# define the keras model
model = Sequential()
model.add(Dense(12, input_dim=8, activation='relu'))
model.add(Dense(8, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
#%%
model.fit(X, y, epochs=1000, batch_size=10)
#evaluate the keras model
_, accuracy = model.evaluate(X, y)
print('Accuracy: %.2f' % (accuracy*100))
model1 = Sequential()
model1.add(Dense(12, input_dim=8, activation='relu'))
model1.add(Dense(8, activation='relu'))
model1.add(Dense(1, activation='sigmoid'))
model1.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
#%%
model1.fit(X, y, epochs=3000, batch_size=10)
#evaluate the keras model
_, accuracy = model.evaluate(X, y)
print('Accuracy: %.2f' % (accuracy*100))
#%%
end = time.time()
print(f"Runtime of the program is {end - start}")