forked from AishiniB/C12_Movie_Recommender
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest2.py
More file actions
56 lines (49 loc) · 2.47 KB
/
test2.py
File metadata and controls
56 lines (49 loc) · 2.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import streamlit as st
from movie_rec import get_top_movies_by_genre, get_movie_recommendations, movie_recommendation, hybrid
def main():
st.title('Movie Recommender App')
st.sidebar.title('Navigation')
# Sidebar options
menu = st.sidebar.selectbox('Menu', ['Top Movies by Genre', 'Movie Recommendations', 'User-based Recommendations', 'Hybrid Recommendations'])
if menu == 'Top Movies by Genre':
st.header('Top Movies by Genre')
# Genre selection
genres = st.multiselect('Select Genre(s)',
['Action', 'Adventure', 'Animation', 'Comedy', 'Crime', 'Documentary', 'Drama',
'Family', 'Fantasy', 'History', 'Horror', 'Music', 'Mystery', 'Romance',
'Science Fiction', 'TV Movie', 'Thriller', 'War', 'Western'], default=['Action'])
if st.button('Get Top Movies'):
top_movies = get_top_movies_by_genre(genres)
st.table(top_movies)
elif menu == 'Movie Recommendations':
st.header('Movie Recommendations')
# Movie name input
movie_name = st.text_input('Enter Movie Name', 'The Dark Knight')
if st.button('Get Recommendations'):
if movie_name.strip() == '':
st.warning('Please enter a movie name.')
else:
recommendations = get_movie_recommendations(movie_name)
st.write(recommendations)
elif menu == 'User-based Recommendations':
st.header('User-based Recommendations')
# User ID input
user_id = st.number_input('Enter User ID', min_value=1, max_value=610, value=1, step=1)
if st.button('Get Recommendations'):
recommendations = movie_recommendation(user_id)
if recommendations.empty:
st.warning('No recommendations found for the given user ID.')
else:
st.write(recommendations)
elif menu == 'Hybrid Recommendations':
st.header('Hybrid Movie Recommendations')
user_id = st.number_input('Enter User ID', min_value=1, max_value=610, value=1, step=1)
movie_name = st.text_input('Enter Movie Name', 'The Dark Knight')
if st.button('Get Recommendations'):
if movie_name.strip() == '':
st.warning('Please enter a movie name.')
else:
recommendations = hybrid(user_id, movie_name)
st.write(recommendations)
if __name__ == '__main__':
main()