def test_sparse_predict():
    """Check that the predict method works with dense coef_ and sparse X"""
    X = sp.lil_matrix((3, 2))
    X[0, 0] = 1
    X[0, 1] = 0.5
    X[1, 0] = -1

    clf = SparseENet()
    clf._set_coef(np.array([1, -1]))
    predicted = clf.predict(X)
    np.testing.assert_array_equal([0.5, -1.0, 0.0], predicted)
Example #2
0
def test_sparse_predict():
    """Check that the predict method works with dense coef_ and sparse X"""
    X = sp.lil_matrix((3, 2))
    X[0, 0] = 1
    X[0, 1] = 0.5
    X[1, 0] = -1

    clf = SparseENet()
    clf._set_coef(np.array([1, -1]))
    predicted = clf.predict(X)
    np.testing.assert_array_equal([0.5, -1.0, 0.0], predicted)