import pandas as pd import numpy as np import joblib import streamlit as st cosine_sim=joblib.load('model_movie_recomadation_sigmoid.joblib') indices_df=pd.read_csv('indices.csv') html_temp = """

Movie Recomandation APP

""" st.markdown(html_temp, unsafe_allow_html=True) image_url="https://tse1.mm.bing.net/th?id=OIP.T1nYWZh17oT5wuISslNzdwHaEK&pid=Api&P=0&h=180" st.image(image_url, use_container_width=True) st.markdown(f""" """, unsafe_allow_html=True) def get_recommendations(title, cosine_sim=cosine_sim): # Get the index of the movie that matches the title filtered_df = indices_df[indices_df.apply(lambda row: row.astype(str).str.contains(movie, case=False).any(), axis=1)].index sim_scores = list(enumerate(cosine_sim[filtered_df])) index, values = sim_scores[0] result = list(zip(range(len(values)), values)) # Sort the movies based on the similarity scores result_sorted = sorted(result, key=lambda x: x[1], reverse=True) # Get the scores of the 10 most similar movies sim_scores = result_sorted[1:11] # Get the movie indices ##global movie_indices movie_indices = [i[0] for i in sim_scores] #Return the top 10 most similar movies return movie_indices movie=st.text_input("Enter the Movie Tittle") if st.button("Search"): val=get_recommendations(movie) st.dataframe(indices_df.iloc[val])