@pytest.mark.parametrize('sample_weight', [True, False])
@pytest.mark.parametrize('normalize', [True, False])
@pytest.mark.parametrize('labels', [[0, 1], [0, 1, 3], [1, 0]])
@pytest.mark.parametrize('daskify', [True, False])
def test_log_loss(labels, normalize, sample_weight, daskify):
    n = 100
    c = 25
    y_true = np.random.choice(labels, size=n)
    y_pred = np.random.uniform(size=(n, len(labels)))
    y_pred /= y_pred.sum(1, keepdims=True)
    if sample_weight:
        sample_weight = np.random.uniform(size=n)
        sample_weight /= sample_weight.sum()
        dsample_weight = da.from_array(sample_weight, chunks=c)
    else:
        sample_weight = None
        dsample_weight = None
    if daskify:
        dy_true = da.from_array(y_true, chunks=c)
        dy_pred = da.from_array(y_pred, chunks=c)
    else:
        dy_true = y_true
        dy_pred = y_pred
        (dsample_weight,) = dask.compute(dsample_weight)
    a = sklearn.metrics.log_loss(y_true, y_pred, normalize=normalize, sample_weight=sample_weight)
    b = dask_ml.metrics.log_loss(dy_true, dy_pred, labels=labels, normalize=normalize, sample_weight=dsample_weight)
    assert_eq(a, b)
@pytest.mark.parametrize('sample_weight', [True, False])
@pytest.mark.parametrize('normalize', [True, False])
@pytest.mark.parametrize('labels', [[0, 1], [0, 1, 3], [1, 0]])
@pytest.mark.parametrize('daskify', [True, False])
def test_log_loss(labels, normalize, sample_weight, daskify):
    n = 100
    c = 25
    y_true = np.random.choice(labels, size=n)
    y_pred = np.random.uniform(size=(n, len(labels)))
    y_pred /= y_pred.sum(1, keepdims=True)
    if sample_weight:
        sample_weight = np.random.uniform(size=n)
        sample_weight /= sample_weight.sum()
        dsample_weight = da.from_array(sample_weight, chunks=c)
    else:
        sample_weight = None
        dsample_weight = None
    if daskify:
        dy_true = da.from_array(y_true, chunks=c)
        dy_pred = da.from_array(y_pred, chunks=c)
    else:
        dy_true = y_true
        dy_pred = y_pred
        (dsample_weight,) = dask.compute(dsample_weight)
    a = sklearn.metrics.log_loss(y_true, y_pred, normalize=normalize, sample_weight=sample_weight)
    b = dask_ml.metrics.log_loss(dy_true, dy_pred, labels=labels, normalize=normalize, sample_weight=dsample_weight)
    assert_eq(a, b)