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
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)
def test_grouped_with_y(pipeline, groupby, y, input_df, y_mode): if y_mode == 'series': y = input_df[y] elif y_mode == 'array': y = input_df[y].values gp = GroupedPipeline(groupby=groupby, pipeline=pipeline) out = gp.fit_predict(input_df, y) assert type(out) is np.ndarray assert len(out) == len(input_df)
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)