Spaces:
Sleeping
Sleeping
File size: 2,473 Bytes
2b32d51 d92dea3 baee161 2b32d51 d92dea3 403bf94 baee161 d92dea3 baee161 d92dea3 e0c5fb0 7fe51f3 baee161 7fe51f3 e0c5fb0 403bf94 baee161 403bf94 e0c5fb0 403bf94 7fe51f3 403bf94 baee161 403bf94 baee161 7fe51f3 baee161 7fe51f3 baee161 403bf94 baee161 403bf94 baee161 | 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 72 73 74 75 76 | import gradio as gr
import pandas as pd
import matplotlib.pyplot as plt
df = pd.read_csv("hotel_final_dataset.csv")
hotels = sorted(df["hotel_name"].dropna().unique().tolist())
def analyze(hotel):
data = df[df["hotel_name"] == hotel].copy()
avg_rating = round(data["avg_rating"].mean(), 2)
sentiment = round(data["sentiment_score"].mean(), 2)
occupancy = round(data["occupancy_rate"].mean(), 2)
price = round(data["price_per_night"].mean(), 2)
demand = round(data["demand_index"].mean(), 2)
base_rec = data["pricing_recommendation"].mode().iloc[0]
if sentiment < 0:
recommendation = f"{base_rec} — but improve customer satisfaction first"
elif occupancy > 0.95:
recommendation = f"{base_rec} — strong demand supports price increase"
else:
recommendation = base_rec
fig, ax = plt.subplots(figsize=(8, 4))
fig.patch.set_facecolor('#111111')
ax.set_facecolor('#111111')
ax.plot(data["month"], data["booking_count"], marker="o")
ax.set_title("Booking Trend", color='white')
ax.set_xlabel("Month", color='white')
ax.set_ylabel("Booking Count", color='white')
ax.tick_params(colors='white')
plt.xticks(rotation=45)
plt.tight_layout()
return avg_rating, sentiment, occupancy, price, demand, recommendation, fig
with gr.Blocks() as demo:
gr.Markdown("# AI-Driven Hotel Pricing Dashboard")
gr.Markdown("Analyze hotel performance using sentiment, demand, pricing, and booking trends.")
with gr.Row():
hotel_input = gr.Dropdown(choices=hotels, label="Select Hotel", value=hotels[0])
with gr.Row():
avg_rating_output = gr.Textbox(label="Average Rating")
sentiment_output = gr.Textbox(label="Customer Sentiment Score")
occupancy_output = gr.Textbox(label="Occupancy Rate")
with gr.Row():
price_output = gr.Textbox(label="Average Price per Night")
demand_output = gr.Textbox(label="Demand Level Index")
recommendation_output = gr.Textbox(label="Pricing Recommendation")
plot_output = gr.Plot(label="Booking Trend")
submit_btn = gr.Button("Run Analysis")
submit_btn.click(
fn=analyze,
inputs=hotel_input,
outputs=[
avg_rating_output,
sentiment_output,
occupancy_output,
price_output,
demand_output,
recommendation_output,
plot_output
]
)
demo.launch() |