Exemplo n.º 1
0
def getPerformance(classifier, domain, testFiles, means, vars):
    correct = 0
    weightedDiff = 0
    total = 0
    for testFile in testFiles:
        f = open(testFile, "r")
        lines = f.readlines()
        f.close()
        context = ConvertData.readContext(lines)
        blockList = ConvertData.getBlockList(lines, context)
        decisions = []
        for _ in range(len(blockList)):
            shotClass = classification(classifier,context,blockList,domain,decisions,means, vars,shot=True)
            correctClass = orange.Value(blockList[-1][-1].shot,domain.class_var)
            #shotClass, correctClass = classify(classifier, testFile, domain, decisions, means, vars)
            decisions.append(shotClass)
            if correctClass == shotClass:
                correct += 1
            weightedDiff += getDifference(shotClass, correctClass)
            total += 1
    return float(correct)/ total, float(weightedDiff) / total