|
import streamlit as st |
|
import numpy as np |
|
import pandas as pd |
|
import seaborn as sns |
|
import matplotlib.pyplot as plt |
|
|
|
|
|
from PIL import Image |
|
|
|
st.set_page_config( |
|
page_title='ParagonCorp Products Sales Quantities Forecasting', |
|
layout = 'wide', |
|
initial_sidebar_state='expanded' |
|
) |
|
|
|
def run(): |
|
|
|
st.title('Exploratory Data Analysis of the Dataset') |
|
st.write('by Ahmad Luay Adnani') |
|
|
|
|
|
|
|
image = Image.open('paragon.png') |
|
st.image(image) |
|
|
|
|
|
st.write('---') |
|
st.write('# Dataset') |
|
st.write('Dataset provided by ParagonCorp.') |
|
|
|
|
|
df = pd.read_csv('sample_dataset_timeseries_noarea.csv') |
|
st.dataframe(df) |
|
|
|
|
|
|
|
df_eda = df.copy() |
|
|
|
|
|
st.write('---') |
|
st.write('# Exploratory Data Analysis') |
|
select_eda = st.selectbox('Select EDA : ', ('Statistical Descriptive','Trend of Product Sales Quantities')) |
|
if select_eda == 'Statistical Descriptive': |
|
|
|
stats = df.describe().T |
|
st.dataframe(stats) |
|
st.write('Based on information above:') |
|
st.write("- The average product sales quantities is 3191.56.") |
|
st.write('- The range of product sales quantities is between 0 to 774,732.') |
|
|
|
else: |
|
|
|
|
|
df_eda = df.copy() |
|
|
|
|
|
df_eda = df_eda.groupby("week_end_date")["quantity"].sum().to_frame().reset_index() |
|
|
|
|
|
df_eda = df.set_index('week_end_date') |
|
|
|
|
|
df_eda.index = pd.to_datetime(df_eda.index) |
|
|
|
|
|
df_eda.drop(columns=['week_number','week_start_date','product_item'],inplace=True) |
|
|
|
|
|
df_eda.index = pd.to_datetime(df_eda.index) |
|
|
|
|
|
df_eda = df_eda['2022-01-02':'2023-04-09'].resample('W').sum() |
|
|
|
|
|
|
|
m, b = np.polyfit(range(len(df_eda)), df_eda['quantity'], 1) |
|
plt.figure(figsize=(10,4)) |
|
plt.plot(df_eda.index, m*range(len(df_eda)) + b, label='Linear Trend Line',color='orange', alpha=0.6) |
|
|
|
|
|
plt.plot(df_eda.index, df_eda['quantity'], marker = 'o', ms = 4, label='Product Sales Quantities') |
|
|
|
|
|
plt.title('Trend of Product Sales Quantities') |
|
plt.xlabel('Date') |
|
plt.ylabel('quantity') |
|
plt.legend() |
|
|
|
|
|
plt.show() |
|
st.set_option('deprecation.showPyplotGlobalUse', False) |
|
st.pyplot() |
|
|
|
st.write('Here we can see the data of product sales quantities for the past 67 weeks. The trend is increasing over the past 67 weeks. There are no pattern on the products sales quantities. There are big spike that occur on 2022-05-08.') |
|
|
|
if __name__ == '__main__': |
|
run() |