Unexpected result while mapping using lightfm.data.Dataset.fit() function

时间:2018-06-04 17:43:12

标签: python-2.7 machine-learning dataset mapping

When I do the mapping using 'lightfm.data.Dataset.fit()' function, the number of users as output is shown but the number of items is shown as 0. please help.

this is my code snippet:

        import csv

ratings=csv.DictReader(
                    (x.decode("utf-8", "ignore") for x in open("./music recommendation dataset/user_artists.dat")),
                    delimiter="\t",
                          )
import json
from itertools import islice

for line in islice(ratings, 2):
    print(json.dumps(line, indent=4))

from lightfm.data import Dataset

dataset = Dataset()
dataset.fit((x['userID'] for x in ratings),(x['artistID'] for x in ratings))

num_users, num_items = dataset.interactions_shape()
print('Num_users: {}, num_items {}.'.format(num_users, num_items))

This is the user_artist.dat file scs:

This is the output I am getting. Notice that the number of users is shown as 1892 which was specified in the description of the dataset but the number od items (or artistID in this case) is shown 0 (although in the description of the dataset it was shown to have 17632 values).

0 个答案:

没有答案