File size: 1,818 Bytes
56a868d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1495ca7
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
57
58
59
60
61
62
63
64
65
66
import pandas as pd
import numpy as np
import joblib
import streamlit as st


cosine_sim=joblib.load('model_movie_recomadation_sigmoid.joblib')

indices_df=pd.read_csv('indices.csv')


html_temp = """
    <div style="background-color:tomato;padding:10px">
    <h2 style="color:white;text-align:center;">Movie Recomandation APP</h2>
    </div>
    """
st.markdown(html_temp, unsafe_allow_html=True)
image_url="https://tse1.mm.bing.net/th?id=OIP.T1nYWZh17oT5wuISslNzdwHaEK&pid=Api&P=0&h=180"

st.image(image_url, use_container_width=True)
st.markdown(f"""
    <style>
        /* Set the background image for the entire app */
        .stApp {{
            background-color:#6793AC;
            background-size: 100px;
            background-repeat:no;
            background-attachment: auto;
            background-position:full;
        }}
    </style>
    """, unsafe_allow_html=True)




def get_recommendations(title, cosine_sim=cosine_sim):
    # Get the index of the movie that matches the title
    
    filtered_df = indices_df[indices_df.apply(lambda row: row.astype(str).str.contains(movie, case=False).any(), axis=1)].index
    
    sim_scores = list(enumerate(cosine_sim[filtered_df]))

    index, values = sim_scores[0]
    result = list(zip(range(len(values)), values))
    # Sort the movies based on the similarity scores
    result_sorted = sorted(result, key=lambda x: x[1], reverse=True)

    # Get the scores of the 10 most similar movies
    sim_scores = result_sorted[1:11]

    # Get the movie indices
    ##global movie_indices
    movie_indices = [i[0] for i in sim_scores]

    #Return the top 10 most similar movies
    return movie_indices


movie=st.text_input("Enter the Movie Tittle")

if st.button("Search"):
    
    val=get_recommendations(movie)

    st.dataframe(indices_df.iloc[val])