def update_multi_output(n_clicks, *input_value): ctx = dash.callback_context if not ctx.triggered: user_click = 'No clicks yet' else: user_click = ctx.triggered[0]['prop_id'].split('.')[0] if n_clicks is not None and n_clicks > 0: list_filter = list(input_value) user_id = int(list_filter[0]) print(user_id) list_next_movie_id = [] movie_names = cop[user_id] # movie_names = cop.user_recommendation_dic[user_id] for mn in movie_names: print(mn) if mn in id_title_set: #print(id_title_set[mn]) list_next_movie_id.append(int(id_title_set[mn])) print(list_next_movie_id) ls = [] for ids in list_next_movie_id: if ids in id_set: ls.append(ids) list_next_movie_id = ls num_movie_rate = len(list_next_movie_id) print(list_next_movie_id) result = display_final_movie.add_final_movies(zip(range(num_movie_rate), list_next_movie_id)) return result else: raise PreventUpdate
def update_multi_output(n_clicks, *input_value): ctx = dash.callback_context if not ctx.triggered: user_click = 'No clicks yet' else: user_click = ctx.triggered[0]['prop_id'].split('.')[0] if n_clicks is not None and n_clicks > 0: list_filter = str(list(input_value)[0]) print(list_filter) recommend = CP.get_recommended_movies(list_filter) #print(recommend) movie_names = recommend['title'].values.tolist() #print(movie_names) list_next_movie_id = [] for mn in movie_names: #print(mn) #print(ID_TITLE_SET[mn]) if mn in ID_TITLE_SET: list_next_movie_id.append(int(ID_TITLE_SET[mn])) #print(list_next_movie_id) ls = [] for ids in list_next_movie_id: if ids in ID_SET: ls.append(ids) #list_next_movie_id = [862 if r == 2000 else 2 for r in list_filter] list_next_movie_id = ls print(list_next_movie_id) result = display_final_movie.add_final_movies(zip(range(len(list_next_movie_id)), list_next_movie_id)) return result else: raise PreventUpdate
def update_multi_output(n_clicks, *input_value): if n_clicks is not None and n_clicks > 0: list_filter = list(input_value) #print(list_filter) for i in range(len(list_filter)): list_filter[i] = str(list_filter[i]) if list_filter[i] == "All": list_filter[i] = None #print(list_filter) recommend = SP.get_recommended_movies(list_filter) #print(recommend) movie_names = recommend['title'].values.tolist() #print(movie_names) list_next_movie_id = [] for movie_name in movie_names: if movie_name in ID_TITLE_SET: list_next_movie_id.append(int(ID_TITLE_SET[movie_name])) print(list_next_movie_id) list_movie_id = [] for ids in list_next_movie_id: if ids in ID_SET: list_movie_id.append(ids) list_next_movie_id = list_movie_id result = display_final_movie.add_final_movies( zip(range(len(list_next_movie_id)), list_next_movie_id)) return result else: raise PreventUpdate
def add_popularity_filter(): movie_div = display_final_movie.add_final_movies( zip(range(num_final_recommend), global_record.initial_movie_id_list[10:(10 + num_final_recommend)])) filter_drop_down = [] for f in filter_options: filter_drop_down.append( html.Div( children=[ html.Div(str(f), style={ 'text-align': 'center', 'font-size': '14px', 'margin-bottom': '20px' }), dcc.Dropdown( id=f, options=get_option(f), value="All", # multi=True, style={ 'text-align': 'left', 'font-size': '12px' }, placeholder="Select a " + str(f)) ], style={ 'width': '15%', 'margin-left': '4%', # 'padding-left': '10%', # 'padding-right': '10%', 'display': 'inline-block', 'color': colors['text'] })) app_popularity_tab = html.Div(children=[]) app_popularity_tab.children.append( html.Div(html.H1('Simple Filtering'), className='wrap')) app_popularity_tab.children.append( html.Div(filter_drop_down, style={'margin-top': '10px'})) filter_button_div = html.Div(html.Button(id='popularity_filter_button', children='Filter', style={'font-size': '13px'}), style={ 'margin-top': '50px', 'margin-bottom': '20px', 'width': '40%', 'padding-left': '45%', 'padding-right': '15%' }) app_popularity_tab.children.append(filter_button_div) app_popularity_tab.children.append( html.Div(id='popularity_main_div', children=movie_div)) return app_popularity_tab
def add_popularity_filter(): """ :return: a html div with all content to be displayed for the simple filtering, including, a div with drop down boxes, filter button, and movies with their info """ movie_div = display_final_movie.add_final_movies( zip(range(NUM_FINAL_RECOMMEND), global_record.INITIAL_MOVIE_ID_LIST[10:(10 + NUM_FINAL_RECOMMEND)])) filter_drop_down = [] for filter_option in FILTER_OPTIONS: filter_drop_down.append(html.Div( children=[ html.Div(str(filter_option), style={'text-align': 'center', 'font-size': '14px', 'margin-bottom': '20px'}), dcc.Dropdown( id=filter_option, options=get_option(filter_option), value="All", # multi=True, style={'text-align': 'left', 'font-size': '12px'}, placeholder="Select a " + str(filter_option))], style={ 'width': '15%', 'margin-left': '4%', # 'padding-left': '10%', # 'padding-right': '10%', 'display': 'inline-block', 'color': COLOR['text']})) app_popularity_tab = html.Div(children=[]) app_popularity_tab.children.append(html.Div(html.H1('Simple Filtering'), className='wrap')) app_popularity_tab.children.append(html.Div(filter_drop_down, style={'margin-top': '10px'})) filter_button_div = html.Div(html.Button(id='popularity_filter_button', children='Filter', style={'font-size': '13px'}), style={'margin-top': '50px', 'margin-bottom': '20px', 'width': '40%', 'padding-left': '45%', 'padding-right': '15%'}) app_popularity_tab.children.append(filter_button_div) app_popularity_tab.children.append(html.Div(id='popularity_main_div', children=movie_div)) return app_popularity_tab
def main(): """ :return: a html div with all content to be displayed for the user-based filtering, including, a div with drop down boxes, find user button, and movies with their info """ movie_div = display_final_movie.add_final_movies( zip(range(NUM_FINAL_RECOMMEND), global_record.INITIAL_MOVIE_ID_LIST[10:(10 + NUM_FINAL_RECOMMEND)])) search_bar = html.Div(children=[ html.Div(children='Please type a user ID', style={ 'text-align': 'center', 'font-size': '16px', 'margin-bottom': '20px' }), html.Div( dcc.Input(id='user_id_dropdown'.format(), type='number', placeholder="Please enter a user id", style={ 'font-size': '13px', 'width': '100%' })) ]) search_button_div = html.Div(html.Button(id='user_id_button', children='Find User', style={'font-size': '13px'}), style={ 'margin-top': '50px', 'margin-bottom': '20px', 'width': '40%', 'margin-left': '30%', 'text-align': 'center' }) app_recommender_tab = html.Div(children=[]) app_recommender_tab.children.append( html.Div(html.H1('User-based Filtering'), className='wrap')) app_recommender_tab.children.append( html.Div(search_bar, style={'margin-top': '15px'})) app_recommender_tab.children.append(search_button_div) app_recommender_tab.children.append( html.Div(id='recommend_main_div', children=movie_div)) return app_recommender_tab
def add_search_bar(): movie_div = display_final_movie.add_final_movies( zip(range(num_final_recommend), global_record.initial_movie_id_list[10:(10 + num_final_recommend)])) search_bar = html.Div(children=[ html.Div(children='Please type a movie', style={ 'text-align': 'center', 'font-size': '16px', 'margin-bottom': '20px' }), html.Div( dcc.Dropdown( id='movie_search_dropdown', options=name_val, # multi=True, placeholder="Please select/type a movie"), style={ 'text-align': 'center', 'font-size': '16px' }) ]) app_filter_tab = html.Div(children=[]) app_filter_tab.children.append( html.Div(html.H1('Content-based Filtering'), className='wrap')) app_filter_tab.children.append( html.Div(search_bar, style={'margin-top': '15px'})) search_button_div = html.Div(html.Button(id='search_similar_button', children='Find Similar Movies', style={'font-size': '13px'}), style={ 'margin-top': '50px', 'margin-bottom': '20px', 'width': '40%', 'margin-left': '30%', 'text-align': 'center' }) app_filter_tab.children.append(search_button_div) app_filter_tab.children.append( html.Div(id='content_base_main_div', children=movie_div)) return app_filter_tab
def main(): movie_div = display_final_movie.add_final_movies(zip(range(num_final_recommend), global_record.initial_movie_id_list[10:(10+num_final_recommend)])) global_record.set_curr_movie_id_list(global_record.initial_movie_id_list) search_bar = html.Div( children=[ html.Div(children='Please type a user ID', style={'text-align': 'center', 'font-size': '16px', 'margin-bottom': '20px'}), html.Div(dcc.Input( id='user_id_dropdown'.format(), type='number', placeholder="Please enter a user id", style={'font-size': '13px', 'width': '100%'} )) # html.Div(dcc.Dropdown( # id='user_id_dropdown', # options=user_val, # # multi=True, # placeholder="Please select/type a user id")) ] ) search_button_div = html.Div(html.Button(id='user_id_button', children='Find User', style={'font-size': '13px'}), style={'margin-top': '50px', 'margin-bottom': '20px', 'width': '40%', 'margin-left': '30%', 'text-align': 'center'}) app_recommender_tab = html.Div(children=[]) app_recommender_tab.children.append(html.Div(html.H1('User-based Filtering'), className='wrap')) app_recommender_tab.children.append(html.Div(search_bar, style={'margin-top': '15px'})) app_recommender_tab.children.append(search_button_div) app_recommender_tab.children.append(html.Div(id='recommend_main_div', children=movie_div)) return app_recommender_tab
def update_multi_output(n_clicks, *input_value): ctx = dash.callback_context if not ctx.triggered: user_click = 'No clicks yet' else: user_click = ctx.triggered[0]['prop_id'].split('.')[0] if n_clicks is not None and n_clicks > 0: list_filter = list(input_value) #print(list_filter) for i in range(len(list_filter)): list_filter[i] = str(list_filter[i]) if list_filter[i] == "All": list_filter[i] = None #print(list_filter) recommend = sp.get_recommended_movies(list_filter) #print(recommend) movie_names = recommend['title'].values.tolist() #print(movie_names) list_next_movie_id = [] for mn in movie_names: print(mn) #print(id_title_set[mn]) if mn in id_title_set: list_next_movie_id.append(int(id_title_set[mn])) print(list_next_movie_id) ls = [] for ids in list_next_movie_id: if ids in id_set: ls.append(ids) # TODO: call backend to filter here (param is a list: 'Genre', 'Year', 'Country', 'Director', 'Actors') #list_next_movie_id = [862 if r == 2000 else 2 for r in list_filter] list_next_movie_id = ls #print(list_next_movie_id) result = display_final_movie.add_final_movies( zip(range(len(list_next_movie_id)), list_next_movie_id)) return result else: raise PreventUpdate
def add_search_bar(): """ :return: a html div with all content to be displayed for the content-based filtering, including, a div with drop down boxes, Find Similar Movies button, and movies with their info """ movie_div = display_final_movie.add_final_movies(zip(range(NUM_FINAL_RECOMMEND), global_record.INITIAL_MOVIE_ID_LIST[10:(10 + NUM_FINAL_RECOMMEND)])) search_bar = html.Div( children=[ html.Div(children='Please type a movie', style={'text-align': 'center', 'font-size': '16px', 'margin-bottom': '20px'}), html.Div(dcc.Dropdown( id='movie_search_dropdown', options=NAME_VAL, # multi=True, placeholder="Please select/type a movie"), style={'text-align': 'center', 'font-size': '16px'}) ] ) app_filter_tab = html.Div(children=[]) app_filter_tab.children.append(html.Div(html.H1('Content-based Filtering'), className='wrap')) app_filter_tab.children.append(html.Div(search_bar, style={'margin-top': '15px'})) search_button_div = html.Div(html.Button(id='search_similar_button', children='Find Similar Movies', style={'font-size': '13px'}), style={'margin-top': '50px', 'margin-bottom': '20px', 'width': '40%', 'margin-left': '30%', 'text-align': 'center'}) app_filter_tab.children.append(search_button_div) app_filter_tab.children.append(html.Div(id='content_base_main_div', children=movie_div)) return app_filter_tab