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.

Exercise solution: Implement a stoplist

Exercise solution: Implement a stoplist

- [Instructor] Okay, so if you open up my RBMAlgorithm.py file in the Challenges folder of the course materials, you'll see how I went about implementing the stop list. In the init function, I've loaded up the MovieLens module because we need it for looking up movie titles from movie IDs. We've also defined a very small stop list here, containing just the terms sex, drugs, and rock n roll. This obviously isn't a real stop list. You should put a lot more thought into yours, and make sure it includes the roots of words and not specific tenses or variations of them. For example, in a real stop list, I'd stop list drug and not drugs to catch as many drug-related words as possible. Next, we have the buildStoplist function on line 26. All we're doing here is building up a dictionary that lets us quickly look up if a given item ID is banned or not. We iterate through every item in our training set, convert it to a raw item ID, and look up its title. If it has a title, we first convert that…

Contents