コード例 #1
0
    def test_prepare_X(self):
        lor = LinearOrdinalRegression(None, None)
        X = np.array([[-1, 0, 1], [0, 1, -1], [1, -1, 0], [-3, 3, -3],
                      [3, -3, 3]])
        X_data, X_scale, X_mean, X_std = lor._prepare_X(X)

        assert_array_equal(X_data, X)
        assert_array_equal(X_scale, X / 2.0)
        assert_array_equal(X_mean, np.array([0, 0, 0]))
        assert_array_equal(X_std, np.array([2, 2, 2]))
        assert lor.N == 5
        assert lor.n_attributes == 3
コード例 #2
0
 def test_vanishing_variance_raises_error(self):
     lor = LinearOrdinalRegression(None, None)
     X = np.array([[1, 1], [1, 2], [1, 3]])
     with pytest.raises(ValueError):
         lor._prepare_X(X)
コード例 #3
0
 def test_prepare_X_from_single_column_dataframe(self, X_ucla, y_ucla):
     X_ucla = X_ucla.iloc[:, 0]
     lor = LinearOrdinalRegression(None, None)
     lor._prepare_X(X_ucla)
     assert lor.n_attributes == 1