Last active
April 19, 2021 22:08
-
-
Save gvyshnya/958790c7eef1a4557772f9b4fd29bb85 to your computer and use it in GitHub Desktop.
Adding groupby aggregate features with featurewiz
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### create groupby aggregates of the following numerics | |
agg_nums = ['cont1','cont3'] | |
groupby_vars = ['cat2','cat4'] | |
train_add, test_add = FW.FE_add_groupby_features_aggregated_to_dataframe(train[agg_nums+groupby_vars], | |
agg_types=['mean','std'], | |
groupby_columns=groupby_vars, | |
ignore_variables=[] , test=test[agg_nums+groupby_vars]) | |
# join the dataframes with the aggregated features to the main training and testing set dataframes | |
train_copy = train.join(train_add.drop(groupby_vars+agg_nums, axis=1)) | |
test_copy = test.join(test_add.drop(groupby_vars+agg_nums, axis=1)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment