def recommend():
    user_input = dict(request.args)

    """Here is where you take the user input dictionary and pre-process it
       for your recommendation function"""

    # movies = nmf_recommend(user_input)
    movies = random_recommend(MOVIES, 5)
    return render_template('recommendation.html', movies=movies)
Beispiel #2
0
def recommend():
    user_response = dict(request.args)
    print(user_response)

    #movies = random_recommend(user_input)
    movies = random_recommend(user_response)
    return render_template('recommendation.html', movies=movies)

    def __repr__(self):

        return '{} - {}'.format(self.iso, self.name)

    def as_dict(self):
        return {'name': self.name}
Beispiel #3
0
def recommender():
    #by default, request.args is an ImmutableMultiDict
    #where keys --> names from HTML form, and vals ---> user input
    user_input = dict(request.args)
    user_input_movies = list(user_input.values())[::2]
    user_input_ratings = list(user_input.values())[1::2]
    user_input_movies2 = []
    """YOUR TASK:"""

    #Write a python function (or multiple) that does the following:
    # 1. Take in user input from the HTML form (dictionary)
    # 2. Map the movies to the database / dataframe
    # 3. Convert the input into a New User Array (601st), with length of ~9000
    # 4. Then use the components of the pre-trained NMF to transform this array (predict)
    # 5. Map the resulting movie "recommendations" to real names.
    # 6. Return the names (e.g. list)

    MOVIES = [
        x[:-7] for x in (pd.read_csv('movies.csv'))['title'].values.tolist()
    ]

    #check =  all(item in user_input_movies for item in MOVIES)
    #[True if x in MOVIES else False for x in user_input_movies]
    userprintout = [
        x if x in MOVIES else 'sorry: This movie does not exist'
        for x in user_input_movies
    ]
    user_input2 = zip(userprintout, user_input_ratings)
    result_list = random_recommend(user_input_movies, user_input_ratings)

    #    if check==True:
    #    elif check==False:
    #        user_input2 = dictionary

    #        yield user_input2

    return render_template('recommender.html',
                           result_html=result_list,
                           user_input_html=user_input2)
Beispiel #4
0
def recommender():
    user_input = request.args
    result_list = random_recommend(8)
    return render_template('recommender.html',
                           result_html=result_list,
                           user_input=user_input)