Aiomer1 commited on
Commit
9e56209
·
verified ·
1 Parent(s): 151b822

Upload folder using huggingface_hub

Browse files
Files changed (4) hide show
  1. .amlignore +6 -0
  2. Dockerfile +31 -5
  3. app.py +68 -0
  4. requirements.txt +6 -3
.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
Dockerfile CHANGED
@@ -1,15 +1,41 @@
1
- FROM python:3.13.5-slim
2
 
3
- WORKDIR /app
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
 
5
  RUN apt-get update && apt-get install -y \
6
  build-essential \
 
7
  curl \
 
 
 
8
  git \
 
9
  && rm -rf /var/lib/apt/lists/*
10
 
11
- COPY requirements.txt ./
12
- COPY src/ ./src/
 
 
 
 
 
 
13
 
14
  RUN pip3 install -r requirements.txt
15
 
@@ -17,4 +43,4 @@ EXPOSE 8501
17
 
18
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
19
 
20
- ENTRYPOINT ["streamlit", "run", "src/streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
1
+ FROM python:3.9-slim
2
 
3
+ RUN useradd -m -u 1000 user
4
+
5
+ USER user
6
+
7
+ ENV HOME=/home/user \
8
+
9
+ PATH=/home/user/.local/bin:$PATH
10
+
11
+ WORKDIR $HOME/app
12
+
13
+ COPY --chown=user . $HOME/app
14
+
15
+
16
+
17
+ # Run apt-get update and install as root
18
+ USER root
19
 
20
  RUN apt-get update && apt-get install -y \
21
  build-essential \
22
+
23
  curl \
24
+
25
+ software-properties-common \
26
+
27
  git \
28
+
29
  && rm -rf /var/lib/apt/lists/*
30
 
31
+ USER user
32
+
33
+
34
+ # COPY requirements.txt ./
35
+
36
+ # COPY src/ ./src/
37
+
38
+ COPY . .
39
 
40
  RUN pip3 install -r requirements.txt
41
 
 
43
 
44
  HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
45
 
46
+ ENTRYPOINT ["streamlit", "run", "app.py", "--server.port=8501", "--server.address=0.0.0.0", "--server.enableXsrfProtection=false"]
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("Pizza Sales Data Analysis Dashboard")
15
+ df = load_data()
16
+
17
+ df = pd.DataFrame(df)
18
+
19
+ # Calculate key metrics
20
+ total_orders = df['order_id'].nunique()
21
+ total_revenue = df['total_price'].sum()
22
+ most_popular_size = df['pizza_size'].value_counts().idxmax()
23
+ most_frequent_category = df['pizza_category'].value_counts().idxmax()
24
+ total_pizzas_sold = df['quantity'].sum()
25
+ repeat_customers = df.groupby('order_id').size().value_counts().get(2, 0)
26
+
27
+ # Sidebar with key metrics
28
+ st.sidebar.header("Key Metrics")
29
+ st.sidebar.metric("Total Orders", total_orders)
30
+ st.sidebar.metric("Total Revenue", f"${total_revenue:,.2f}")
31
+ st.sidebar.metric("Most Popular Size", most_popular_size)
32
+ st.sidebar.metric("Most Popular Category", most_frequent_category)
33
+ st.sidebar.metric("Total Pizzas Sold", total_pizzas_sold)
34
+
35
+ plots = [
36
+ {"title": "Top Selling Pizzas (by Quantity)", "x": "pizza_name", "y": "quantity", "top": 5},
37
+ {"title": "Quantity of Pizzas Sold by Category and Time of the Day", "x": "time_of_day", "hue": "pizza_category"},
38
+ {"title": "Quantity of Pizzas Sold by Size and Time of the Day", "x": "time_of_day", "hue": "pizza_size"},
39
+ {"title": "Monthly Revenue Trends by Pizza Category", "x": "order_month", "y": "total_price", "hue": "pizza_category", "estimator": "sum", "marker": "o"},
40
+ ]
41
+
42
+ for plot in plots:
43
+ st.header(plot["title"])
44
+
45
+ fig, ax = plt.subplots()
46
+
47
+ if "Top Selling Pizzas" in plot["title"]:
48
+ data_aux = df.groupby(plot["x"])[plot["y"]].sum().reset_index().sort_values(by=plot["y"], ascending=False).head(plot["top"])
49
+ ax.bar(data_aux[plot["x"]].values.tolist(), data_aux[plot["y"]].values.tolist())
50
+
51
+ if "Quantity of Pizzas" in plot["title"]:
52
+ sns.countplot(data=df, x=plot["x"], hue=plot["hue"], ax=ax)
53
+
54
+ if "Monthly Revenue" in plot["title"]:
55
+ sns.lineplot(data=df, x=plot["x"], y=plot["y"], hue=plot["hue"], estimator=plot["estimator"], errorbar=None, marker=plot["marker"], ax=ax)
56
+
57
+ ax.set_xlabel(" ".join(plot["x"].split("_")).capitalize())
58
+ if "y" in plot.keys():
59
+ ax.set_ylabel(" ".join(plot["y"].split("_")).capitalize())
60
+ else:
61
+ ax.set_ylabel("Quantity")
62
+ ax.legend(bbox_to_anchor=(1,1))
63
+
64
+ st.pyplot(fig)
65
+
66
+
67
+ if __name__ == "__main__":
68
+ app()
requirements.txt CHANGED
@@ -1,3 +1,6 @@
1
- altair
2
- pandas
3
- streamlit
 
 
 
 
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
6
+ streamlit==1.46.0