예제 #1
0
    def run_diagnose(self):

        standards = serial.objFromFile('prob_groups.txt')

        c = ClusterBridge()
        name_net = c.getNameNet()

        for thres in range(1, 10):
            # Experimental
            def lengthFilter(triplet):
                names = triplet[1]
                return len(names) == thres

            filtered_net = filter(lengthFilter, name_net)
            # Experimental-end

            observed = gstat.convertNameNet2Observed(filtered_net)
            prediction = matchstat.convertObserved2Prediction(standards, observed)

            # Format becomes:
            # [(true1, true2,...), (predict1, predict2, ...), (meta1, meta2, ...)]
            pairs = matchstat.unzipGroupPrediction(prediction)

            num_label = 4
            tester = tests.tester(num_label)
            assert(len(pairs) >= 2)     # sanity check
            tester.record(pairs[0], pairs[1])
            tester.recordMeta(pairs[2])

            #print thres
            print "Accuracy:", tester.accuracy()
            print "Conf matrix:"
            print tester.confusionMatrix(friends.groupToNumeric)
예제 #2
0
    def run(self):
        standards = serial.objFromFile('prob_groups.txt')

        c = ClusterBridge()
        name_net = c.getNameNet()

        observed = gstat.convertNameNet2Observed(name_net)
        prediction = matchstat.convertObserved2Prediction(standards, observed)

        # Format becomes:
        # [(true1, true2,...), (predict1, predict2, ...), (meta1, meta2, ...)]
        pairs = matchstat.unzipGroupPrediction(prediction)

        num_label = 4
        tester = tests.tester(num_label)
        assert(len(pairs) >= 2)     # sanity check
        tester.record(pairs[0], pairs[1])
        tester.recordMeta(pairs[2])

        #print thres
        print "Accuracy:", tester.accuracy()
        print "Conf matrix:"
        print tester.confusionMatrix(friends.groupToNumeric)