Ejemplo n.º 1
0
    def test_binary_probabilities(self):
        inner_est = DummyProbEstimator(2)
        est = BinaryProbabilities(inner_est)

        # test attr wrap
        self.assertEqual(est._coefs, inner_est._coefs)

        preds = est.predict(self.data.values)
        self.assertEqual(preds.shape, (10,))
Ejemplo n.º 2
0
    def test_sklearn_probabilities(self):
        # test multi-class
        self.data['target'] = [0] * 5 + [1] * 3 + [2] * 2
        inner_est = linear_model.LogisticRegression()
        est = wrap_sklearn_like_estimator(inner_est)
        x = self.data[['a', 'b']]
        est.fit(x, self.data.target)
        preds = est.predict(x)
        self.assertEqual(preds.shape, (10, 3))

        # test binary, single output
        self.data['target'] = [0] * 5 + [1] * 5
        est = BinaryProbabilities(inner_est)
        x = self.data[['a', 'b']]
        est.fit(x, self.data.target)
        preds = est.predict(x)
        self.assertEqual(preds.shape, (10, ))
Ejemplo n.º 3
0
    def test_sklearn_probabilities(self):
        # test multi-class
        self.data['target'] = [0] * 5 + [1] * 3 + [2] * 2
        inner_est = linear_model.LogisticRegression()
        est = wrap_sklearn_like_estimator(inner_est)
        x = self.data[['a', 'b']]
        est.fit(x, self.data.target)
        preds = est.predict(x)
        self.assertEqual(preds.shape, (10, 3))

        # test binary, single output
        self.data['target'] = [0] * 5 + [1] * 5
        est = BinaryProbabilities(inner_est)
        x = self.data[['a', 'b']]
        est.fit(x, self.data.target)
        preds = est.predict(x)
        self.assertEqual(preds.shape, (10, ))