raggarwal commited on
Commit
dda760d
·
verified ·
1 Parent(s): f3383d1

Upload folder using huggingface_hub

Browse files
Files changed (3) hide show
  1. .amlignore +6 -0
  2. app.py +68 -0
  3. requirements.txt +5 -0
.amlignore ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ ## This file was auto generated by the Azure Machine Learning Studio. Please do not remove.
2
+ ## Read more about the .amlignore file here: https://docs.microsoft.com/azure/machine-learning/how-to-save-write-experiment-files#storage-limits-of-experiment-snapshots
3
+
4
+ .ipynb_aml_checkpoints/
5
+ *.amltmp
6
+ *.amltemp
app.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import seaborn as sns
3
+ import matplotlib.pyplot as plt
4
+ import pandas as pd
5
+
6
+ # Load data
7
+ def load_data():
8
+ df = pd.read_csv("processed_data.csv") # Replace with your dataset
9
+ return df
10
+
11
+ # Create Streamlit app
12
+ def app():
13
+ # Title for the app
14
+ st.title("Retail Data Insights Dashboard")
15
+
16
+ # Load data
17
+ df = load_data()
18
+
19
+ # Key Metrics from the data
20
+ total_orders = df['Transaction ID'].nunique()
21
+ total_products_sold = df['Quantity'].sum()
22
+ total_revenue = df['Total Amount'].sum()
23
+ most_popular_product_cat = df['Product Category'].value_counts().idxmax()
24
+ most_frequent_age_cat = df['Age Category'].value_counts().idxmax()
25
+
26
+ # Display metrics in the sidebar
27
+ st.sidebar.header("Key Metrics")
28
+ st.sidebar.metric("Total Orders", total_orders)
29
+ st.sidebar.metric("Total Products Sold", total_products_sold)
30
+ st.sidebar.metric("Total Revenue", f"${total_revenue:,.2f}")
31
+ st.sidebar.metric("Most Popular Product Category", most_popular_product_cat)
32
+ st.sidebar.metric("Most Frequent Age Category", most_frequent_age_cat)
33
+
34
+
35
+ plots = [
36
+ {"title": "Total Products Sold by Product and Age Categories", "x": "Product Category", "hue": "Age Category"},
37
+ {"title": "Monthly Revenue Trends by Product Category", "x": "month", "y": "Total Amount", "hue": "Product Category", "estimator": "sum", "marker": "o"},
38
+ {"title": "Monthly Revenue Trends by Age Category", "x": "month", "y": "Total Amount", "hue": "Age Category", "estimator": "sum", "marker": "o"},
39
+ {"title": "Revenue by Product Category", "x": "Product Category", "y": "Total Amount", "estimator": "sum"},
40
+ ]
41
+
42
+ for plot in plots:
43
+ st.header(plot["title"])
44
+
45
+ fig, ax = plt.subplots()
46
+
47
+ if "Total Products" in plot["title"]:
48
+ sns.countplot(data=df, x=plot["x"], hue=plot["hue"], ax=ax)
49
+
50
+ if "Monthly Revenue" in plot["title"]:
51
+ sns.lineplot(data=df, x=plot["x"], y=plot["y"], hue=plot["hue"], estimator=plot["estimator"], errorbar=None, marker=plot["marker"], ax=ax)
52
+
53
+ if "Revenue by Product" in plot["title"]:
54
+ sns.barplot(data=df, x=plot["x"], y=plot["y"], estimator=plot["estimator"], errorbar=None, ax=ax)
55
+
56
+ ax.set_xlabel(" ".join(plot["x"].split("_")).capitalize())
57
+ if "y" in plot.keys():
58
+ ax.set_ylabel(" ".join(plot["y"].split("_")).capitalize())
59
+ else:
60
+ ax.set_ylabel("Quantity")
61
+ ax.legend(bbox_to_anchor=(1,1))
62
+
63
+ st.pyplot(fig)
64
+ plt.show()
65
+
66
+
67
+ if __name__ == "__main__":
68
+ app()
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ pandas==1.5.2
2
+ matplotlib==3.6.2
3
+ seaborn==0.12.1
4
+ scipy==1.10.0
5
+ numpy==1.23.5