YAMITEK commited on
Commit
56a868d
·
verified ·
1 Parent(s): 8417ba7

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +65 -48
app.py CHANGED
@@ -1,49 +1,66 @@
1
- import pandas as pd
2
- import numpy as np
3
- import joblib
4
- import streamlit as st
5
-
6
-
7
- cosine_sim=joblib.load('model_movie_recomadation_sigmoid.joblib')
8
-
9
- indices_df=pd.read_csv('indices.csv')
10
-
11
-
12
- html_temp = """
13
- <div style="background-color:tomato;padding:10px">
14
- <h2 style="color:white;text-align:center;">Movie Recomandation APP</h2>
15
- </div>
16
- """
17
- st.markdown(html_temp, unsafe_allow_html=True)
18
-
19
-
20
- def get_recommendations(title, cosine_sim=cosine_sim):
21
- # Get the index of the movie that matches the title
22
-
23
- filtered_df = indices_df[indices_df.apply(lambda row: row.astype(str).str.contains(movie, case=False).any(), axis=1)].index
24
-
25
- sim_scores = list(enumerate(cosine_sim[filtered_df]))
26
-
27
- index, values = sim_scores[0]
28
- result = list(zip(range(len(values)), values))
29
- # Sort the movies based on the similarity scores
30
- result_sorted = sorted(result, key=lambda x: x[1], reverse=True)
31
-
32
- # Get the scores of the 10 most similar movies
33
- sim_scores = result_sorted[1:11]
34
-
35
- # Get the movie indices
36
- ##global movie_indices
37
- movie_indices = [i[0] for i in sim_scores]
38
-
39
- #Return the top 10 most similar movies
40
- return movie_indices
41
-
42
-
43
- movie=st.text_input("Enter the Movie Tittle")
44
-
45
- if st.button("Search"):
46
-
47
- val=get_recommendations(movie)
48
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  st.dataframe(indices_df.iloc[val])
 
1
+ import pandas as pd
2
+ import numpy as np
3
+ import joblib
4
+ import streamlit as st
5
+
6
+
7
+ cosine_sim=joblib.load('model_movie_recomadation_sigmoid.joblib')
8
+
9
+ indices_df=pd.read_csv('indices.csv')
10
+
11
+
12
+ html_temp = """
13
+ <div style="background-color:tomato;padding:10px">
14
+ <h2 style="color:white;text-align:center;">Movie Recomandation APP</h2>
15
+ </div>
16
+ """
17
+ st.markdown(html_temp, unsafe_allow_html=True)
18
+ image_url="https://tse1.mm.bing.net/th?id=OIP.T1nYWZh17oT5wuISslNzdwHaEK&pid=Api&P=0&h=180"
19
+
20
+ st.image(image_url, use_container_width=True)
21
+ st.markdown(f"""
22
+ <style>
23
+ /* Set the background image for the entire app */
24
+ .stApp {{
25
+ background-color:#6793AC;
26
+ background-size: 100px;
27
+ background-repeat:no;
28
+ background-attachment: auto;
29
+ background-position:full;
30
+ }}
31
+ </style>
32
+ """, unsafe_allow_html=True)
33
+
34
+
35
+
36
+
37
+ def get_recommendations(title, cosine_sim=cosine_sim):
38
+ # Get the index of the movie that matches the title
39
+
40
+ filtered_df = indices_df[indices_df.apply(lambda row: row.astype(str).str.contains(movie, case=False).any(), axis=1)].index
41
+
42
+ sim_scores = list(enumerate(cosine_sim[filtered_df]))
43
+
44
+ index, values = sim_scores[0]
45
+ result = list(zip(range(len(values)), values))
46
+ # Sort the movies based on the similarity scores
47
+ result_sorted = sorted(result, key=lambda x: x[1], reverse=True)
48
+
49
+ # Get the scores of the 10 most similar movies
50
+ sim_scores = result_sorted[1:11]
51
+
52
+ # Get the movie indices
53
+ ##global movie_indices
54
+ movie_indices = [i[0] for i in sim_scores]
55
+
56
+ #Return the top 10 most similar movies
57
+ return movie_indices
58
+
59
+
60
+ movie=st.text_input("Enter the Movie Tittle")
61
+
62
+ if st.button("Search"):
63
+
64
+ val=get_recommendations(movie)
65
+
66
  st.dataframe(indices_df.iloc[val])