Recommendation System - Order number#C105017


You will write one program; recommender.py. The file contains sets of four lines containing the username, title, author and rating in that order. You must use Python’s dictionaries and sets to complete this assignment. When your program starts it should load all the ratings from ratings.txt. Your program should prompt the user with options to add a rating, get recommendations, get the best rated book or quit. Your program should keep prompting the user for a next task until the user types “quit”. When this happens the program should halt.

It must be possible for the user to choose options multiple times in any order and get the correct results each time.

You are required to store your rating data in a dictionary mapping a name to set of review objects.


We have provided you with a class named Review that your recommender program will use. A Review object represents a single review of a book. It keeps track of the name of the book, the book’s author and the rating a user gave it.

The Review class provides the following constructors and methods that you should use in your program.


We suggest the following development strategy for solving this program:

1. Write a function to read the input file and create the initial dictionary mapping username to sets of books rated.

2. Write a main that prompts the user for what they want to do next. You may need to prompt for additional information depending on what they want to do. See sample outputs for details.

3. Implement the add functionality so that values can be added to your dictionary

4. Write code to find the best book overall. To do this, create another dictionary mapping the title of each book to a tuple containing the sum of all of its ratings and the number of ratings. Then, loop over the dictionary to find the book with the highest average review (calculate average by dividing sum of all ratings by number of ratings).

5. Calculate recommendations for a particular user. To do this, start by creating a map of users to distances form the user you are trying to make a recommendation for. To fill this, go through your dictionary that maps users to their reviews and for each user go through all of their review. For each of those reviews go through all of the reviews of the user you are trying to make a recommendation for and if the book titles are the same, multiply the ratings of the two users and add them to the similarity score.

Once the dictionary is filled, go through it and find the person with the minimum distance score. Output all of the books that the person with the minimum distance has read and rated a positive number that the person you are trying to make a recommendation for hasn’t.

You can test the output of your program by running it on the provided input files as well as creating an input file of your own. You can also use our Output Comparison Tool to see that your outputs match what is expected.

推荐好友下单领$20

Richard Team 

第一次下单

立减$20

活动时间:2020.06.01 - 2021.06.01

  • Instagram

©2015 by Richard Team.