Guest User

Untitled

a guest
Jan 19th, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. # Create your first MLP in Keras
  2. from keras.models import Sequential
  3. from keras.layers import Dense
  4. import numpy
  5. # fix random seed for reproducibility
  6. numpy.random.seed(7)
  7. # load pima indians dataset
  8. dataset = numpy.loadtxt("pima-indians-diabetes.data.csv", delimiter=",")
  9. # split into input (X) and output (Y) variables
  10. X = dataset[:,0:8]
  11. Y = dataset[:,8]
  12. # create model
  13. model = Sequential()
  14. model.add(Dense(12, input_dim=8, activation='relu'))
  15. model.add(Dense(8, activation='relu'))
  16. model.add(Dense(1, activation='sigmoid'))
  17. # Compile model
  18. model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
  19. # Fit the model
  20. model.fit(X, Y, epochs=150, batch_size=10)
  21. # evaluate the model
  22. scores = model.evaluate(X, Y)
  23. print("\n%s: %.2f%%" % (model.metrics_names[1], scores[1]*100))
Add Comment
Please, Sign In to add comment