changed zip to csv and converted recommended_movies into array of objects
Browse files
app.py
CHANGED
|
@@ -5,8 +5,8 @@ import ast
|
|
| 5 |
|
| 6 |
|
| 7 |
from datasets import load_dataset, concatenate_datasets
|
| 8 |
-
movies = load_dataset("jyshbgde/cinescopeDataset", data_files = "tmdb_5000_movies.
|
| 9 |
-
credits = load_dataset("jyshbgde/cinescopeDataset", data_files = "tmdb_5000_credits.
|
| 10 |
|
| 11 |
movies = movies['train']
|
| 12 |
credits = credits['train']
|
|
@@ -94,7 +94,9 @@ similarity = cosine_similarity(vectors)
|
|
| 94 |
def recommend(movie):
|
| 95 |
movie = movie.lower()
|
| 96 |
if movie not in new_movies_df['lower_title'].values:
|
| 97 |
-
return [
|
|
|
|
|
|
|
| 98 |
else:
|
| 99 |
movie_index = new_movies_df[new_movies_df['lower_title'] == movie].index[0]
|
| 100 |
distances = similarity[movie_index]
|
|
@@ -102,9 +104,18 @@ def recommend(movie):
|
|
| 102 |
|
| 103 |
recommended_movies = []
|
| 104 |
for i in movies_list:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 105 |
|
| 106 |
-
|
| 107 |
-
recommended_movies.append([str(movies.iloc[i[0]]["movie_id"]) ,movies.iloc[i[0]]["title"], movies.iloc[i[0]]["overview"], movies.iloc[i[0]]["genres"], movies.iloc[i[0]]["cast"], movies.iloc[i[0]]["crew"] ])
|
| 108 |
|
| 109 |
return recommended_movies
|
| 110 |
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
from datasets import load_dataset, concatenate_datasets
|
| 8 |
+
movies = load_dataset("jyshbgde/cinescopeDataset", data_files = "tmdb_5000_movies.csv")
|
| 9 |
+
credits = load_dataset("jyshbgde/cinescopeDataset", data_files = "tmdb_5000_credits.csv")
|
| 10 |
|
| 11 |
movies = movies['train']
|
| 12 |
credits = credits['train']
|
|
|
|
| 94 |
def recommend(movie):
|
| 95 |
movie = movie.lower()
|
| 96 |
if movie not in new_movies_df['lower_title'].values:
|
| 97 |
+
return [{
|
| 98 |
+
"error": "movie not found"
|
| 99 |
+
}]
|
| 100 |
else:
|
| 101 |
movie_index = new_movies_df[new_movies_df['lower_title'] == movie].index[0]
|
| 102 |
distances = similarity[movie_index]
|
|
|
|
| 104 |
|
| 105 |
recommended_movies = []
|
| 106 |
for i in movies_list:
|
| 107 |
+
|
| 108 |
+
obj = {
|
| 109 |
+
"_id":str(movies.iloc[i[0]]["movie_id"]),
|
| 110 |
+
"title":movies.iloc[i[0]]["title"],
|
| 111 |
+
"overview":movies.iloc[i[0]]["overview"],
|
| 112 |
+
"genres": movies.iloc[i[0]]["genres"],
|
| 113 |
+
"casts":movies.iloc[i[0]]["cast"],
|
| 114 |
+
"crew": movies.iloc[i[0]]["crew"],
|
| 115 |
+
}
|
| 116 |
+
recommended_movies.append(obj)
|
| 117 |
|
| 118 |
+
|
|
|
|
| 119 |
|
| 120 |
return recommended_movies
|
| 121 |
|