# Create first network with Keras
from keras.models import Sequential
from keras.layers import Dense
import numpy
from keras.utils import np_utils

# load pima indians dataset
dataset = numpy.loadtxt("FB_categories_similarities.txt", delimiter=",")

# split into input (X) and output (Y) variables
X1 = dataset[:,0]
X2 = dataset[:,1]
x1_cat = np_utils.to_categorical(X1)
x2_cat = np_utils.to_categorical(X2)
X = numpy.column_stack((X1, X2))
Y = dataset[:,2]

# Reconvertimos para una mejor precision
Y[Y == 0.25] = 0
Y[Y == 0.5] = 1
Y[Y == 0.75] = 1

# create model
model = Sequential()
model.add(Dense(12, input_dim=2, init='uniform', activation='relu'))
model.add(Dense(8, init='uniform', activation='relu'))
model.add(Dense(20, init='uniform', activation='relu'))
model.add(Dense(12, init='uniform', activation='relu'))
model.add(Dense(1, init='uniform', activation='sigmoid'))

# Compile model
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])

# Fit the model
model.fit(X, Y, nb_epoch=200, batch_size=50,  verbose=2)
