Example #1
0
def predict(movie_id):
    target_movie = Movie.get(movie_id)
    #target_movie = get_movie(movie_id)
    target_ratings = make_target_ratings(movie_id)
    # target_movie_rating = rating
    my_movie_ids = movie_ids(0)

    movies_to_compare = []
    for id in my_movie_ids:
        ratings = make_target_ratings(id)
        movies_to_compare.append(ratings)

    similarities = []

    for ratings in movies_to_compare:
        our_rating = ratings[0] # ratings is not a list, it is a dictionary
        similarity = pearson(target_ratings, ratings)
        tup = (similarity, our_rating)
        similarities.append(tup)

    # (similarity, ranking)

    top_five = sorted(similarities)
    top_five.reverse()
    top_five = top_five[:5]
    num = 0.0
    den = 0.0
    # Use a weighted mean rather than a strict top similarity
    for sim, m in top_five:
        num += (float(sim) * m)
        den += sim

    rating = num/den
    return "%.2f" %(rating)
Example #2
0
def movie_details(movie_id):
	movie_id = int(movie_id)
	movie = Movie.get(movie_id)
	title = movie["title"]
	genres = movie["genres"]
	genre = ", ".join(genres)
	imdb = movie["imdb_url"]
	movie_id = movie["_id"]
	rating_records = Rating.get_many(movie_id)
	ratings = [ rec['rating'] for rec in rating_records ]
	avg = float(sum(ratings))/len(ratings)
	return render_template("movie_details.html", title=title, genre=genre, avg=avg, imdb=imdb, movie=movie)
Example #3
0
def home():
	movie_ids=[]
	ratings=[]
	while len(movie_ids) < 10:
		movie_id = randint(1,1682)
		movie = Movie.get(movie_id)
		movie_ids.append(movie)
		
		movie_id = movie["_id"]
		rating_records = Rating.get_many(movie_id)
		rating = [ rec['rating'] for rec in rating_records ]
		avg = float(sum(rating))/len(rating)
		ratings.append(avg)

	return render_template("potato.html", ratings=ratings, movie_ids=movie_ids)
Example #4
0
def get_movie(movie_id):
    return Movie.get(movie_id)
Example #5
0
def average_rating(movie_id):
    movie = Movie.get(movie_id)
    avg = movie.get_average()
    print "%.1f stars"%(avg)
Example #6
0
def movie_details():
	movie_id = request.form['movie_id']
	movie = Movie.get(int(movie_id))
	return render_template("movie_details.html", movie=movie)