<jupyter_start><jupyter_text>![alt text](popcorn.png "Title")<jupyter_code>import ipywidgets as widgets
import pandas as pd
from IPython.display import display


df_predict= pd.read_csv('df_predict')
movie_title_list=df_predict["movie_title"].to_list()

w =widgets.Dropdown(
    placeholder='Choose movie',
    options=movie_title_list,
    description='movie :',
    disabled=False
)

output = widgets.Output()
@output.capture(clear_output=False,wait=True) # based on https://github.com/jupyter-widgets/ipywidgets/issues/1846 and https://ipywidgets.readthedocs.io/en/latest/examples/Output%20Widget.html
def dropdown_eventhandler(change):
   print('for movie : {}'.format(change.new) )

   cluster=df_predict[df_predict.movie_title==change.new].predict.values
   column ="dist_"+str(cluster[0])
   print('we could recommend you :\n{} '.format('\n'.join(df_predict.nsmallest(5,column )["movie_title"].values)))
   #print(df_predict.nsmallest(5,column )["movie_title"])
   
w.observe(dropdown_eventhandler, names='value')

display(w)
output<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14780168381665107, 'fraction_numerical': 0.00841908325537886, 'mean_word_length': 6.753623188405797, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '549664', 'license': 'Apache-2.0', 'n_tokens_mistral': 388, 'n_tokens_neox': 367, 'n_words': 53, 'path': 'app.ipynb', 'repo_name': 'cpailhes/filmrecommendation', 'size': '1069'}