PreferredAI / cornac

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

Fix EFM._build_matrices() method #616

Closed hieuddo closed 2 months ago

hieuddo commented 2 months ago

Description

The two methods knows_user and knows_item check whether uid (or iid) is smaller than self.num_users (or self.num_items), which doesn't exist because fit() was never executed.

This commit tries to fix an error in recommender-systems tutorial notebook 7, where EFM.train_set is assigned and _build_matrices() is executed before fit():

efm = EFM()
efm.train_set = rs.train_set
_, X, Y = efm._build_matrices(rs.train_set)
tqtg commented 2 months ago

@hieuddo @lthoang how about modifying the tutorial to the following?

efm = EFM(max_iter=0)
efm.fit(train_set=rs.train_set)

I think it serves the same purpose and looks cleaner.

hieuddo commented 2 months ago

@tqtg I think your suggestion makes sense. efm.fit(train_set=rs.train_set) seems more conventional than directly assign train_set by efm.train_set = rs.train_set.

Anyway, could you help to release new cornac version with the recent Recommender.rank() fix so that EFM can run smoothly?

tqtg commented 2 months ago

@hieuddo we have a new version released. Should we check if the above approach works for the tutorial? and do we need to work on this change anymore?

hieuddo commented 2 months ago

@tqtg Yes, it works. There is no need for this change. Thanks