Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,120 +1,52 @@
|
|
| 1 |
-
import os
|
| 2 |
import streamlit as st
|
| 3 |
-
|
| 4 |
-
import
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
st.
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
)
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
#
|
| 20 |
-
if
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
#
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
# Back Button to Redirect to Dashboard
|
| 44 |
-
st.markdown(
|
| 45 |
-
"""
|
| 46 |
-
<style>
|
| 47 |
-
.back-button {
|
| 48 |
-
display: flex;
|
| 49 |
-
justify-content: center;
|
| 50 |
-
padding: 10px;
|
| 51 |
-
}
|
| 52 |
-
.btn {
|
| 53 |
-
background-color: #4CAF50;
|
| 54 |
-
color: white;
|
| 55 |
-
padding: 10px 20px;
|
| 56 |
-
text-align: center;
|
| 57 |
-
text-decoration: none;
|
| 58 |
-
font-size: 16px;
|
| 59 |
-
border-radius: 5px;
|
| 60 |
-
display: inline-block;
|
| 61 |
-
}
|
| 62 |
-
</style>
|
| 63 |
-
<div class="back-button">
|
| 64 |
-
<a href="https://binsight.onrender.com/dashboard.html" class="btn">🔙 Back to Dashboard</a>
|
| 65 |
-
</div>
|
| 66 |
-
""",
|
| 67 |
-
unsafe_allow_html=True,
|
| 68 |
-
)
|
| 69 |
-
|
| 70 |
-
# Introduction and instructions
|
| 71 |
-
st.markdown(
|
| 72 |
-
"""
|
| 73 |
-
Welcome to the **Smart Waste Management System**! This tool helps **citizens, municipal workers,
|
| 74 |
-
recycling companies, and biogas plants** collaborate efficiently for **better waste management**.
|
| 75 |
-
|
| 76 |
-
### **🌟 Key Features**
|
| 77 |
-
- 🏡 **Improve waste collection efficiency** for citizens.
|
| 78 |
-
- 🚛 **Help municipal workers** manage schedules.
|
| 79 |
-
- 🔄 **Assist recycling companies** in waste processing.
|
| 80 |
-
- ⚡ **Support biogas plants** in energy production.
|
| 81 |
-
"""
|
| 82 |
-
)
|
| 83 |
-
|
| 84 |
-
# User role selection
|
| 85 |
-
user_role = st.selectbox("🔹 Select Your Role:", ["Citizen", "Municipal Worker", "Recycling Company", "Biogas Plant"])
|
| 86 |
-
|
| 87 |
-
# Chat input
|
| 88 |
-
user_prompt = st.chat_input(f"💬 [{user_role}] Enter your query or task...")
|
| 89 |
-
|
| 90 |
-
if user_prompt:
|
| 91 |
-
# Display the user's message
|
| 92 |
-
st.chat_message("user").markdown(f"**{user_role}:** {user_prompt}")
|
| 93 |
-
|
| 94 |
-
# Generate a role-specific prompt
|
| 95 |
-
role_specific_prompt = f"You are assisting a {user_role} in a smart waste management system. The user says: {user_prompt}"
|
| 96 |
-
|
| 97 |
-
# Send the prompt to Gemini-Pro and get the response
|
| 98 |
-
try:
|
| 99 |
-
gemini_response = st.session_state.chat_session.send_message(role_specific_prompt)
|
| 100 |
-
|
| 101 |
-
# Display Gemini-Pro's response
|
| 102 |
-
with st.chat_message("assistant"):
|
| 103 |
-
st.markdown(gemini_response.text)
|
| 104 |
-
|
| 105 |
-
except Exception as e:
|
| 106 |
-
st.error(f"❌ Error processing your message: {e}")
|
| 107 |
-
|
| 108 |
-
# Sidebar Information
|
| 109 |
st.sidebar.title("📌 About")
|
| 110 |
st.sidebar.markdown(
|
| 111 |
"""
|
| 112 |
-
|
| 113 |
-
-
|
| 114 |
-
-
|
| 115 |
-
-
|
| 116 |
-
- ⚡ Support biogas plants in energy production.
|
| 117 |
|
| 118 |
-
|
| 119 |
"""
|
| 120 |
)
|
|
|
|
|
|
|
| 1 |
import streamlit as st
|
| 2 |
+
import numpy as np
|
| 3 |
+
import pandas as pd
|
| 4 |
+
from sklearn.linear_model import LinearRegression
|
| 5 |
+
|
| 6 |
+
# Streamlit page config
|
| 7 |
+
st.set_page_config(page_title="BigMart Sales Predictor", page_icon="🛒", layout="centered")
|
| 8 |
+
|
| 9 |
+
st.title("🛒 BigMart Sales Prediction")
|
| 10 |
+
st.markdown("Enter item details below to predict sales:")
|
| 11 |
+
|
| 12 |
+
# Input fields
|
| 13 |
+
project_name = st.text_input("📦 Project Name")
|
| 14 |
+
item_weight = st.number_input("⚖️ Item Weight (kg)", min_value=0.0, step=0.1)
|
| 15 |
+
item_visibility = st.slider("👀 Item Visibility", 0.0, 1.0, 0.1)
|
| 16 |
+
item_mrp = st.number_input("💰 Item MRP (Max Retail Price)", min_value=0.0, step=1.0)
|
| 17 |
+
|
| 18 |
+
# Predict button
|
| 19 |
+
if st.button("Predict Sales"):
|
| 20 |
+
if not project_name:
|
| 21 |
+
st.warning("Please enter a project name.")
|
| 22 |
+
else:
|
| 23 |
+
# Dummy ML Model: Replace with your actual trained model
|
| 24 |
+
X_train = np.array([
|
| 25 |
+
[9.3, 0.016, 249.8],
|
| 26 |
+
[5.92, 0.019, 48.27],
|
| 27 |
+
[17.5, 0.016, 141.62],
|
| 28 |
+
[19.2, 0.0075, 182.095],
|
| 29 |
+
])
|
| 30 |
+
y_train = np.array([3735.14, 443.42, 2233.6, 3612.47]) # example sales
|
| 31 |
+
|
| 32 |
+
model = LinearRegression()
|
| 33 |
+
model.fit(X_train, y_train)
|
| 34 |
+
|
| 35 |
+
# Prepare input
|
| 36 |
+
user_input = np.array([[item_weight, item_visibility, item_mrp]])
|
| 37 |
+
prediction = model.predict(user_input)[0]
|
| 38 |
+
|
| 39 |
+
st.success(f"📈 Predicted Sales for '{project_name}': ₹{prediction:,.2f}")
|
| 40 |
+
|
| 41 |
+
# Sidebar info
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
st.sidebar.title("📌 About")
|
| 43 |
st.sidebar.markdown(
|
| 44 |
"""
|
| 45 |
+
This app uses a simple ML model to estimate sales based on:
|
| 46 |
+
- Item weight
|
| 47 |
+
- Item visibility
|
| 48 |
+
- Item MRP
|
|
|
|
| 49 |
|
| 50 |
+
Replace with a trained BigMart dataset model for production use.
|
| 51 |
"""
|
| 52 |
)
|