classification_model = metrics.classification_report(expected, predicted)
confusion_model = metrics.confusion_matrix(expected, predicted)
accuracy_model = metrics.accuracy_score(expected, predicted)
print(classification_model)
print(confusion_model)
print("Accuracy NN with best parameters: ",accuracy_model)

#Save metrics
with open(save_report, "a") as text_file:
    text_file.write("\nAccuracy NN with best parameters: ")
    text_file.write(str(accuracy_model))
    text_file.write("\nClassification NN with best parameters:\n")
    text_file.write(classification_model)

#Save model
filename = os.path.join('models','NN_model_best.h5')
model.save(filename)

####################
# APPLY BEST MODEL #
####################

# load best SVM
loaded_model = pickle.load(open(os.path.join('models','SVM_model_best.sav'), 'rb'))
#predict
predicted = loaded_model.predict(features)
#add to dataframe
data['prediction'] = predicted
print(data)
data.to_csv(os.path.join('listPlaces','listPlaces_classified.tsv'), sep='\t', encoding='utf-8')