Spaces:
Sleeping
Sleeping
File size: 3,691 Bytes
66a274e be54d32 efdb030 e985a1e efdb030 045771f 5ea8ec2 a6da2a0 045771f a6da2a0 efdb030 a6da2a0 08c5568 8d92fd7 a6da2a0 efdb030 c459fea 03208bc c459fea efdb030 d79aae9 8d92fd7 a6da2a0 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
import os
import streamlit as st
st.title("Inventory Dashboard")
st.write("Welcome to your inventory tracking system!")
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
@st.cache_data
def load_data():
cwd = os.getcwd()
print(f"Current Directory: {cwd}")
print(f"Files in Directory: {os.listdir(cwd)}")
lead_time_path = os.path.join(os.getcwd(), "final_cleaned_lead_time_data.csv")
inventory_path = os.path.join(os.getcwd(), "inventory.csv")
optimization_path = os.path.join(os.getcwd(), "inventory_optimization_results.csv")
lead_time_data = pd.read_csv(lead_time_path)
inventory_data = pd.read_csv(inventory_path)
optimization_data=pd.read_csv(optimization_path)
return lead_time_data, inventory_data, optimization_data
lead_time_data, inventory_data, optimization_data = load_data()
st.header("📊 Inventory Optimization Insights")
st.write("### Optimization Results Dataset(sample)")
st.dataframe(optimization_data.head(500))
st.write("### Optimization Trend")
if 'Optimization_Score' in optimization_data.columns:
fig, ax = plt.subplots()
ax.plot(optimization_data.index, optimization_data['Optimization_Score'], marker='o', linestyle='-')
ax.set_title("Optimization Score Over Time")
ax.set_xlabel("Iteration")
ax.set_ylabel("Score")
st.pyplot(fig)
def calculate_safety_stock(demand_std, lead_time_mean, z_score=1.645):
return z_score * demand_std * np.sqrt(lead_time_mean)
def calculate_reorder_point(avg_demand, lead_time_mean, safety_stock):
return (avg_demand * lead_time_mean) + safety_stock
def simulate_real_time_data(data, interval=5):
for i in range(interval):
new_demand = np.random.randint(50, 100)
new_row = pd.DataFrame([{'Product Name': f'Product {i+1}', 'Demand': new_demand}])
data = pd.concat([data, new_row], ignore_index=True)
return data
st.sidebar.header("Inventory Parameters")
z_score = st.sidebar.slider("Z-Score (Service Level)", 1.0, 3.0, 1.645)
interval = st.sidebar.slider("Real-Time Update Interval", 1, 10, 5)
demand_std = lead_time_data['Lead Time (Days)'].std()
lead_time_mean = lead_time_data['Lead Time (Days)'].mean()
avg_demand = inventory_data[' Warehouse Inventory '].mean()
safety_stock = calculate_safety_stock(demand_std, lead_time_mean, z_score)
reorder_point = calculate_reorder_point(avg_demand, lead_time_mean, safety_stock)
st.title("Inventory Management Dashboard")
st.write("This dashboard dynamically visualizes inventory levels, reorder points, and safety stock.")
st.subheader("Key Metrics")
st.metric("Safety Stock", f"{safety_stock:.2f} units")
st.metric("Reorder Point", f"{reorder_point:.2f} units")
st.metric("Average Demand", f"{avg_demand:.2f} units/day")
st.subheader("Real-Time Inventory Updates")
real_time_data = simulate_real_time_data(inventory_data, interval)
st.write(real_time_data)
st.subheader("Inventory Levels")
fig, ax = plt.subplots()
ax.plot(inventory_data['Product Name'], inventory_data[' Warehouse Inventory '], label='Inventory Levels', color='blue')
ax.axhline(y=reorder_point, color='red', linestyle='--', label='Reorder Point')
ax.axhline(y=safety_stock, color='green', linestyle='--', label='Safety Stock')
ax.set_title("Inventory Levels and Reorder Point")
ax.set_xlabel("Product Name")
ax.set_ylabel("Inventory")
ax.legend()
st.pyplot(fig)
st.subheader("Inventory Data")
st.dataframe(inventory_data)
if st.button("Save Results"):
inventory_data.to_csv("updated_inventory_data.csv", index=False)
st.success("Results saved to 'updated_inventory_data.csv'")
if __name__ == "__main__":
import streamlit as st
st.write("Streamlit app is running!")
|