ai2010 / machine_learning_for_the_web

61 stars 66 forks source link

In chapter7, I run into this problem: IndexError at / list index out of range <code:ndim = mobjs[0].ndim> #2

Closed djmirv closed 4 years ago

djmirv commented 7 years ago

I already checked the data directory. umatrixpath: '/Users/jmirv/Desktop/MachineLearningfortheWeb_Code/chapter_7/server_movierecsys/umatrix.csv' Anyone help me solve this!! Thx in advance.

Lxuex commented 5 years ago

I also run into this problem: IndexError at / list index out of range . Have you solved the problem yet?

djmirv commented 5 years ago

I also run into this problem: IndexError at / list index out of range . Have you solved the problem yet?

没呢老弟,这书用着贼坑,demo都跑不出来,都甩手掌柜了

ai2010 commented 4 years ago

The error occurs because Django's Table “MovieData” (chapter7/server_movierecsys/books_recsys_app/models.py) is empty and as a result "mobjs[0].ndim" is empty too. Instead, you should first load the data directly into memory (cache of Django) by running the following as described in the book:

  1. python manage.py get_plotsfromtitles --input=utilitymatrix.csv --outputplots=plots.csv --outputumatrix='umatrix.csv'

  2. python manage.py load_data --input=plots.csv --nmaxwords=30000 --umatrixfile=umatrix.csv After that, “MovieData” Table will contain data and you can then run the Django app and access localhost/home. (book pages 211-219)