Skip to content

Conversation

@hieuddo
Copy link
Member

@hieuddo hieuddo commented Apr 22, 2024

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.

@hieuddo hieuddo requested review from lthoang and qtuantruong April 22, 2024 08:42
@qtuantruong
Copy link
Member

@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
Copy link
Member

lthoang commented Apr 23, 2024

@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.

@qtuantruong
Copy link
Member

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.

@qtuantruong
Copy link
Member

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

Copy link
Member

@lthoang lthoang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hieuddo hieuddo merged commit ae7ba86 into PreferredAI:master Apr 24, 2024
@hieuddo hieuddo added the bug Something isn't working label Apr 24, 2024
@hieuddo hieuddo deleted the fix-recommender-rank branch May 20, 2024 06:09
qtuantruong pushed a commit to qtuantruong/cornac that referenced this pull request Oct 25, 2025
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).

This commit updates .rank() for mentioned models with topK option.
qtuantruong pushed a commit to qtuantruong/cornac that referenced this pull request Oct 25, 2025
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).

This commit updates .rank() for mentioned models with topK option.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants