Пример #1
0
def test_grouped_returns_numpy(pipeline, groupby, is_estimator, input_df):
    gp = GroupedPipeline(groupby=groupby, pipeline=pipeline)
    if is_estimator:
        out = gp.fit_predict(input_df)
    else:
        out = gp.fit_transform(input_df)
    assert type(out) is np.ndarray
Пример #2
0
def test_grouped_order(pipeline, groupby, is_estimator, input_df):
    gp = GroupedPipeline(groupby=groupby, pipeline=pipeline)
    if is_estimator:
        out = gp.fit_predict(input_df).values
        expected = input_df[ini.Columns.target].values
    else:
        out = gp.fit_transform(input_df).values
        expected = input_df[[ini.Columns.target]].values
    np.testing.assert_array_equal(out, expected)
Пример #3
0
def test_grouped_values(mocker, pipeline, groupby, is_estimator, input_df):
    gp = GroupedPipeline(groupby=groupby, pipeline=pipeline)
    if is_estimator:
        out = gp.fit_predict(input_df)
    else:
        out = gp.fit_transform(input_df)

    input_df['out'] = out
    for _, df in input_df.groupby(groupby):
        expected = df[ini.Columns.target].shift(1)
        np.testing.assert_array_equal(expected.values, df['out'].values)
Пример #4
0
def test_grouped_returns_pandas(pipeline, groupby, input_df):
    gp = GroupedPipeline(groupby=groupby, pipeline=pipeline)
    out = gp.fit_transform(input_df)
    assert type(out) is pd.DataFrame