Beispiel #1
0
    def _test_label_model(self, data, test_acc=True, mts=False):
        if mts:
            label_model = LabelModel(data.m, task_graph=data.task_graph, 
                p=data.p, deps=data.E)
        else:
            label_model = LabelModel(data.m, k=data.k, p=data.p, deps=data.E)
        label_model.train(data.L, n_epochs=1000, print_every=200)
        
        # Test parameter estimation error
        c_probs_est = label_model.get_conditional_probs()
        err = np.mean(np.abs(data.c_probs - c_probs_est))
        print(f"Parameter Estimation Error={err}")
        self.assertLess(err, 0.015)

        # Test label prediction accuracy
        if test_acc:
            Y_pred = label_model.get_label_probs(data.L).argmax(axis=1) + 1
            acc = np.where(data.Y == Y_pred, 1, 0).sum() / data.n
            print(f"Label Prediction Accuracy={acc}")
            self.assertGreater(acc, 0.95)
Beispiel #2
0
    def _test_label_model(self, data, test_acc=True):
        label_model = LabelModel(k=data.k, verbose=False)
        label_model.train(
            data.L,
            deps=data.E,
            class_balance=data.p,
            n_epochs=1000,
            print_every=200,
        )

        # Test parameter estimation error
        c_probs_est = label_model.get_conditional_probs()
        err = np.mean(np.abs(data.c_probs - c_probs_est))
        self.assertLess(err, 0.025)

        # Test label prediction accuracy
        if test_acc:
            Y_pred = label_model.predict_proba(data.L).argmax(axis=1) + 1
            acc = np.where(data.Y == Y_pred, 1, 0).sum() / data.n
            self.assertGreater(acc, 0.95)
    def _test_label_model(self, data, test_acc=True):
        label_model = LabelModel(k=data.k, verbose=False)
        label_model.train_model(
            data.L,
            deps=data.E,
            class_balance=data.p,
            n_epochs=1000,
            log_train_every=200,
        )

        # Test parameter estimation error
        c_probs_est = label_model.get_conditional_probs()
        err = np.mean(np.abs(data.c_probs - c_probs_est))
        self.assertLess(err, 0.025)

        # Test label prediction accuracy
        if test_acc:
            score = label_model.score((data.L, data.Y), verbose=False)
            self.assertGreater(score, 0.95)

            # Test against baseline
            mv = MajorityLabelVoter()
            mv_score = mv.score((data.L, data.Y), verbose=False)
            self.assertGreater(score, mv_score)