def sample_neg_interaction(self, pos_interaction_table, offset):
    'Sample neg_interaction to construct train data.\n\n        Args:\n            pos_interaction_table(dict): the interaction_table that only contains pos_interaction.\n            offset(int): The offset that is used for calculating the key(index) in interaction_table\n\n        Returns:\n            interaction_table(dict): key: user_id * 10^offset + item_id; value: y_{user_id, item_id}\n        '
    pos_num = len(pos_interaction_table)
    neg_num = 0
    neg_interaction_table = {}
    while (neg_num < pos_num):
        user_id = random.randint(0, self.n_users)
        item_id = random.randint(0, self.n_items)
        keys = ((user_id * offset) + item_id)
        if (keys not in pos_interaction_table):
            neg_interaction_table[keys] = 0.0
            neg_num += 1
    interaction_table = {**pos_interaction_table, **neg_interaction_table}
    return interaction_table
Sample neg_interaction to construct train data.

Args:
    pos_interaction_table(dict): the interaction_table that only contains pos_interaction.
    offset(int): The offset that is used for calculating the key(index) in interaction_table

Returns:
    interaction_table(dict): key: user_id * 10^offset + item_id; value: y_{user_id, item_id}
def sample_neg_interaction(self, pos_interaction_table, offset):
    'Sample neg_interaction to construct train data.\n\n        Args:\n            pos_interaction_table(dict): the interaction_table that only contains pos_interaction.\n            offset(int): The offset that is used for calculating the key(index) in interaction_table\n\n        Returns:\n            interaction_table(dict): key: user_id * 10^offset + item_id; value: y_{user_id, item_id}\n        '
    pos_num = len(pos_interaction_table)
    neg_num = 0
    neg_interaction_table = {}
    while (neg_num < pos_num):
        user_id = random.randint(0, self.n_users)
        item_id = random.randint(0, self.n_items)
        keys = ((user_id * offset) + item_id)
        if (keys not in pos_interaction_table):
            neg_interaction_table[keys] = 0.0
            neg_num += 1
    interaction_table = {**pos_interaction_table, **neg_interaction_table}
    return interaction_table