|
import streamlit as st |
|
import numpy as np |
|
import pandas as pd |
|
|
|
final_movie_df = pd.read_csv('movie_data.csv') |
|
|
|
similarity = np.load("similarity.npy") |
|
|
|
def recomendMovie(movie_title) : |
|
matching_indices = final_movie_df[final_movie_df['title'].str.contains(movie_title, case=False, na=False)].index |
|
if not matching_indices.empty: |
|
distance = similarity[matching_indices[0]] |
|
|
|
movie_list = sorted(list(enumerate(distance)), reverse=True, key = lambda x: x[1])[1:6] |
|
output_list = [] |
|
for movie in movie_list: |
|
output_list.append(final_movie_df.iloc[movie[0]].title) |
|
return pd.DataFrame({ |
|
'movie_name' : output_list |
|
}) |
|
else: |
|
return "This movie isn't present in the dataset." |
|
|
|
st.title('Get recommendation related to your favourite movies πΏ π¬') |
|
name = st.text_input("Enter Movie name: ") |
|
if name != "": |
|
output = recomendMovie(name) |
|
st.dataframe(output, use_container_width=True) |