Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Create first network with Keras
- from keras.models import Sequential
- from keras.layers import Dense
- import numpy
- # fix random seed for reproducibility
- seed = 7
- numpy.random.seed(seed)
- # load pima indians dataset
- dataset = numpy.loadtxt("pima-indians-diabetes.csv", delimiter=",")
- # split into input (X) and output (Y) variables
- X = dataset[:,0:8]
- Y = dataset[:,8]
- # create model
- model = Sequential([
- Dense(12, input_dim=8, init='uniform', activation='relu'),
- Dense(8, init='uniform', activation='relu'),
- Dense(1, init='uniform', activation='sigmoid')])
- # Compile model
- model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
- # Fit the model
- model.fit(X, Y, epochs=15000, batch_size=10000, verbose=1)
- # calculate predictions
- predictions = model.predict(X)
- # round predictions
- rounded = [round(x[0]) for x in predictions]
- print(rounded)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement