patricia8a commited on
Commit
f183e2a
·
verified ·
1 Parent(s): b08cbf8

Delete app (1).py

Browse files
Files changed (1) hide show
  1. app (1).py +0 -55
app (1).py DELETED
@@ -1,55 +0,0 @@
1
- import pandas as pd
2
- import gradio as gr
3
-
4
- # Load final dataset
5
- df = pd.read_csv("amazon_final_model_dataset.csv")
6
-
7
- # Keep only useful columns if they exist
8
- useful_columns = [
9
- "product_name",
10
- "avg_rating",
11
- "avg_sentiment",
12
- "avg_price",
13
- "monthly_sales",
14
- "monthly_revenue",
15
- "monthly_profit",
16
- "success_probability",
17
- "business_recommendation"
18
- ]
19
-
20
- existing_columns = [col for col in useful_columns if col in df.columns]
21
- df = df[existing_columns].copy()
22
-
23
- # Remove duplicates on product name for cleaner dropdown
24
- df = df.drop_duplicates(subset=["product_name"]).sort_values("product_name")
25
-
26
- def analyze_product(product_name):
27
- row = df[df["product_name"] == product_name].iloc[0]
28
-
29
- result = f"""
30
- ### Product analysis
31
-
32
- **Product:** {row['product_name']}
33
-
34
- **Average rating:** {row.get('avg_rating', 'N/A'):.2f}
35
- **Average sentiment:** {row.get('avg_sentiment', 'N/A'):.3f}
36
- **Average price:** ${row.get('avg_price', 'N/A'):.2f}
37
- **Monthly sales:** {int(row.get('monthly_sales', 0))}
38
- **Monthly revenue:** ${row.get('monthly_revenue', 0):.2f}
39
- **Monthly profit:** ${row.get('monthly_profit', 0):.2f}
40
- **Success probability:** {row.get('success_probability', 0):.2%}
41
-
42
- **Business recommendation:**
43
- {row.get('business_recommendation', 'No recommendation available')}
44
- """
45
- return result
46
-
47
- demo = gr.Interface(
48
- fn=analyze_product,
49
- inputs=gr.Dropdown(choices=df["product_name"].tolist(), label="Choose a product"),
50
- outputs=gr.Markdown(label="Analysis"),
51
- title="Amazon Product Success Analyzer",
52
- description="This app analyzes Amazon products using sentiment, ratings, synthetic business metrics, and predicted success probability."
53
- )
54
-
55
- demo.launch()