def test_misclassified(self): data = readAllData(SHORT_FILE_NAME) average = computeAverageForClasses(data) misclasified = misclassified(data) result_data = [('15.24850737', 'NO'), ('13.195037', 'NO')] self.assertEqual(misclasified, result_data)
def test_compute_average_for_classes_complete_final(self): data = readAllData(COMPLETE_FINAL_FILE_NAME) average = computeAverageForClasses(data) result_data = { 'YES': 10.287209574866667, 'NO': 20.240770106972597, 'OK': 97.84553928928842 } self.assertEqual(average, result_data)
from functions import readAllData, computeAverageForClasses, misclassified # file name FILE_NAME = 'short_data.txt' #read data data = readAllData(FILE_NAME) # average average = computeAverageForClasses(data) print('Average:') print(average) # misclassified misclasified = misclassified(data) print('Misclassified:') print(len(misclasified)) # file write write_data = [ f'{m[0]}\t{m[1]}' for m in misclasified ] f = open("Misclassified.txt", "w") f.write('\n'.join(write_data)) f.close()
def test_misclassified_complete_final(self): data = readAllData(COMPLETE_FINAL_FILE_NAME) average = computeAverageForClasses(data) misclasified = misclassified(data) self.assertEqual(len(misclasified), 36)
def test_compute_average_for_classes_complete(self): data = readAllData(COMPLETE_FILE_NAME) average = computeAverageForClasses(data) result_data = {'YES': 11.016275211379998, 'NO': 19.25457457829} self.assertEqual(average, result_data)
def test_compute_average_for_classes(self): data = readAllData(SHORT_FILE_NAME) average = computeAverageForClasses(data) result_data = {'YES': 12.654788940000001, 'NO': 19.13054132285714} self.assertEqual(average, result_data)