Ejemplo n.º 1
0
    def testCalcBasics(self):
        settings = {}
        settings["apiKey"] = "xxx"
        settings["algoSingle"] = "userName/algoName"
        settings["inputSingle"] = "an input"

        b = Benchmark(settings)

        b.results = [{"result": 5, "label": 5}, {"result": 7, "label": 7},\
                     {"result": 5, "label": 5}, {"result": 1, "label": 7},\
                     {"result": 3, "label": 5}, {"result": 7, "label": 7},\
                     {"result": 5, "label": 5}, {"result": 4, "label": 7},\
                     {"result": 4, "label": 5}, {"result": 7, "label": 7}]

        def mapFunc(res):
            return res

        b.calcStats(mapFunc)

        assert b.stats["FN"]["labels"][5] == 2
        assert b.stats["FN"]["labels"][7] == 2
        assert b.stats["FP"]["labels"][5] == 0
        assert b.stats["FP"]["labels"][7] == 0
        assert b.stats["TN"]["labels"][5] == 5
        assert b.stats["TN"]["labels"][7] == 5
        assert b.stats["TP"]["labels"][5] == 3
        assert b.stats["TP"]["labels"][7] == 3
Ejemplo n.º 2
0
    def testCalcFScore(self):
        settings = {}
        settings["apiKey"] = "xxx"
        settings["algoSingle"] = "userName/algoName"
        settings["inputSingle"] = "an input"

        b = Benchmark(settings)

        b.results = [{"result": 5, "label": 5}, {"result": 7, "label": 7},\
                     {"result": 5, "label": 5}, {"result": 1, "label": 7},\
                     {"result": 3, "label": 5}, {"result": 7, "label": 7},\
                     {"result": 5, "label": 5}, {"result": 4, "label": 7},\
                     {"result": 4, "label": 5}, {"result": 7, "label": 7}]

        def mapFunc(res):
            return res

        b.calcStats(mapFunc)

        assert b.stats['fScore']['labels'][5] == 0.7499999999999999
        assert b.stats['fScore']['labels'][7] == 0.7499999999999999