Advertisement
Guest User

Untitled

a guest
May 23rd, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.87 KB | None | 0 0
  1. # Create first network with Keras
  2. from keras.models import Sequential
  3. from keras.layers import Dense
  4. import numpy
  5. # fix random seed for reproducibility
  6. seed = 7
  7. numpy.random.seed(seed)
  8. # load pima indians dataset
  9. dataset = numpy.loadtxt("pima-indians-diabetes.csv", delimiter=",")
  10. # split into input (X) and output (Y) variables
  11. X = dataset[:,0:8]
  12. Y = dataset[:,8]
  13. # create model
  14. model = Sequential([
  15. Dense(12, input_dim=8, init='uniform', activation='relu'),
  16. Dense(8, init='uniform', activation='relu'),
  17. Dense(1, init='uniform', activation='sigmoid')])
  18. # Compile model
  19. model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
  20. # Fit the model
  21. model.fit(X, Y, epochs=15000, batch_size=10000, verbose=1)
  22. # calculate predictions
  23. predictions = model.predict(X)
  24. # round predictions
  25. rounded = [round(x[0]) for x in predictions]
  26. print(rounded)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement