Delete app.py
Browse files
app.py
DELETED
|
@@ -1,50 +0,0 @@
|
|
| 1 |
-
import streamlit as st
|
| 2 |
-
import pandas as pd
|
| 3 |
-
from forecast_engine import forecast_consumables
|
| 4 |
-
|
| 5 |
-
# Load the samples CSV for inventory lookup
|
| 6 |
-
samples_df = pd.read_csv('samples.csv')
|
| 7 |
-
|
| 8 |
-
st.title("Consumables Forecast Dashboard")
|
| 9 |
-
lab_id = st.text_input("Lab ID", value="Lab001")
|
| 10 |
-
consumable_type = st.selectbox("Consumable Type", ["Filters", "Reagents", "Vials"])
|
| 11 |
-
usage_data = st.text_area("Enter last 60 days usage, comma-separated", value="23,26,25,18,23,20,24,25,27,24,18,20,26,24,18,20,27,26,21,18,25,24,28,25,21,18,20,26,24,22,24,20,27,26,21,25,24,28,25,26,24,22,24,20,27,26,21,18,20,25,22,21,19,20,24,20,17,20")
|
| 12 |
-
days = st.selectbox("Forecast Period", [7, 14, 30])
|
| 13 |
-
threshold = st.number_input("Set Usage Threshold for Alert (Total Usage)", min_value=0, value=500, step=10)
|
| 14 |
-
safety_stock = st.number_input("Safety Stock Level", min_value=0, value=50, step=1)
|
| 15 |
-
|
| 16 |
-
# Look up current inventory from samples.csv
|
| 17 |
-
current_inventory = 0
|
| 18 |
-
if lab_id and consumable_type:
|
| 19 |
-
inventory_row = samples_df[(samples_df['Lab_ID'] == lab_id) & (samples_df['Consumable_Type'] == consumable_type)]
|
| 20 |
-
if not inventory_row.empty:
|
| 21 |
-
current_inventory = inventory_row.iloc[0]['Current_Stock']
|
| 22 |
-
st.write(f"Current Inventory for {lab_id} ({consumable_type}): {current_inventory} units")
|
| 23 |
-
else:
|
| 24 |
-
st.warning(f"No inventory data found for Lab ID {lab_id} and Consumable Type {consumable_type}. Assuming 0 inventory.")
|
| 25 |
-
|
| 26 |
-
if st.button("Forecast"):
|
| 27 |
-
try:
|
| 28 |
-
usage_series = list(map(int, usage_data.split(",")))
|
| 29 |
-
if len(usage_series) != 60:
|
| 30 |
-
st.error("Please enter exactly 60 days of usage data.")
|
| 31 |
-
else:
|
| 32 |
-
forecast = forecast_consumables(usage_series, days)
|
| 33 |
-
total_usage = sum(forecast)
|
| 34 |
-
# Display the chart
|
| 35 |
-
st.line_chart(forecast)
|
| 36 |
-
# Display the daily predicted usage
|
| 37 |
-
st.write("Predicted Usage for Next", days, "Days:", forecast)
|
| 38 |
-
# Display the total predicted usage
|
| 39 |
-
st.success(f"Predicted Total Usage (next {days} days): {total_usage:.1f}")
|
| 40 |
-
# Threshold alerting
|
| 41 |
-
if total_usage > threshold:
|
| 42 |
-
st.warning(f"⚠️ Alert: Total forecasted usage ({total_usage:.1f}) exceeds threshold ({threshold})! Consider reordering.")
|
| 43 |
-
# Order suggestion
|
| 44 |
-
reorder_quantity = total_usage - current_inventory + safety_stock
|
| 45 |
-
if reorder_quantity > 0:
|
| 46 |
-
st.info(f"📦 Suggested Reorder Quantity: {reorder_quantity:.1f} units")
|
| 47 |
-
else:
|
| 48 |
-
st.info("✅ Current inventory is sufficient. No reorder needed.")
|
| 49 |
-
except ValueError:
|
| 50 |
-
st.error("Invalid input. Please enter comma-separated integers (e.g., 10,11,12,...).")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|