def test_check_increasing_small_number_of_samples():
    x = [0, 1, 2]
    y = [1, 1.1, 1.05]

    with pytest.warns(None) as record:
        is_increasing = check_increasing(x, y)
    assert len(record) == 0

    assert is_increasing
Exemple #2
0
    def test_check_increasing(self):
        data = np.abs(np.random.randn(100))
        data = data.cumsum()
        df = pdml.ModelFrame(np.arange(len(data)), target=data)

        result = df.isotonic.check_increasing()
        expected = isotonic.check_increasing(np.arange(len(data)), data)
        self.assertTrue(result)
        self.assertTrue(expected)

        data = np.abs(np.random.randn(100))
        data = data.cumsum()[-1::-1]        # reverse
        df = pdml.ModelFrame(np.arange(len(data)), target=data)

        result = df.isotonic.check_increasing()
        expected = isotonic.check_increasing(np.arange(len(data)), data)
        self.assertFalse(result)
        self.assertFalse(expected)
Exemple #3
0
    def test_check_increasing(self):
        data = np.abs(np.random.randn(100))
        data = data.cumsum()
        df = pdml.ModelFrame(np.arange(len(data)), target=data)

        result = df.isotonic.check_increasing()
        expected = isotonic.check_increasing(np.arange(len(data)), data)
        self.assertTrue(result)
        self.assertTrue(expected)

        data = np.abs(np.random.randn(100))
        data = data.cumsum()[-1::-1]        # reverse
        df = pdml.ModelFrame(np.arange(len(data)), target=data)

        result = df.isotonic.check_increasing()
        expected = isotonic.check_increasing(np.arange(len(data)), data)
        self.assertFalse(result)
        self.assertFalse(expected)
def test_check_increasing_small_number_of_samples():
    x = [0, 1, 2]
    y = [1, 1.1, 1.05]

    with warnings.catch_warnings():
        warnings.simplefilter("error", UserWarning)
        is_increasing = check_increasing(x, y)

    assert is_increasing
Exemple #5
0
def test_check_increasing_small_number_of_samples():
    x = [0, 1, 2]
    y = [1, 1.1, 1.05]

    with pytest.warns(None) as record:
        is_increasing = check_increasing(x, y)
    assert not [w.message for w in record]

    assert is_increasing
def test_check_ci_warn():
    x = [0, 1, 2, 3, 4, 5]
    y = [0, -1, 2, -3, 4, -5]

    # Check that we got increasing=False and CI interval warning
    msg = "interval"
    with pytest.warns(UserWarning, match=msg):
        is_increasing = check_increasing(x, y)

    assert not is_increasing
def test_check_increasing_down_extreme():
    x = [0, 1, 2, 3, 4, 5]
    y = [0, -1, -2, -3, -4, -5]

    # Check that we got increasing=False and no warnings
    with pytest.warns(None) as record:
        is_increasing = check_increasing(x, y)
    assert len(record) == 0

    assert not is_increasing
def test_check_increasing_down():
    x = [0, 1, 2, 3, 4, 5]
    y = [0, -1.5, -2.77, -8.99, -8.99, -50]

    # Check that we got increasing=False and no warnings
    with pytest.warns(None) as record:
        is_increasing = check_increasing(x, y)
    assert len(record) == 0

    assert not is_increasing
def test_check_increasing_up_extreme():
    x = [0, 1, 2, 3, 4, 5]
    y = [0, 1, 2, 3, 4, 5]

    # Check that we got increasing=True and no warnings
    with pytest.warns(None) as record:
        is_increasing = check_increasing(x, y)
    assert len(record) == 0

    assert is_increasing
Exemple #10
0
def test_check_increasing_down_extreme():
    x = [0, 1, 2, 3, 4, 5]
    y = [0, -1, -2, -3, -4, -5]

    # Check that we got increasing=False and no warnings
    with warnings.catch_warnings():
        warnings.simplefilter("error", UserWarning)
        is_increasing = check_increasing(x, y)

    assert not is_increasing
Exemple #11
0
def test_check_increasing_down():
    x = [0, 1, 2, 3, 4, 5]
    y = [0, -1.5, -2.77, -8.99, -8.99, -50]

    # Check that we got increasing=False and no warnings
    with warnings.catch_warnings():
        warnings.simplefilter("error", UserWarning)
        is_increasing = check_increasing(x, y)

    assert not is_increasing
Exemple #12
0
def test_check_increasing_up_extreme():
    x = [0, 1, 2, 3, 4, 5]
    y = [0, 1, 2, 3, 4, 5]

    # Check that we got increasing=True and no warnings
    with warnings.catch_warnings():
        warnings.simplefilter("error", UserWarning)
        is_increasing = check_increasing(x, y)

    assert is_increasing
Exemple #13
0
def test_check_increasing_up_extreme():
    x = [0, 1, 2, 3, 4, 5]
    y = [0, 1, 2, 3, 4, 5]

    # Check that we got increasing=True and no warnings
    with pytest.warns(None) as record:
        is_increasing = check_increasing(x, y)
    assert not [w.message for w in record]

    assert is_increasing
 def check_increasing(self, X, y):
     """it sets self.is_increasing
     Args:
         X: 2d-array. training instances.
         y: 1d-array. labels
     """
     dim = X.shape[1]
     self.is_increasing = [None] * dim
     for d in range(dim):
         # here, we use spearman's rank correlation
         self.is_increasing[d] = check_increasing(X[:, d], y)