-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
71 lines (58 loc) · 2.5 KB
/
Copy pathapp.py
File metadata and controls
71 lines (58 loc) · 2.5 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
"""
Indian Content Recommender
A content-based recommendation app for Indian movies, web series and
documentaries across languages, genres and OTT platforms.
"""
import streamlit as st
from recommender import load_data, ContentRecommender
DATA_PATH = "data/indian_content.csv"
st.set_page_config(page_title="Indian Content Recommender", page_icon="🎬", layout="centered")
@st.cache_resource
def get_recommender():
df = load_data(DATA_PATH)
return ContentRecommender(df), df
recommender, df = get_recommender()
st.title("🎬 Indian Content Recommender")
st.caption(
"Content-based recommendations across Hindi, Tamil, Telugu, Malayalam, "
"Kannada and Marathi movies, series and documentaries."
)
with st.sidebar:
st.header("Filters")
content_type = st.selectbox("Content type", ["All"] + sorted(df["type"].unique()))
top_n = st.slider("Number of recommendations", 3, 15, 8)
st.markdown("---")
st.markdown(
"**Dataset:** starter set of 50 titles. Swap in a larger dataset "
"(e.g. Kaggle's *Indian Movies* or *OTT Platforms* datasets) by "
"replacing `data/indian_content.csv` — same column format."
)
query = st.text_input("Enter a movie, series or documentary you like", placeholder="e.g. Drishyam")
if query:
matched_title, results = recommender.recommend(query, top_n=top_n, content_type=content_type)
if matched_title is None:
st.warning("No close match found. Try another title.")
else:
if matched_title.lower() != query.strip().lower():
st.info(f"Showing recommendations based on closest match: **{matched_title}**")
if results.empty:
st.warning("No recommendations match the selected filter.")
else:
st.subheader(f"Because you liked {matched_title}")
for _, row in results.iterrows():
with st.container(border=True):
col1, col2 = st.columns([3, 1])
with col1:
st.markdown(f"**{row['title']}** · {row['type']} · {row['language']}")
st.caption(row["genre"])
st.write(row["description"])
with col2:
st.metric("Match", f"{row['match_score']}%")
st.caption(row.get("platform", ""))
else:
st.markdown("### Browse the catalog")
st.dataframe(
df[["title", "type", "language", "genre", "platform", "year"]],
use_container_width=True,
hide_index=True,
)