Upload folder using huggingface_hub
Browse files- .amlignore +6 -0
- Dockerfile +31 -5
- app.py +68 -0
- 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.
|
| 2 |
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 |
-
|
| 12 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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", "
|
|
|
|
| 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("Retail Sales 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
CHANGED
|
@@ -1,3 +1,6 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 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
|