PreferredAI / cornac

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

Update TriRank documentation #619

Closed lthoang closed 6 months ago

lthoang commented 6 months ago

Description

Related Issues

https://github.com/PreferredAI/cornac/issues/618

Checklist:

tqtg commented 6 months ago

@lthoang there is a failed unit test related to NextItemRecommender. See the log below:

_______________________ TestNextItemRecommender.test_fit _______________________

self = <models.test_recommender.TestNextItemRecommender testMethod=test_fit>

    def test_fit(self):
        dataset = SequentialDataset.from_usit(self.data)
        model = NextItemRecommender("")
        model.fit(dataset)
        model = SPop()
        model.fit(dataset)
        model.score(0, [])
        result = model.rank(0, history_items=[])
>       self.assertTrue((result[0] == [3, 2, 4, 1, 0, 5, 8, 7, 6]).all())
E       AssertionError: False is not true

tests/cornac/models/test_recommender.py:88: AssertionError

There might be some randomness in this test where it passes most of the time but fails rarely?

lthoang commented 6 months ago

@lthoang there is a failed unit test related to NextItemRecommender. See the log below:

_______________________ TestNextItemRecommender.test_fit _______________________

self = <models.test_recommender.TestNextItemRecommender testMethod=test_fit>

    def test_fit(self):
        dataset = SequentialDataset.from_usit(self.data)
        model = NextItemRecommender("")
        model.fit(dataset)
        model = SPop()
        model.fit(dataset)
        model.score(0, [])
        result = model.rank(0, history_items=[])
>       self.assertTrue((result[0] == [3, 2, 4, 1, 0, 5, 8, 7, 6]).all())
E       AssertionError: False is not true

tests/cornac/models/test_recommender.py:88: AssertionError

There might be some randomness in this test where it passes most of the time but fails rarely?

Investigate this failing case, I find that the ranking results of SPop as follows:

(array([3, 2, 4, 0, 1, 5, 8, 7, 6]), 
array([0.6923077 , 0.6923077 , 0.9230769 , 1., 0.7692308 , 0.3846154 , 0.07692308, 0.07692308, 0.07692308], dtype=float32))

We can see that there are some items having identical scores. Thus we need to rewrite to ensure the test case can pass in those cases. This will be fixed in another PR.