def compareAlgorithmsWithData(testCases): global algosToTest, data, headers, testOutputFilename allResults = {} for key in algosToTest.keys(): allResults[key] = [] for companyName in sorted(testCases.keys()): print('Testing ' + companyName) data, headers = para.readFile(display.nameToFile(companyName)) for key in sorted(algosToTest.keys()): #print(' algo ' + key) for target in testCases[companyName]: algo = algosToTest[key] result = testAlgo(algo, target) if result != None: allResults[key].append(result) #printResult(key, result) averageResults = {} f = open(testOutputFilename, 'w+') for key in allResults.keys(): averageResult = computeAverageResult(allResults[key]) s = formatResult(key, averageResult) f.write(s+'\n') f.close()
def testAlgorithmsForAverageScore(testCases, weightDict): allResults = [] weightDataFun = weightedData(weightDict) for companyName in testCases.keys(): #print('Testing ' + companyName) data, headers = para.readFile(display.nameToFile(companyName)) for key in algosToTest.keys(): #print(' algo ' + key) algo = algosToTest[key] for target in testCases[companyName]: result = testAlgoWeighted(algo, target, weightDataFun, data) if result != None: allResults.append(result) averageResult = testalgos.computeAverageResult(allResults) return averageResult[2] # Maximise the amount of return alone.