Howto for CompSci 101 Fall 2016, Asgn 8 Recommender

Get the snarf file that has the data files you need for this assignment or get them here.

Suggested order to work on

Below is a list of the files and essential methods you need to create for this assignment. Feel free to also create additional helper methods.

IN ALL OF THESE, PRINT A LOT OF OUTPUT WHILE DEBUGGING. Strongly suggested after you create a new structure, print it out to make sure it was built correctly. If it is large, just print a small part of it, such as the first 20 items in a list, or print just ten items from the dictionary.

Here is the suggested 12-step process to work on this project.

  1. Write ReadFood.py to process the food data. This is a very small file so you will be able to print a complete structure out (list, dictionary) after you build it to see if it looks correct.

  2. Write Recommender.py, just the averages function.

  3. Write RecommenderFood.py, just the part to test the averages function.

  4. Add to Recommender.py, just the similarities function.

  5. Add to RecommenderFood.py, just the part to test the similarities function.

  6. Add to Recommender.py, just the recommender function.

  7. Add to RecommenderFood.py, just the recommender to test the similarities function.

    At this point you have completed ReadFood.py, Recommender.py and ReadFood.py. You've completed a large part of this assignment!

  8. Write ReadBooks.py. The data will be in a different format than the food was, but the output should be the same: a list and a dictionary.

  9. Write RecommenderBooks.py - this is similar to RecommenderFood.py, suggest you copy it and modify it.

    You are almost done!

  10. Write ReadMovies.py. The data again is in a different format than the food and books were, but the output should be the same: a list and a dictionary.

  11. Write RecommenderMovies.py - this is similar to RecommenderBooks.py, suggest you copy it and modify it.

  12. Now you are done! Submit your program and feel good about all you have learned in CompSci 101 this semester!

Below are a list of all the files and methods you need to write. More detail for each are on the details page.


ReadFood.py

Function: processdata( filename) : The function must read data about food and raters and return the information in a list and dictionary. (see details)

The filename argument must be a txt file of food and ratings like this sample small one (also in the snarf ) and in this format.
rater
place rating place rating place rating
rater
place rating place rating place rating place rating place rating
rater
place rating place rating
....

For each rater, the rater is on one line and a list of one or more restaurants and integer ratings appear on the next line separated by commas, if there is more than one. Each place is one word and each rating is one number.

Return values

The call processdata(filename) must return two things:

itemlist a list of items (restaurants) being rated: [ "restaurant", "restaurant", ... ]

ratingsdict a dictionary of raters and their ratings of the restaurants:

{"ratername" : [integer ratings for each restaurant],
 "ratername" : [integer ratings for each restaurant], ...
}


BookReader.py

Function: processdata( booktitles, bookratings ) : The function must read data about books and raters and return the information in a list and dictionary. (see details)

The booktitles argument must be a txt file of books (supplied with the snarf or here) with an author and the corresponding book title on the same line. The format is line number, followed by "::", followed by author, followed by "::", followed by title of book:
1::author::bookTitle
2::author::bookTitle
3::author::bookTitle
....

The bookratings argument must be a txt file of raters (supplied with the snarf or here) with each line having the name of a rater followed by a rating for all the books (with 0 if not rated) with each rating on a separate line.
ratername
rating
rating
...
rating
ratername
rating
rating
...
rating
ratername
rating
rating
...
rating
....

Return values

The call processdata( booktitles, bookratings ) must return two things:

itemlist a list of books being rated (combine each author and title into a string "title,author"
[ "title,author", "title,author", ... ]

raterdict a dictionary of raters and their ratings of the books:

{"ratername" : [integer ratings for each book],
 "ratername" : [integer ratings for each book], ...
}


ReadMovies.py

Function: processdata( movieratings )
(see details)

The movieratings argument must be a txt file of movies (supplied with the snarf or here) in the format of one movie rating per line with three pieces of information: rater, rating, and movietitle, in that order, with the parenthesis around each field. Note that movietitles may have blanks in them.
(ratername)(title)(rating)
(ratername)(title)(rating)
(ratername)(title)(rating)
...

Return values

The processdata( movieratings ) must return two things:

itemlist a list of movies being rated:  [ "title ", "title ", "title ", ... ]
(see details and examples here)

ratingsdict a dictionary of raters and their ratings of the movies:

{"ratername" : [integer ratings for each movie],
 "ratername" : [integer ratings for each movie], ...
}

Note that all three functions processdata return the same types: a list of strings (each item being rated) and a dictionary in which keys are raters and values are lists of integer ratings by each rater.


Recommender.py

In the module Recommender.py you must write the three functions shown in the details pages: averages, similarities, and recommended. Each of these will be used for comparing ratings of restaurants, movies and books in other programs, that is, all three of these will be imported into other Python modules.

Here is briefly what each of these do, with more detail for each on the details page.


RecommenderFood.py

This is the main program for restaurant recommendations. It should read in the file of restaurant recommendations and then call processdata in ReadFood.py to get the list of restaurants and the dictionary of raters and their ratings.

Then it will call the functions in Recommender to find out what the average rating is for each restaurant, find top raters who are similar to another rater, and give recommendations to a rater.

In particular, it should produce the following output. For all three make sure your output is easily identifiable and understandable.

(See details)



RecommenderBooks.py

This is the main program for book recommendations. It should read in the files of book recommendations and then call processdata in ReadBooks.py to get the list of books and authors, and the dictionary of raters and their ratings.

Then it will call the functions in Recommender to find out what the average rating is for each book, find top raters who are similar to another rater, and give recommendations to a rater.

In particular, it should produce the following output. For all three make sure your output is easily identifiable and understandable.

(See details)



RecommenderMovies.py

This is the main program for movie recommendations. It should read in the file of movie recommendations and then call processdata in ReadMovies.py to get the list of movies and the dictionary of raters and their ratings.

Then it will call the functions in Recommender to find out what the average rating is for each movie, find top raters who are similar to another rater, and give recommendations to a rater.

In particular, it should produce the following output. For all three make sure your output is easily identifiable and understandable.

(See details)



Next 'details'