def test_network_and_plot_results(self): accuracy_results = [] for training_iterations in self.training_iterations_list: print "Testing network for " + str( training_iterations) + " iterations" # Initialise lists to store mean accuracy and standard error values mean_accuracies = [] standard_errors = [] # Iterates through the hidden layer sizes specified for hidden_layer_size in self.hidden_layer_sizes: # initialise list to store accuracy results accuracy_cache = [] print "Testing network with hidden layer size: " + str( hidden_layer_size) # The Neural network is trained and tested for the specified number of iterations for each # hidden layer size value for i in range(0, 10, 1): # Reinitialise dataset importer object csv_delegate = CSVFileDelegate(self.filepath) # Initialise Neural Network Classifier with data and target from data importer neural_network_classifier = NeuralNetworkClassifier( csv_delegate.training_data, csv_delegate.training_target) # Build and train network with <hidden_layer_size> nodes in the hidden layer neural_network_classifier.build_network( hidden_layer_size, training_iterations) # Use classifier to classify testing data results = neural_network_classifier.classify_set( csv_delegate.testing_data) # Compare results to testing target accuracy = self.compare_result_to_target( results, csv_delegate.testing_target) accuracy_cache.append(accuracy) print accuracy # Store the mean and standard error values for each set of results mean_accuracies.append((float(sum(accuracy_cache)) / 10)) standard_errors.append(scipy.stats.sem(accuracy_cache)) # Plot accuracy vs number of hidden nodes with the standard error plotter = ResultPlotter(self.hidden_layer_sizes, mean_accuracies, standard_errors, training_iterations, self.baseline_accuracy, ntpath.basename(self.filepath)) plotter.generate_plot_with_errors() accuracy_results.append(mean_accuracies) if plotter: plotter.generate_combined_plot(self.hidden_layer_sizes, accuracy_results, self.training_iterations_list)