From the course: Building Recommender Systems with Machine Learning and AI

Unlock this course with a free trial

Join today to access over 22,600 courses taught by industry experts.

Running user- and item-based KNN on MovieLens

Running user- and item-based KNN on MovieLens - Python Tutorial

From the course: Building Recommender Systems with Machine Learning and AI

Running user- and item-based KNN on MovieLens

- [Instructor] Okay, so let's head back to Spyder, and this time have a look at the KNNBakeOff file inside our collaborative filtering folder. As I said, surpriselib will do most of the work for us here. We just have to tell it what we want to do. We're importing the KNNBasic package because that's what implements both user-based and item-based KNN recommendations as we've described them. All we do is create one instance with the user_based set to True and another to False and pit them against each other, and also the Random recommender as a baseline. We will print out accuracy metrics, but in the interest of time, we'll just sample the top end recommender results. You can certainly pass True to the evaluate function if you want to get hit rate metrics as well, but it will take a lot longer to run. Let's kick it off, and we'll come back in a few minutes, when it's done. So let's take a look at the accuracy results. This is interesting. Both user-based and item-based have about the…

Contents