Exemplo n.º 1
0
    def test_correct_calls(self):
        """Test number and order of calls of the kernel function when computing the
        polarity, including computation of the diagonal kernel matrix entries."""
        X = [0.1, 0.4]
        Y = [1, -1]

        hist = []

        kern.polarity(X, Y, lambda x1, x2: _mock_kernel(x1, x2, hist))

        assert hist == [(0.1, 0.1), (0.1, 0.4), (0.4, 0.4)]
Exemplo n.º 2
0
    def test_correct_calls_normalized(self):
        """Test number and order of calls of the kernel function when computing the
        polarity, assuming normalized diagonal kernel matrix entries."""
        X = [0.1, 0.4]
        Y = [1, -1]

        hist = []

        kern.polarity(
            X, Y, lambda x1, x2: _mock_kernel(x1, x2, hist), assume_normalized_kernel=True
        )

        assert hist == [(0.1, 0.4)]
Exemplo n.º 3
0
    def test_polarity_value_other_labels(self):
        """Test value of polarity without class label rescaling (2/2)."""
        X = [0.1, 0.4]
        Y = [1, 1]
        pol = kern.polarity(
            X, Y, lambda x1, x2: _mock_kernel(x1, x2, []), rescale_class_labels=False
        )
        pol_assume = kern.polarity(
            X,
            Y,
            lambda x1, x2: _mock_kernel(x1, x2, []),
            assume_normalized_kernel=True,
            rescale_class_labels=False,
        )

        assert pol == 2.4
        assert pol == pol_assume