MohamedMotaz commited on
Commit
9233f56
1 Parent(s): fb3c979

first commit

Browse files
Data/README.txt ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Summary
2
+ =======
3
+
4
+ This dataset (ml-latest-small) describes 5-star rating and free-text tagging activity from [MovieLens](http://movielens.org), a movie recommendation service. It contains 100836 ratings and 3683 tag applications across 9742 movies. These data were created by 610 users between March 29, 1996 and September 24, 2018. This dataset was generated on September 26, 2018.
5
+
6
+ Users were selected at random for inclusion. All selected users had rated at least 20 movies. No demographic information is included. Each user is represented by an id, and no other information is provided.
7
+
8
+ The data are contained in the files `links.csv`, `movies.csv`, `ratings.csv` and `tags.csv`. More details about the contents and use of all these files follows.
9
+
10
+ This is a *development* dataset. As such, it may change over time and is not an appropriate dataset for shared research results. See available *benchmark* datasets if that is your intent.
11
+
12
+ This and other GroupLens data sets are publicly available for download at <http://grouplens.org/datasets/>.
13
+
14
+
15
+ Usage License
16
+ =============
17
+
18
+ Neither the University of Minnesota nor any of the researchers involved can guarantee the correctness of the data, its suitability for any particular purpose, or the validity of results based on the use of the data set. The data set may be used for any research purposes under the following conditions:
19
+
20
+ * The user may not state or imply any endorsement from the University of Minnesota or the GroupLens Research Group.
21
+ * The user must acknowledge the use of the data set in publications resulting from the use of the data set (see below for citation information).
22
+ * The user may redistribute the data set, including transformations, so long as it is distributed under these same license conditions.
23
+ * The user may not use this information for any commercial or revenue-bearing purposes without first obtaining permission from a faculty member of the GroupLens Research Project at the University of Minnesota.
24
+ * The executable software scripts are provided "as is" without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of them is with you. Should the program prove defective, you assume the cost of all necessary servicing, repair or correction.
25
+
26
+ In no event shall the University of Minnesota, its affiliates or employees be liable to you for any damages arising out of the use or inability to use these programs (including but not limited to loss of data or data being rendered inaccurate).
27
+
28
+ If you have any further questions or comments, please email <grouplens-info@umn.edu>
29
+
30
+
31
+ Citation
32
+ ========
33
+
34
+ To acknowledge use of the dataset in publications, please cite the following paper:
35
+
36
+ > F. Maxwell Harper and Joseph A. Konstan. 2015. The MovieLens Datasets: History and Context. ACM Transactions on Interactive Intelligent Systems (TiiS) 5, 4: 19:1–19:19. <https://doi.org/10.1145/2827872>
37
+
38
+
39
+ Further Information About GroupLens
40
+ ===================================
41
+
42
+ GroupLens is a research group in the Department of Computer Science and Engineering at the University of Minnesota. Since its inception in 1992, GroupLens's research projects have explored a variety of fields including:
43
+
44
+ * recommender systems
45
+ * online communities
46
+ * mobile and ubiquitious technologies
47
+ * digital libraries
48
+ * local geographic information systems
49
+
50
+ GroupLens Research operates a movie recommender based on collaborative filtering, MovieLens, which is the source of these data. We encourage you to visit <http://movielens.org> to try it out! If you have exciting ideas for experimental work to conduct on MovieLens, send us an email at <grouplens-info@cs.umn.edu> - we are always interested in working with external collaborators.
51
+
52
+
53
+ Content and Use of Files
54
+ ========================
55
+
56
+ Formatting and Encoding
57
+ -----------------------
58
+
59
+ The dataset files are written as [comma-separated values](http://en.wikipedia.org/wiki/Comma-separated_values) files with a single header row. Columns that contain commas (`,`) are escaped using double-quotes (`"`). These files are encoded as UTF-8. If accented characters in movie titles or tag values (e.g. Misérables, Les (1995)) display incorrectly, make sure that any program reading the data, such as a text editor, terminal, or script, is configured for UTF-8.
60
+
61
+
62
+ User Ids
63
+ --------
64
+
65
+ MovieLens users were selected at random for inclusion. Their ids have been anonymized. User ids are consistent between `ratings.csv` and `tags.csv` (i.e., the same id refers to the same user across the two files).
66
+
67
+
68
+ Movie Ids
69
+ ---------
70
+
71
+ Only movies with at least one rating or tag are included in the dataset. These movie ids are consistent with those used on the MovieLens web site (e.g., id `1` corresponds to the URL <https://movielens.org/movies/1>). Movie ids are consistent between `ratings.csv`, `tags.csv`, `movies.csv`, and `links.csv` (i.e., the same id refers to the same movie across these four data files).
72
+
73
+
74
+ Ratings Data File Structure (ratings.csv)
75
+ -----------------------------------------
76
+
77
+ All ratings are contained in the file `ratings.csv`. Each line of this file after the header row represents one rating of one movie by one user, and has the following format:
78
+
79
+ userId,movieId,rating,timestamp
80
+
81
+ The lines within this file are ordered first by userId, then, within user, by movieId.
82
+
83
+ Ratings are made on a 5-star scale, with half-star increments (0.5 stars - 5.0 stars).
84
+
85
+ Timestamps represent seconds since midnight Coordinated Universal Time (UTC) of January 1, 1970.
86
+
87
+
88
+ Tags Data File Structure (tags.csv)
89
+ -----------------------------------
90
+
91
+ All tags are contained in the file `tags.csv`. Each line of this file after the header row represents one tag applied to one movie by one user, and has the following format:
92
+
93
+ userId,movieId,tag,timestamp
94
+
95
+ The lines within this file are ordered first by userId, then, within user, by movieId.
96
+
97
+ Tags are user-generated metadata about movies. Each tag is typically a single word or short phrase. The meaning, value, and purpose of a particular tag is determined by each user.
98
+
99
+ Timestamps represent seconds since midnight Coordinated Universal Time (UTC) of January 1, 1970.
100
+
101
+
102
+ Movies Data File Structure (movies.csv)
103
+ ---------------------------------------
104
+
105
+ Movie information is contained in the file `movies.csv`. Each line of this file after the header row represents one movie, and has the following format:
106
+
107
+ movieId,title,genres
108
+
109
+ Movie titles are entered manually or imported from <https://www.themoviedb.org/>, and include the year of release in parentheses. Errors and inconsistencies may exist in these titles.
110
+
111
+ Genres are a pipe-separated list, and are selected from the following:
112
+
113
+ * Action
114
+ * Adventure
115
+ * Animation
116
+ * Children's
117
+ * Comedy
118
+ * Crime
119
+ * Documentary
120
+ * Drama
121
+ * Fantasy
122
+ * Film-Noir
123
+ * Horror
124
+ * Musical
125
+ * Mystery
126
+ * Romance
127
+ * Sci-Fi
128
+ * Thriller
129
+ * War
130
+ * Western
131
+ * (no genres listed)
132
+
133
+
134
+ Links Data File Structure (links.csv)
135
+ ---------------------------------------
136
+
137
+ Identifiers that can be used to link to other sources of movie data are contained in the file `links.csv`. Each line of this file after the header row represents one movie, and has the following format:
138
+
139
+ movieId,imdbId,tmdbId
140
+
141
+ movieId is an identifier for movies used by <https://movielens.org>. E.g., the movie Toy Story has the link <https://movielens.org/movies/1>.
142
+
143
+ imdbId is an identifier for movies used by <http://www.imdb.com>. E.g., the movie Toy Story has the link <http://www.imdb.com/title/tt0114709/>.
144
+
145
+ tmdbId is an identifier for movies used by <https://www.themoviedb.org>. E.g., the movie Toy Story has the link <https://www.themoviedb.org/movie/862>.
146
+
147
+ Use of the resources listed above is subject to the terms of each provider.
148
+
149
+
150
+ Cross-Validation
151
+ ----------------
152
+
153
+ Prior versions of the MovieLens dataset included either pre-computed cross-folds or scripts to perform this computation. We no longer bundle either of these features with the dataset, since most modern toolkits provide this as a built-in feature. If you wish to learn about standard approaches to cross-fold computation in the context of recommender systems evaluation, see [LensKit](http://lenskit.org) for tools, documentation, and open-source code examples.
Data/links.csv ADDED
The diff for this file is too large to render. See raw diff
 
Data/movies.csv ADDED
The diff for this file is too large to render. See raw diff
 
Data/ratings.csv ADDED
The diff for this file is too large to render. See raw diff
 
Data/tags.csv ADDED
The diff for this file is too large to render. See raw diff
 
Deployment/app.py ADDED
@@ -0,0 +1,415 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests
3
+ import pandas as pd
4
+ import hashlib
5
+ import pickle
6
+ import gdown
7
+ import os
8
+
9
+ # CSV files URLs as raw data from GitHub repository
10
+ moviesCSV = "Data/movies.csv"
11
+ ratingsCSV = "Data/ratings.csv"
12
+ linksCSV = "Data/links.csv"
13
+
14
+ # the folloing code is used to download the similarity matrix from google drive if not exist
15
+ file_url = 'https://drive.google.com/file/d/1-1bpusE96_Hh0rUxU7YmBo6RiwYLQGVy/view?usp=sharing'
16
+ output_path = 'Models/similarity_matrix.pkl'
17
+
18
+ @st.cache_data
19
+ def download_model_from_google_drive(file_url, output_path):
20
+ gdown.download(file_url, output_path, quiet=False)
21
+
22
+
23
+ # # Check if the file already exists
24
+ if not os.path.exists(output_path):
25
+ print("Downloading the similarity matrix from Googlr Drive...")
26
+ # download_model_from_google_drive(file_url, output_path)
27
+
28
+
29
+ # Set page configuration
30
+ st.set_page_config(page_title="Movie Recommendation", page_icon="🎬", layout="wide")
31
+
32
+ # Dummy data for user recommendations
33
+ user_recommendations = {
34
+ "1": ["Inception", "The Matrix", "Interstellar"],
35
+ "2": ["The Amazing Spider-Man", "District 9", "Titanic"]
36
+ }
37
+
38
+ # Function to hash passwords
39
+ def hash_password(password):
40
+ return hashlib.sha256(password.encode()).hexdigest()
41
+
42
+ # Dummy user database
43
+ user_db = {
44
+ "1": hash_password("password123"),
45
+ "2": hash_password("mypassword")
46
+ }
47
+
48
+ # Login function
49
+ def login(email, password):
50
+ if email in user_db:
51
+ return True
52
+ return False
53
+
54
+ # Function to fetch movie details from OMDb API
55
+ def fetch_movie_details(title, api_key="23f109b2"):
56
+ url = f"http://www.omdbapi.com/?t={title}&apikey={api_key}"
57
+ response = requests.get(url)
58
+ return response.json()
59
+
60
+ # Display movie details
61
+ def display_movie_details(movie):
62
+ if movie['Response'] == 'False':
63
+ st.write(f"Movie not found: {movie['Error']}")
64
+ return
65
+ if movie['imdbRating'] == 'N/A':
66
+ movie['imdbRating'] = 0
67
+ imdb_rating = float(movie['imdbRating'])
68
+ url = f"https://www.imdb.com/title/{movie['imdbID']}/"
69
+ st.markdown(
70
+ f"""
71
+ <div style="
72
+ background-color: #313131;
73
+ border-radius: 15px;
74
+ padding: 10px;
75
+ margin: 10px 0;
76
+ box-shadow: 0px 4px 12px rgba(0, 0, 0, 0.1);
77
+ ">
78
+ <div style="display: flex;">
79
+ <div style="flex: 1;">
80
+ <BR>
81
+ <a href="{url}" target="_blank" >
82
+ <img src="{movie['Poster']}" style="width: 100%; border-radius: 10px;" />
83
+ </a>
84
+ </div>
85
+ <div style="flex: 3; padding-left: 20px;">
86
+ <h2 style="margin: 0;" anchor="{url}">{movie['Title']}</h2>
87
+ <p style="color: gray;">
88
+ <b>Year:</b> {movie['Year']} Rated: {movie['Rated']} <br>
89
+ <b>Genre:</b> {movie['Genre'].replace(',',' |')} <br>
90
+ </p>
91
+ <p>{movie['Plot']}</p>
92
+ <div style="margin-top: 10px;">
93
+ <div style="background-color: #e0e0e0; border-radius: 5px; overflow: hidden;">
94
+ <div style="width: {imdb_rating * 10}%; background-color: #4caf50; padding: 5px 0; text-align: center; color: white;">
95
+ {imdb_rating}
96
+ </div>
97
+ </div>
98
+ </div>
99
+ </div>
100
+ </div>
101
+ </div>
102
+ """, unsafe_allow_html=True
103
+ )
104
+
105
+
106
+
107
+
108
+ def print_movie_details(movie):
109
+ st.markdown(
110
+ f"""
111
+ <div class="recommendation">
112
+ <div style="display: flex;">
113
+ <div style="flex: 1;">
114
+ <a href="https://www.imdb.com/title/tt{movie['imdb_id']:07d}/" target="_blank">
115
+ <img src="{movie['poster_url']}" />
116
+ </a>
117
+ </div>
118
+ <div style="flex: 3; padding-left: 20px;">
119
+ <h4 style="margin: 0;">{' '.join(movie['title'].split(" ")[:-1])}</h4>
120
+ <p style="color: gray;">
121
+ <b>Year:</b> {movie['title'].split(" ")[-1]}<br>
122
+ <b>Genre:</b> {', '.join(movie['genres'])}<br>
123
+ <b>Number of Ratings:</b> {movie['num_ratings']}<br>
124
+ <b>IMDb Rating: </b>{round(movie["imdb_rating"],1)}<br>
125
+ </p>
126
+ <div style="margin-top: 10px;">
127
+ <div style="background-color: #e0e0e0; border-radius: 5px; overflow: hidden;">
128
+ <div style="width: {movie['avg_rating'] * 20}%; background-color: #4caf50; padding: 5px 0; text-align: center; color: white;">
129
+ {movie['avg_rating']}
130
+ </div>
131
+ </div>
132
+ </div>
133
+ </div>
134
+ </div>
135
+ </div>
136
+ """,
137
+ unsafe_allow_html=True
138
+ )
139
+
140
+
141
+
142
+ # Function to load data
143
+ @st.cache_data
144
+ def load_data():
145
+ movies_df = pd.read_csv(moviesCSV)
146
+ ratings_df = pd.read_csv(ratingsCSV)
147
+ links_df = pd.read_csv(linksCSV)
148
+ return movies_df, ratings_df, links_df
149
+
150
+ # Function to load similarity matrix
151
+ @st.cache_data
152
+ def load_similarity_matrix():
153
+ with open('Models/similarity_matrix.pkl', 'rb') as f:
154
+ similarity_df = pickle.load(f)
155
+ return similarity_df
156
+
157
+ # Function to get movie details
158
+ def get_movie_details(movie_id, df_movies, df_ratings, df_links):
159
+ try:
160
+ imdb_id = df_links[df_links['movieId'] == movie_id]['imdbId'].values[0]
161
+ tmdb_id = df_links[df_links['movieId'] == movie_id]['tmdbId'].values[0]
162
+
163
+ movie_data = df_movies[df_movies['movieId'] == movie_id].iloc[0]
164
+ genres = movie_data['genres'].split('|') if 'genres' in movie_data else []
165
+
166
+ avg_rating = df_ratings[df_ratings['movieId'] == movie_id]['rating'].mean()
167
+ num_ratings = df_ratings[df_ratings['movieId'] == movie_id].shape[0]
168
+
169
+ api_key = 'b8c96e534866701532768a313b978c8b'
170
+ response = requests.get(f'https://api.themoviedb.org/3/movie/{tmdb_id}?api_key={api_key}' )
171
+ poster_url = response.json().get('poster_path', '')
172
+ full_poster_url = f'https://image.tmdb.org/t/p/w500{poster_url}' if poster_url else ''
173
+ imdb_rating = response.json().get('vote_average', 0)
174
+
175
+ return {
176
+ "title": movie_data['title'],
177
+ "genres": genres,
178
+ "avg_rating": round(avg_rating, 2),
179
+ "num_ratings": num_ratings,
180
+ "imdb_id": imdb_id,
181
+ "tmdb_id": tmdb_id,
182
+ "poster_url": full_poster_url,
183
+ "imdb_rating": imdb_rating
184
+ }
185
+ except Exception as e:
186
+ st.error(f"Error fetching details for movie ID {movie_id}: {e}")
187
+ return None
188
+
189
+ # Function to recommend movies
190
+ def recommend(movie, similarity_df, movies_df, ratings_df, links_df, k=5):
191
+ try:
192
+ index = movies_df[movies_df['title'] == movie].index[0]
193
+ distances = sorted(list(enumerate(similarity_df.iloc[index])), reverse=True, key=lambda x: x[1])
194
+ recommended_movies = []
195
+ for i in distances[1:k+1]:
196
+ movie_id = movies_df.iloc[i[0]]['movieId']
197
+ movie_details = get_movie_details(movie_id, movies_df, ratings_df, links_df)
198
+ if movie_details:
199
+ recommended_movies.append(movie_details)
200
+ return recommended_movies
201
+ except Exception as e:
202
+ st.error(f"Error generating recommendations: {e}")
203
+ return []
204
+
205
+ # Main app
206
+
207
+ def main():
208
+ st.markdown(
209
+ """
210
+ <style>
211
+ body {
212
+ background-image: url("https://repository-images.githubusercontent.com/275336521/20d38e00-6634-11eb-9d1f-6a5232d0f84f");
213
+ color: #FFFFFF;
214
+ font-family: 'Arial', sans-serif;
215
+ }
216
+
217
+ .stApp {
218
+ background: rgba(0, 0, 0, 0.7);
219
+ border-radius: 15px;
220
+ padding: 20px;
221
+ }
222
+
223
+ .title {
224
+ font-size: 3em;
225
+ text-align: center;
226
+ margin-bottom: 20px;
227
+ font-weight: bold;
228
+ color: #FF0000;
229
+ }
230
+
231
+ .section-title {
232
+ font-size: 2em;
233
+ margin-top: 30px;
234
+ margin-bottom: 20px;
235
+ text-align: center;
236
+ color: #FFD700;
237
+ }
238
+
239
+ .recommendation {
240
+ border: 1px solid #FFD700;
241
+ padding: 20px;
242
+ margin-bottom: 20px;
243
+ border-radius: 15px;
244
+ box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
245
+ transition: transform 0.2s, box-shadow 0.2s;
246
+ background-color: rgba(0, 0, 0, 0.8);
247
+ overflow: hidden;
248
+ }
249
+
250
+ .recommendation:hover {
251
+ transform: translateY(-10px);
252
+ box-shadow: 0 8px 16px rgba(0, 0, 0, 0.5);
253
+ }
254
+
255
+ .recommendation img {
256
+ width: 100%;
257
+ height: 200px;
258
+ object-fit: cover;
259
+ border-radius: 10px;
260
+ margin-bottom: 10px;
261
+ }
262
+
263
+ .movie-details-container {
264
+ display: flex;
265
+ align-items: center;
266
+ margin-bottom: 20px;
267
+ }
268
+
269
+ .movie-details-container .movie-poster {
270
+ flex: 0 0 auto;
271
+ width: 30%;
272
+ margin-right: 20px;
273
+ }
274
+
275
+ .movie-details-container .movie-poster img {
276
+ width: 100%;
277
+ border-radius: 10px;
278
+ }
279
+
280
+ .movie-details-container .movie-details {
281
+ flex: 1 1 auto;
282
+ }
283
+
284
+ .movie-details-container .movie-details p {
285
+ margin: 5px 0;
286
+ }
287
+
288
+ a {
289
+ color: #FFD700;
290
+ text-decoration: none;
291
+ }
292
+
293
+ a:hover {
294
+ text-decoration: underline;
295
+ }
296
+
297
+ .stSidebar .element-container {
298
+ background: rgba(0, 0, 0, 0.7);
299
+ border-radius: 15px;
300
+ padding: 15px;
301
+ }
302
+
303
+ .stSidebar .stButton button {
304
+ background-color: #FFD700;
305
+ color: #000;
306
+ border: none;
307
+ border-radius: 10px;
308
+ padding: 10px;
309
+ transition: background-color 0.2s, transform 0.2s;
310
+ }
311
+
312
+ .stSidebar .stButton button:hover {
313
+ background-color: #FFAA00;
314
+ transform: scale(1.05);
315
+ }
316
+ </style>
317
+ """,
318
+ unsafe_allow_html=True
319
+ )
320
+
321
+ movies_df, ratings_df, links_df = load_data()
322
+ similarity_df = load_similarity_matrix()
323
+
324
+ st.sidebar.title("Navigation")
325
+ menu = ["Login", "Movie Similarity"]
326
+ choice = st.sidebar.selectbox("Select an option", menu)
327
+
328
+ if choice == "Login":
329
+ st.title("Movie Recommendations")
330
+ st.write("Welcome to the Movie Recommendation App!")
331
+ st.write("Please login to get personalized movie recommendations. username between (1 and 800)")
332
+ st.write("leve password blank for now.")
333
+
334
+ # Login form
335
+ st.sidebar.header("Login")
336
+ email = st.sidebar.text_input("Username")
337
+ # password = st.sidebar.text_input("Password", type="password")
338
+ if st.sidebar.button("Login"):
339
+ if login(email, 'password'):
340
+ st.sidebar.success("Login successful!")
341
+ recommendations = user_recommendations.get(email, [])
342
+ st.write(f"Recommendations for user number {email}:")
343
+ num_cols = 2
344
+ cols = st.columns(num_cols)
345
+ for i, movie_title in enumerate(recommendations):
346
+ movie = fetch_movie_details(movie_title)
347
+ if movie['Response'] == 'True':
348
+ with cols[i % num_cols]:
349
+ display_movie_details(movie)
350
+ else:
351
+ st.write(f"Movie details for '{movie_title}' not found.")
352
+ else:
353
+ st.sidebar.error("Invalid email or password")
354
+
355
+ elif choice == "Movie Similarity":
356
+ num_cols = 2
357
+ cols = st.columns(num_cols)
358
+
359
+ # Movie similarity search
360
+ with cols[0]:
361
+ st.title("Find Similar Movies")
362
+ selected_movie = st.selectbox("Type or select a movie from the dropdown", movies_df['title'].unique())
363
+ k = st.slider("Select the number of recommendations (k)", min_value=1, max_value=50, value=5)
364
+ button = st.button("Find Similar Movies")
365
+ with cols[1]:
366
+ st.title("Choosen Movie Details:")
367
+ if selected_movie:
368
+ correct_Name = selected_movie[:-7]
369
+ movie = fetch_movie_details(correct_Name)
370
+ if movie['Response'] == 'True':
371
+ display_movie_details(movie)
372
+ else:
373
+ st.write(f"Movie details for '{selected_movie}' not found.")
374
+ if button:
375
+ st.write("The rating bar here is token from our dataset and it's between 0 and 5.")
376
+ if selected_movie:
377
+ recommendations = recommend(selected_movie, similarity_df, movies_df, ratings_df, links_df, k)
378
+ if recommendations:
379
+ st.write(f"Similar movies to '{selected_movie}':")
380
+ num_cols = 2
381
+ cols = st.columns(num_cols)
382
+
383
+ # movie_id = movies_df[movies_df['title'] == selected_movie]['movieId'].values[0]
384
+ # movie_details = get_movie_details(movie_id, movies_df, ratings_df, links_df)
385
+ # if movie_details:
386
+ # st.markdown(f'<h2 class="section-title">{movie_details["title"]} Details:</h2>', unsafe_allow_html=True)
387
+ # st.markdown(
388
+ # f"""
389
+ # <div class="movie-details-container">
390
+ # <div class="movie-poster">
391
+ # <img src="{movie_details['poster_url']}" alt="Movie Poster">
392
+ # </div>
393
+ # <div class="movie-details">
394
+ # <p><b>Genres:</b> {', '.join(movie_details['genres'])}</p>
395
+ # <p><b>Average Rating:</b> {movie_details['avg_rating']}</p>
396
+ # <p><b>Number of Ratings:</b> {movie_details['num_ratings']}</p>
397
+ # <p><b>IMDb :</b> <a href="https://www.imdb.com/title/tt{movie_details['imdb_id']:07d}/" target="_blank">movie link</a></p>
398
+ # </div>
399
+ # </div>
400
+ # """,
401
+ # unsafe_allow_html=True
402
+ # )
403
+
404
+
405
+
406
+ for i, movie in enumerate(recommendations):
407
+ with cols[i % num_cols]:
408
+ print_movie_details(movie)
409
+ else:
410
+ st.write("No recommendations found.")
411
+ else:
412
+ st.write("Please select a movie.")
413
+
414
+ if __name__ == "__main__":
415
+ main()
Models/movie_titles.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4dc74fe926322dd72dbc817ccd184e33d29734031b4fbedc2d24ef5c504b3ce0
3
+ size 384386