def get_prediction(user_id): movie_to_predict = raw_input("What is the ID# of the movie for which you want a prediction? ") prediction = IIDH.predict_rating(int(movie_to_predict), user_id) print(prediction) user_answer = raw_input("Do you want to see another prediction? ") if user_answer == "yes": get_prediction(user_id) else: main_menu(user_id)
def get_top_ten(user_id): print "Calculating Top Ten...\n" already_rated = set(sum(IIDH.database_query("SELECT movie FROM ratings WHERE user = {0}".format(user_id)), ())) all_movies = set(sum(IIDH.database_query("SELECT id FROM movies"), ())) difference = all_movies - already_rated difference_list = list(difference) ratings = [] for item in difference_list: prediction = IIDH.predict_rating(item, user_id) ratings.append([item, prediction]) ratings.sort(key=lambda x: x[1], reverse=True) print "Your Top Ten unseen movies are:" for i in range(10): movie_title = IIDH.database_query("SELECT title FROM movies WHERE id = {0}".format(ratings[i][0])) print "{0}. {1} - {2}".format(i+1, movie_title[0][0], ratings[i][1]) raw_input("\nPress ENTER to return to Main Menu") main_menu(user_id)