Lecture7.2 After Large
Lecture7.2 After Large
• Reading
• cspy ch. 11 & 12
Recommendation Systems
Related Course: CMPT 353
• Task
• Given users ratings on some movies
• Predict user ratings on other movies
• If John rates
• “Mission Impossible”: 5 https://www.cnbc.com/
• Collaborative recommendation
• Recommending a user based on the
preferences of other similar users
• Content-based recommendation
• Recommending based on item features
considering users previous actions
Advantages Challenges
• Finding meaningful features
• No need for data on other users.
• Learning users’ tastes as a function of these content
• Able to recommend to users with unique tastes features
• Able to recommend new and unpopular items • Overspecialization by not being able to recommend
outside users’ profiles
• Recommendation for new users (cold starts)
• def main()
• Main function to initiate the program
Zip function in Python is used to iterate over two lists. It takes corresponding
elements from two lists and merges them in a tuple.
import gzip
countries = ["UK", "Italy", "Canada"]
capitals = ["London", "Rome", "Ottawa"]
country_capital = zip(countries, capitals)
CMPT 120, Spring 2023, Mohammad Tayebi 14
1. def data_preparation(dataset):
2. users_per_item = {}
3. for d in dataset:
4. user = d['customer_id']
5. item = d['product_id']
6. if item not in users_per_item:
7. users_per_item[item] = [user]
8. else:
9. temp_list = users_per_item[item]
10. temp_list.append(user)
11. users_per_item[item] = temp_list
12. return users_per_item