Exemple #1
0
def read_interaction_data(item_id_mapping, positive_threshold=4.0):

    interactions = Interactions(item_id_mapping)

    with open(os.path.join(DATA_DIR, "ratings.dat"), "r") as ratingfile:
        for line in ratingfile:

            (uid, iid, rating, timestamp) = line.split(SEPARATOR)

            value = 1.0 if float(rating) >= positive_threshold else 0.0

            interactions.add(uid, iid, value)

    return interactions
Exemple #2
0
def read_interaction_data(item_id_mapping, positive_threshold=4.0):

    interactions = Interactions(item_id_mapping)

    with open(os.path.join(DATA_DIR, 'ratings.dat'), 'r') as ratingfile:
        for line in ratingfile:

            (uid, iid, rating, timestamp) = line.split(SEPARATOR)

            value = 1.0 if float(rating) >= positive_threshold else 0.0

            interactions.add(uid, iid, value)

    return interactions
Exemple #3
0
def read_interactions(item_id_mapping):

    interactions = Interactions(item_id_mapping)

    interactions_dropped = 0

    for post_id, user_id, tags, parent_post_id, body in read_post_data():

        assert user_id is not None
        assert post_id is not None
        
        # Only answers count as interactions
        if parent_post_id is not None:
            try:
                interactions.add(user_id, parent_post_id, 1.0)
            except KeyError:
                interactions_dropped += 1

    logger.info('Dropped %s interactions due to None user issues', interactions_dropped)

    return interactions
Exemple #4
0
def read_interactions(item_id_mapping):

    interactions = Interactions(item_id_mapping)

    interactions_dropped = 0

    for post_id, user_id, tags, parent_post_id, body in read_post_data():

        assert user_id is not None
        assert post_id is not None

        # Only answers count as interactions
        if parent_post_id is not None:
            try:
                interactions.add(user_id, parent_post_id, 1.0)
            except KeyError:
                interactions_dropped += 1

    logger.info('Dropped %s interactions due to None user issues',
                interactions_dropped)

    return interactions