Skip to content

Instantly share code, notes, and snippets.

@michelkana
Last active July 18, 2019 16:07
Show Gist options
  • Save michelkana/93149b09b6be47e3658ba29422dfa725 to your computer and use it in GitHub Desktop.
Save michelkana/93149b09b6be47e3658ba29422dfa725 to your computer and use it in GitHub Desktop.
from keras.models import Sequential
from keras.layers import Dense
from sklearn.metrics import accuracy_score
model = Sequential()
model.add(Dense(1, activation = 'sigmoid', input_dim = 1))
model.compile(optimizer='sgd', loss='binary_crossentropy', metrics = ['acc'])
history = model.fit(x, y, batch_size=1, epochs=100, shuffle=True, verbose=0)
print("Classification accuracy: {0:0.2%}".format(accuracy_score(y, y_pred)))
plt.scatter(x,y, label='original data')
plt.scatter(x,y_pred, label='ANN prediction')
plt.xlabel('year')
plt.ylabel('harvest good/bad')
plt.title('classification')
plt.legend();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment