|
import pandas as pd |
|
import gradio as gr |
|
|
|
|
|
df = pd.read_csv("TeluguMovies_dataset.csv") |
|
|
|
|
|
genres = df['Genre'].unique().tolist() |
|
|
|
def recommend_movie(genre, min_rating): |
|
|
|
if 'Genre' not in df.columns or 'Rating' not in df.columns: |
|
return "Dataset is missing 'Genre' or 'Rating' columns." |
|
|
|
recommendations = df[df['Genre'].str.contains(genre, case=False, na=False) & (df['Rating'] >= min_rating)] |
|
if recommendations.empty: |
|
return "No movies found with the specified criteria." |
|
|
|
|
|
recommendations = recommendations.sort_values(by='Rating', ascending=False) |
|
|
|
|
|
response = [] |
|
for idx, row in recommendations.iterrows(): |
|
response.append(f"**{row['Movie']} ({row['Year']})**\nRating: {row['Rating']}\nOverview: {row['Overview']}\n") |
|
|
|
return "\n\n".join(response) |
|
|
|
|
|
iface = gr.Interface( |
|
fn=recommend_movie, |
|
inputs=[ |
|
gr.Dropdown(choices=genres, label="Genre"), |
|
gr.Slider(1.0, 10.0, step=0.1, value=7.0, label="Minimum Rating") |
|
], |
|
outputs="markdown", |
|
title="Movie Recommendation Chatbot", |
|
description="Get movie recommendations based on genre and rating." |
|
) |
|
|
|
|
|
iface.launch() |
|
|