Exemple #1
0
 def get_error(self, data_set: DataSet):
     squared_sum = 0
     # Sum up the squared sup across all squared differences between the actual class value and the expected value.
     for example_array, expected_class in data_set.get_data():
         output = self.run(example_array)
         squared_sum += (output - expected_class)**2
     return math.sqrt(squared_sum) / len(data_set.get_data())
Exemple #2
0
 def get_accuracy(self, data_set: DataSet):
     correct = 0
     # Sum the number of correctly classified examples.
     for example_array, expected_class in data_set.get_data():
         output = self.run(example_array)
         if output == expected_class:
             correct += 1
     # Divide the number of correct examples by the total number of examples.
     return correct / len(data_set.get_data())