예제 #1
0
    def test_pipeline_subclass_correctly_supports_decision_function(self):
        X, y = generate_dataset_1()

        pipeline = Pipeline([LogisticRegressionBinaryClassifier()])
        pipeline.fit(X, y)
        orig_result = pipeline.decision_function(X)

        pipeline = CustomPipeline([LogisticRegressionBinaryClassifier()])
        pipeline.fit(X, y)
        new_result = pipeline.decision_function(X)

        self.assertTrue(np.array_equal(orig_result, new_result))
예제 #2
0
    def test_pass_decision_function_multiclass_with_pipeline_adds_classes(
            self):
        clf = FastLinearClassifier(number_of_threads=1)
        pipeline = Pipeline([clf])
        pipeline.fit(X_train_3class, y_train_3class)

        expected_classes = {'Blue', 'Green', 'Red'}
        assert_equal(set(clf.classes_), expected_classes)
        assert_equal(set(pipeline.classes_), expected_classes)

        s = pipeline.decision_function(X_test_3class).sum()
        assert_almost_equal(s,
                            38.0,
                            decimal=4,
                            err_msg=invalid_decision_function_output)

        assert_equal(set(clf.classes_), expected_classes)
        assert_equal(set(pipeline.classes_), expected_classes)