deeplearning
deeplearning copied to clipboard
Question re: 05_1_TimeSeries_HistoricalEvents!
Good Afternoon! Thank you very much for all you have done with these repositories of knowledge! I had a question about the file: 05_1_TimeSeries_HistoricalEvents.ipynb
In the case of the solution code here:
############### Solution ###############
offset = '7D'
data_window = df_train[['product_id', 'date', 'target']].groupby(['product_id', 'date']).agg(['count', 'sum']).reset_index()
data_window.columns = ['product_id', 'date', 'count', 'sum']
data_window.index = data_window['date']
data_window_roll = data_window[['product_id', 'count', 'sum']].groupby(['product_id']).rolling(offset).sum().drop('product_id', axis=1)
data_window_roll = data_window_roll.reset_index()
data_window_roll.columns = ['product_id', 'date', 'count_' + offset, 'sum_' + offset]
data_window_roll[['count_' + offset, 'sum_' + offset]] = data_window_roll[['count_' + offset, 'sum_' + offset]].shift(1)
data_window_roll.loc[data_window_roll['product_id']!=data_window_roll['product_id'].shift(1), ['count_' + offset, 'sum_' + offset]] = 0
data_window_roll['avg_' + offset] = data_window_roll['sum_' + offset]/data_window_roll['count_' + offset]
data = df_train.merge(data_window_roll, how='left', on=['product_id', 'date'])
data
We are typically left with a np.nan
value for the first row of each group's avg_7D
. Would you all recode this to zero, or leave it as nan
and drop the row? Additionally, would you typically include several of these in your model? Say, compute 3D
and a 7D
offset average?
Separately, I take it you apply identical functions to the valid and test sets, as well, right?
Lastly, where/when I might learn more about similar courses that you might offer in the future?
Thank you for your time and consideration!