PreferredAI / cornac

A Comparative Framework for Multimodal Recommender Systems

Home Page:https://cornac.preferred.ai

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[ASK] adding user demographics as feature for training

tahsinkheya opened this issue · comments

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!

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
)

Yeah alright thank you! @lthoang

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?

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

user_features = train_set.user_feature.features[: train_set.num_users]

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

okay thank you sm @lthoang