

def test_stratified_strategy_sparse_target():
    X = ([[0]] * 5)
    y = sp.csc_matrix(np.array([[4, 1], [0, 0], [1, 1], [1, 4], [1, 1]]))
    clf = DummyClassifier(strategy='stratified', random_state=0)
    clf.fit(X, y)
    X = ([[0]] * 500)
    y_pred = clf.predict(X)
    assert_true(sp.issparse(y_pred))
    y_pred = y_pred.toarray()
    for k in range(y.shape[1]):
        p = (np.bincount(y_pred[:, k]) / float(len(X)))
        assert_almost_equal(p[1], (3.0 / 5), decimal=1)
        assert_almost_equal(y_pred[0], (1.0 / 5), decimal=1)
        assert_almost_equal(p[4], (1.0 / 5), decimal=1)

dataset/ETHPy150Open scikit-learn/scikit-learn/sklearn/tests/test_dummy.py test_stratified_strategy_sparse_target/VarMisuse@185/218 `p`->`y_pred`