PreferredAI / cornac

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

Fix .rank() method for multiple models #615

Closed hieuddo closed 2 months ago

hieuddo commented 2 months ago

Description

The new Recommender.rank() function adds k as required value, which breaks some models that do not use k in ranking evaluation (e.g., ComparER, EFM, LRPPM).

I put k into **kwargs and use k = kwargs.get("k", -1) instead. Another option is to add k=None to incompatible models.

These two sound like backward compatibility. Should make old models forward-compatible instead.

I added and updated topK ranking for mentioned models.

tqtg commented 2 months ago

@lthoang @hieuddo one question for these models, is it possible to move the part of computing known_item_scores at the beginning of the rank function to the score function?

lthoang commented 2 months ago

@lthoang @hieuddo one question for these models, is it possible to move the part of computing known_item_scores at the beginning of the rank function to the score function?

@tqtg Could you please elaborate more? Based on my understanding, these models compute ranking scores by weighting the tradeoff between predicted ratings and top-k aspects via the following formula:

$$RankingScore{ij} = \alpha \cdot Rating{ij} + (1-\alpha) \cdot AverageTopKAspects_{ij}$$

We can replace $Rating{ij}$ with score(i, j). However, we may not need to recompute the score in $ComparER{sub}$ model as ratings are already computed along with aspect scores.

tqtg commented 2 months ago

I was thinking whether we can reuse the rank() function as implemented by default for all models in Cornac. It seems that these models trying to do rating prediction and top-K recommendation with different scoring mechanisms so we need to overwrite the rank() function.

tqtg commented 2 months ago

@hieuddo the changes look fine to me. @lthoang please help double check the detail. Thank you both.