recommenders icon indicating copy to clipboard operation
recommenders copied to clipboard

[ASK] Questions about the construction of user history

Open DoubleX-Star opened this issue 3 years ago • 3 comments

Hi, I'm a little confuseds about how to load MIND data.

Description

When initializing user behavior, the code in MINDIterator/MINDAllIterator is like this :

history = [0] * (self.his_size - len(history)) + history[ : self.his_size ]

Padding 0 to the head of the list when the history is insufficient should mean that the News in history are arranged according to time. (The later the position, the newer the time) On the other hand, the first his_size elements are selected in the code.

Solution

Would it be more reasonable to select the latest his_size elements like this to represent the user status?

history = [0] * (self.his_size - len(history)) + history[ -self.his_size : ]

Other Comments

Specific location link : https://github.com/microsoft/recommenders/blob/66e4b6b2220bae6bb97947e1bbe7c5d97cbec979/reco_utils/recommender/newsrec/io/mind_iterator.py#L117

https://github.com/microsoft/recommenders/blob/66e4b6b2220bae6bb97947e1bbe7c5d97cbec979/reco_utils/recommender/newsrec/io/mind_all_iterator.py#L143

DoubleX-Star avatar Dec 10 '20 14:12 DoubleX-Star

Same confusion here. @yjw1029 Could you please have some words on this?

cc @miguelgfierro

thaiminhpv avatar Jan 04 '24 11:01 thaiminhpv

Seems like an issue in the previous implementation. Modifying to history[ -self.his_size : ]would be more reasonable. Will open a PR later to fix this issue.

yjw1029 avatar Jan 05 '24 15:01 yjw1029

This is the result when using the solution:

>>> history = [1, 2, 3, 4, 5, 6]
>>> history[-3:]
[4, 5, 6]
>>> history[:3]
[1, 2, 3]
>>> his_size = 10
>>> [0] * (his_size - len(history)) + history[: his_size]
[0, 0, 0, 0, 1, 2, 3, 4, 5, 6]
>>> [0] * (his_size - len(history)) + history[-his_size:]
[0, 0, 0, 0, 1, 2, 3, 4, 5, 6]
>>> his_size = 4
>>> [0] * (his_size - len(history)) + history[: his_size]
[1, 2, 3, 4]
>>> [0] * (his_size - len(history)) + history[-his_size:]
[3, 4, 5, 6]

SimonYansenZhao avatar Jan 08 '24 15:01 SimonYansenZhao