lyst / lightfm

A Python implementation of LightFM, a hybrid recommendation algorithm.
Apache License 2.0
4.66k stars 679 forks source link

Cannot get MovieLens labels' correctly #682

Open baibai25 opened 1 year ago

baibai25 commented 1 year ago

Hi! Thank you for fix #676! I updated to version 1.17 and tried the tutorial code with the following results.

スクリーンショット 2023-03-23 21 43 28

The label dtype is '<U1', which appears to be incorrect. I ran movielens.py on my Notebook and got the same result.

スクリーンショット 2023-03-23 21 44 02

Suggestion

Probably an error caused by the numpy specification. I suggest following modifications:

https://github.com/lyst/lightfm/blob/688feded0717f289933b95a0134bad6fbe547331/lightfm/datasets/movielens.py#L75

# new
id_feature_labels = np.empty(num_items, dtype=object)

In my Notebook, it works!

スクリーンショット 2023-03-23 21 44 14
baibai25 commented 1 year ago

Here is my environment

- OS: Ubuntu 20.04.1
- Python: 3.9.2
  - numpy: 1.24.2
  - lightfm: 1.17
z2z63 commented 11 months ago

the same problem, and changing from

 id_feature_labels = np.empty(num_items, dtype=str) 

to

  id_feature_labels = np.empty(num_items, dtype=object) 

works