TannerGilbert / Tutorials

Code for some of my articles
https://gilberttanner.com/
MIT License
561 stars 631 forks source link

Two personal questions about Recommendation System.ipynb #42

Closed 1097872822 closed 3 years ago

1097872822 commented 3 years ago

In the code user = np.array([1 for i in range(len(book_data))]) ,why is user range starting from 1 and user equal [1,1,1,1...1] ,why not start from the first user_id = 314 in the rating.csv,I personally not understand this, if you can answer me, I will be grateful.

Next, my second personal question is in the code predictions = np.array([a[0] for a in predictions]),what is the specific "a[0]" here? what is its role? and why use a[0]? Thank you again for your code and thank you if you can answer me.

TannerGilbert commented 3 years ago

Sorry for the late reply. With the code user = np.array([1 for i in range(len(book_data))]) we are creating an array of 1s. That's because we want to make recommendations for the user with the ID 1.

Secondly, a[0] is used because the predictions are of type array, e.g. [5.107734], and we only want the number. I hope this answers your questions. If you have any more questions, feel free to ask.