Closed lthoang closed 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 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.
Description
Related Issues
https://github.com/PreferredAI/cornac/issues/618
Checklist:
README.md
(if you are adding a new model).examples/README.md
(if you are adding a new example).datasets/README.md
(if you are adding a new dataset).