Question: Your next task is to use the data stored in preference variable and compute the popularity scores of the movies. To compute a movie's popularity

Your next task is to use the data stored in preference variable and compute the popularity scores of the movies. To compute a movie's popularity score, you should first compute the number of times people have liked movies in the entire dataset across all movies (i.e., total likes). You should then compute the number of times people have disliked movies in the entire dataset across all movies (i.e., total dislikes).
Let's assume that people have liked movies A times in the entire dataset and disliked movies B times in the entire dataset. The popularity score of a movie is then defined as Num_of_People_Like_the_Movie - A / B * Num_of_People_Dislike_the_Movie
(We use A/B to normalize the weights of likes and dislikes because if one type of reaction is rare, it derseves more weights. For example, if a typical movie gets on average 100 likes and no dislike, a dislike conveys a much stronger message on a movie's quality than a like).
Your function should return:
A dictionary where the keys are movie names and the values are correpsonding movie popularity score.
A list of movie names sorted descendingly by their popularity. For example, if 'The Shawshank Redemption' is the second most popular movie, the second element in the list should be 'The Shawshank Redemption'.
A and B as defined above.
Note: You may want to use prior functions to help you read data inside this function

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!