pima-diabetes.csv
file in the ./data/
folder.Diabetes
knowing all the input variables?from google.colab import files
uploaded = files.upload()
import pandas as pd
data = pd.read_csv('pima-diabetes.csv', delimiter=',')
data.head()
import numpy as np
# Use np.loadtxt() instead when there are non-numeric values as well
dataset = np.genfromtxt('pima-diabetes.csv', delimiter=",", skip_header = True)
np.set_printoptions(precision = 2) # does not work for too wide array
np.set_printoptions(formatter = {'float': '{: 0.1f}'.format})
print('')
print(dataset.shape)
print('')
print(dataset[0:5])
X = dataset[:, :-1]
Y = dataset[:, -1]
mean = X.mean(axis=0)
X -= mean
std = X.std(axis=0)
X /= std
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense
model = Sequential()
model.add(Dense(8, input_dim = len(X[0, :]), activation='relu'))
model.add(Dense(4, activation='relu'))
model.add(Dense(1, activation='sigmoid'))
What is the total parameters? How?
model.summary()
from tensorflow.keras.utils import plot_model
plot_model(model, show_layer_names=True, show_shapes=True)
model.compile(loss='binary_crossentropy', optimizer = 'rmsprop', metrics=['accuracy'])
model.fit(X, Y, epochs = 256, verbose = 1)
print ('True Validation Data:')
print(Y[:10])
prediction = model.predict(X)
print ('Prediction:')
print(prediction[0:10].T)
from sklearn.metrics import accuracy_score, precision_score, recall_score, f1_score
accuracy = accuracy_score(Y, prediction.round())
precision = precision_score(Y, prediction.round())
recall = recall_score(Y, prediction.round())
f1score = f1_score(Y, prediction.round())
print("Accuracy: %.2f%%" % (accuracy * 100.0))
print("Precision: %.2f%%" % (precision * 100.0))
print("Recall: %.2f%%" % (recall * 100.0))
print("F1-score: %.2f" % (f1score))