Have you noticed that our computer systems are getting to know us almost better than we know ourselves? For example, if you watch television shows or movies on Netflix, they’ll happily show you
all the titles you haven’t seen, but will probably like. Spotify’s Dis- cover will find music tracks for you that will end up being your new favourites. And if you shop on Amazon, they have a whole per- sonalized virtual store for you filled with stuff you never knew you needed. Pretty scary, isn’t it?
If you’re under the impression that these companies are running very sophisticated machine learning and artificial intelligence algo- rithms to find recommendations for you, you are probably correct. However, you might be surprised at how effective a few simple pat- tern recognition and classification techniques can be in some situ- ations. The goal of this assignment is to apply what we’ve learned about computing so far to explore the foundations behind such rec- ommendation systems, using our very own class as a test sample.
The individual component will have you write a small program that will read a list of movies from a text file, and allow you to in- teractively give each one a rating based on how much you liked it. We will assemble all your individual ratings to create a large data file representing the movie tastes of our class. In the paired component, you will write a program that uses this data to provide individual- ized movie recommendations.
First, find the text file cpsc231-movies.txt which contains a curated list of movie titles that we’ll use for this assignment. You can down- load it from the Assignments section of the course web page, or grab it from d2l. The main goal of this first part of the assignment is for you to write a program that will allow you to interactively give a rating to each title in the movie list.
You can use the exact same programming environment you set up for previous assignments to complete this assignment. Create and submit a separate Python program for each problem.
Problem 1: Your Movie Ratings
Write a Python program that will read a list of movie titles from a file, cpsc231-movies.txt, and present the titles one at a time on the screen, asking for a rating for each one. First, ask the user for his or her name, then ask the user to rate each of the titles according to the scale shown on the right.
Your program should write the final ratings for all the titles to a text output file once the interactive rating process is complete.
You may name your output file however you’d like, but use a .txt file extension. The file should contain exactly two lines of text: line 1 should contain the name provided at the beginning of the run and line 2 should contain the ratings for all 100 movies, in the order presented and separated by commas. Please don’t write a comma after the last rating, and ensure that the second line ends with a newline (’\n’) character!
When you are satisfied with your program, run it to give your own rating to each title in our movies list. Feel free to use a fake name, partial name, nickname, or simply write “anonymous” if you’d like to keep your movie preferences private. We thought it might be neat to potentially find movie buddies though this exercise if you’re not embarrassed to include your name with your ratings. We will not divulge your real identity to your classmates nor anyone else through this assignment unless you volunteer it explicitly here.
Ensure that the output file created by your program, which con- tains your ratings, is formatted exactly as specified above when you are finished. Submit your ratings file along with your program for this problem.
Inputs: A file containing our list of movie titles, specified as a com- mand line argument. For example, you might run your program with the following invocation:
$ python3 my-p1.py cpsc231-movies.txt
Outputs: An interactive prompt for each of the titles in the file speci- fied, asking for a rating for each title, similar to that shown on the right. At the end of your program, the ratings should be saved to a text file in the exact format specified. The output file from this sample run (my-ratings.txt) would look like:
5,1,3,0,(ratings for the other 96 movies… 〉
Problem 2: Your Personal Summary
It’s always a good idea to double-check your results before you sub- mit them. The format of the output file makes it tricky to do by in- spection, but we can create a program that both confirms some of your ratings while showing some interesting information.
Write a program that that takes as input our list of movies and a saved ratings file (the output of Problem 1), both specified as com- mand line arguments, and prints the following to the screen:
- The number of movies seen out of the total number of
- A list of favourite titles (with the highest possible rating).
- A list of least favourite titles (with the lowest possible rating).
Inputs: The movie list file (cpsc231-movies.txt) and a saved ratings file, both specified by command line arguments.
$ python3 my-p2.py cpsc231-movies.txt my-ratings.txt
Outputs: Summary information from the ratings, presented in a form similar to that shown on the right.
本网站支持淘宝 支付宝 微信支付 paypal等等交易。如果不放心可以用淘宝交易！
E-mail: [email protected]ail.com 微信:dmxyzl003