benfred / implicit

Fast Python Collaborative Filtering for Implicit Feedback Datasets
https://benfred.github.io/implicit/
MIT License
3.57k stars 612 forks source link

Unable to successfully run the code in the example #648

Closed 1105283746 closed 1 year ago

1105283746 commented 1 year ago

Hi When I try to run the movielens.py in the example, I encounter the following problem:

INFO:implicit:Using cached dataset at 'C:\Users\HP\implicit_datasets\movielens_20m.hdf5' DEBUG:h5py._conv:Creating converter from 3 to 5 INFO:implicit:read data file in 0.4409642219543457 WARNING:root:Intel MKL BLAS detected. Its highly recommend to set the environment variable 'export MKL_NUM_THREADS=1' to disable its internal multithreading DEBUG:implicit:通过bm25_weight加权矩阵 DEBUG:implicit:training model als DEBUG:implicit:Calculated transpose in 0.184s DEBUG:implicit:Initialized factors in 0.3221714496612549 DEBUG:implicit:Running 15 ALS iterations 100%|██████████| 15/15 [01:20<00:00, 5.34s/it] DEBUG:implicit:训练'als'模型共花费 80.70574712753296 秒 DEBUG:implicit:calculating top movies DEBUG:implicit:calculating similar movies 0%| | 0/131263 [00:00<?, ?it/s] <zip object at 0x000001E2BB989900> Traceback (most recent call last): File "D:\pythoneCodeTest\implicit-main\examples\movielens.py", line 141, in calculate_similar_movies( File "D:\pythoneCodeTest\implicit-main\examples\movielens.py", line 97, in calculate_similar_movies for other, score in zip(*model.similar_items(movieid, 11)): ValueError: too many values to unpack (expected 2)

Process finished with exit code 1

I am a newbie in recommendation algorithms and I feel that your project will not have such a simple problem. So I'm wondering if something else is wrong. The current python version is python 3.9

benfred commented 1 year ago

What version of the implicit library are you running (like what does print(implicit.__version__) show in your python interpreter)?

Based off the output you're showing here, it looks like you're running an older version of the implicit library against the latest movielen example - if you're not running implicit v0.6.2, can you try upgrading to the latest version?

1105283746 commented 1 year ago

Thank you very much indeed! My pycharm tells me version 0.6.2, but when I print the version it's 0.4.8. It works fine already, and I'll recommend your code to my classmates!