In [ ]:
#Import essential packages
import pandas as pd
from keras.models import Sequential
from keras.layers import Dense
from sklearn.model_selection import train_test_split
from sklearn.metrics import accuracy_score

#Read in data from the UCI machine learning repository and give the columns the proper names
data = pd.read_csv('https://archive.ics.uci.edu/ml/machine-learning-databases/00267/data_banknote_authentication.txt',
	names = ['variance', 'skewness', 'curtosis', ' entropy', 'class'])

#Split the data into train and testing sets with a 80/20 split
train, test = train_test_split(data, test_size=0.2)
train_x = train.loc[['variance', 'skewness', 'curtosis', ' entropy']]
train_y = train.loc[:,'class']

test_x = test.loc[['variance', 'skewness', 'curtosis', ' entropy']]
test_y = test.loc[:,'class']

#Initialize a sequential Keras neural net model
model = Sequential()
#First hidden layer will have 6 neurons and expects 4 inputs (the 5 columns we read in minus the class)
model.add(Dense(6, input_dim=4, activation='relu'))
model.add(Dense(4, activation='relu'))
model.add(Dense(1, activation='sigmoid'))

#Last layer is a binary prediction layer
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])

#train the network
model.fit(train_x, train_y, epochs=10,batch_size=10, verbose=1)

#predict the classes and print out how well we did
ynew = model.predict_classes(test_x)
print(accuracy_score(ynew,test_y))