PreferredAI / cornac

A Comparative Framework for Multimodal Recommender Systems
https://cornac.preferred.ai
Apache License 2.0
845 stars 138 forks source link

[ASK] adding user demographics as feature for training #633

Closed tahsinkheya closed 5 days ago

tahsinkheya commented 6 days ago

Hi, I want to add user info as features for training like, their age, gender and so on. If my interpretation is correct then I can add it as a modality like so. Is this correct? ` user_feature_modality = FeatureModality( features=user_features_numpy, name="user", normalized=True, ids=list(range(0, n)) )

ratio_split = StratifiedSplit( data=dataset, test_size=0.2, rating_threshold=0.0, seed=123, verbose=True )

user_feature_modality.build()\ ratio_split.add_modalities( user_feature=user_feature_modality, ) ` I am just unsure if I have to add it like this or to the dataset itself. Please help. Thanks!

lthoang commented 6 days ago

You can init your user feature within the declaration of evaluation method. For example:

user_feature_modality = FeatureModality(...)
ratio_split = StratifiedSplit(
    ...,
    user_feature=user_feature_modality
)
tahsinkheya commented 5 days ago

Yeah alright thank you! @lthoang

tahsinkheya commented 5 days ago

So just doing this is enough for adding user features for any of the models? or do I need to change the code for the models?

lthoang commented 5 days ago

For BiVAECF, which uses user_feature modality, you have to add user_feature modality to train it.

https://github.com/PreferredAI/cornac/blob/ef9956e6a4549953820baa15275066ca405a0204/cornac/models/bivaecf/bivae.py#L181

If you are using a different model, you have to change the code to use user_feature data.

tahsinkheya commented 5 days ago

okay thank you sm @lthoang