# -*- coding: utf-8 -*-
"""
Created on Tue Oct 15 12:51:32 2019

@author: Cian
"""


# first neural network with keras make predictions
from numpy import loadtxt
from keras.models import Sequential
from keras.layers import Dense
# load the dataset
dataset = loadtxt('breastCancerDataset.csv', delimiter=',')
# split into input (X) and output (y) variables
X = dataset[:,0:5]
y = dataset[:,5]
# define the keras model
model = Sequential()
model.add(Dense(12, input_dim=5, activation='relu'))
model.add(Dense(8, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
# compile the keras model
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
# fit the keras model on the dataset
model.fit(X, y, epochs=150, batch_size=10, verbose=1)
# make class predictions with the model
predictions = model.predict_classes(X)
# summarize the first 5 cases
for i in range(100):
	print('%s => %d (expected %d)' % (X[i].tolist(), predictions[i], y[i]))
model.save("breast_model.h5")
print("Saved model to disk")
# evaluate the model
scores = model.evaluate(X, y, verbose=0)
print("%s: %.2f%%" % (model.metrics_names[1], scores[1]*100))