Transformers4Rec
Transformers4Rec copied to clipboard
[QST] Understanding the feature dependency from Example
❓ Questions & Help
While training the model we are taking multiple features which also includes 'item_id-list_seq', 'category-list_seq' as categorical features and 'product_recency_days_log_norm-list_seq', 'et_dayofweek_sin-list_seq' as continuous variables. As per my understanding of training task the model is learning all 4 features separately and while evaluating it predicts all the features and take their ground truth to provide NDGC and recall.
If that's the case just wanted to understand that are the continuous features 'product_recency_days_log_norm-list_seq', 'et_dayofweek_sin-list_seq' needed by the model because as per my understanding these features are impacting the final results. Predicting the recency and time of interaction can be a tough task.
Could you please explain the dependency of these features and correct me if I have misunderstood any of the point. I have tried training model only on categorical features and the results are pretty good, the model is able to predict next item id and category at a very good NDGC and recall.
Thanks
@Sagar1094 not sure I understand your question clearly but the model is predicting the next item to be interacted
with by using the input features: 'item_id-list_seq', 'category-list_seq' as categorical features and 'product_recency_days_log_norm-list_seq', 'et_dayofweek_sin-list_seq'.
so our target here is the next
item in a given sequence, so feeding an item-id
sequence (`'item_id-list_seq') is required feature but other features are optional. you can feed whatever feature you want to model as side info and test if these features are giving you better results or not. As in any ML pipeline. Hope that helps.
@rnyak Could you help me understand what the item_recency function is actually doing? For example,
from nvtabular.ops import Operator
class ItemRecency(Operator):
def transform(self, columns, gdf):
for column in columns.names:
col = gdf[column]
item_first_timestamp = gdf['prod_first_event_time_ts']
delta_days = (col - item_first_timestamp) / (60*60*24)
gdf[column + "_age_days"] = delta_days * (delta_days >=0)
return gdf
def output_column_names(self, columns):
return ColumnSelector([column + "_age_days" for column in columns.names])
def dependencies(self):
return ["prod_first_event_time_ts"]
recency_features = ['event_time_ts'] >> ItemRecency()
recency_features_norm = recency_features >> nvt.ops.LogOp() >> nvt.ops.Normalize() >> nvt.ops.Rename(name='product_recency_days_log_norm')