ds = SemEvalData(blank=True) for j in range(num_folds): if j != i: ds = ds + datasets[j] input, tags, order = NeuralNet.format_dataset(ds, embedder) # Train the network. network = NeuralNet(hidden=128, layers=2, input=len(input[0]), output=2) # Train on non-test datasets. loss, accuracy = network.train(input, tags, iterations=100) accuracies += [accuracy] # Test on test dataset. test, _, order = NeuralNet.format_dataset(datasets[i], embedder) network_predictions.update(network.predict(test, order)) # Evaluate neural network. neural_cm = Evaluator.confidence_compare(dataset.tags, network_predictions) print("Neural Network Accuracy: " + str(round( Evaluator.accuracy(neural_cm)*100, 2)) + "%") # Save similarity measures to csv. with open(args.csv_file(), 'w') as writefile: writefile.write(embedder.to_csv(embed_predictions)) # Save neural network to csv. with open('output.csv', 'w') as writefile: writefile.write(NeuralNet.pred_to_csv(network_predictions))