Created
July 6, 2018 05:03
-
-
Save spicyramen/64330a0b823044baa944a4cdfcdca1d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MLP with manual validation set | |
from keras.models import Sequential | |
from keras.layers import Dense | |
from sklearn.model_selection import train_test_split | |
import numpy as np | |
# fix random seed for reproducibility | |
seed = 7 | |
np.random.seed(seed) | |
# load pima indians dataset | |
FILENAME = '../data/pima-indians-diabetes.csv' | |
dataset = np.loadtxt(FILENAME, delimiter=',') | |
# split into input (X) and output (Y) variables | |
features = dataset[:, 0:8] | |
labels = dataset[:, 8] | |
# split into 67% for train and 33% for test | |
model = Sequential() | |
model.add(Dense(12, input_dim=8, kernel_initializer='uniform', activation='relu')) | |
model.add(Dense(8, kernel_initializer='uniform', activation='relu')) | |
model.add(Dense(1, kernel_initializer='uniform', activation='sigmoid')) | |
# Compile model | |
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy']) | |
# Fit the model | |
model.fit(features, labels, validation_split=0.33, epochs=150, batch_size=10) | |
model.summary() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment