import streamlit as st import pandas as pd import numpy as np # Streamlit App Configuration st.set_page_config(page_title="Maintenance Prediction & Scheduling", layout="wide") # Sidebar for Navigation and File Upload st.sidebar.title("Navigation") view_option = st.sidebar.radio("Choose View:", ["Home", "Upload Data", "Maintenance Schedule", "Equipment Insights"]) st.sidebar.title("Upload Data") data_upload = st.sidebar.file_uploader("Upload Equipment Data (CSV):", type=["csv"]) # App Title st.title("Maintenance Prediction & Scheduling App") st.markdown( "This app predicts maintenance needs and schedules activities to minimize downtime for construction equipment like HVAC, elevators, and generators." ) # Helper Function - Process Uploaded Data def process_uploaded_data(uploaded_file): try: data = pd.read_csv(uploaded_file) st.success("Data uploaded successfully!") st.dataframe(data) return data except Exception as e: st.error(f"Error processing the uploaded file: {e}") return None # Main Views uploaded_data = None if view_option == "Home": st.image("https://via.placeholder.com/800x400.png?text=Maintenance+Scheduling+App", caption="Welcome Screen") st.markdown( """ ### Key Features: - Upload site data for analysis. - Predict maintenance needs based on historical data. - Schedule maintenance tasks and download the schedule. """ ) elif view_option == "Upload Data": st.subheader("Upload Equipment Data") if data_upload: uploaded_data = process_uploaded_data(data_upload) elif view_option == "Maintenance Schedule": st.subheader("Maintenance Schedule") if data_upload and uploaded_data is not None: st.write("Generating maintenance schedule...") # Simulate maintenance schedule uploaded_data["Maintenance_Due"] = np.where(uploaded_data["Condition_Score"] < 75, "Yes", "No") st.dataframe(uploaded_data[["Equipment_ID", "Equipment_Type", "Maintenance_Due"]]) st.download_button( label="Download Schedule as CSV", data=uploaded_data.to_csv(index=False).encode('utf-8'), file_name="maintenance_schedule.csv", mime="text/csv", ) else: st.info("Please upload data in the 'Upload Data' section.") elif view_option == "Equipment Insights": st.subheader("Equipment Insights") if data_upload and uploaded_data is not None: st.write("Analyzing equipment performance...") st.bar_chart(uploaded_data[["Usage_Hours", "Condition_Score"]].set_index(uploaded_data["Equipment_Type"])) else: st.info("Please upload data in the 'Upload Data' section.") # Footer st.markdown("---") st.markdown("Developed by [Your Name] - Enhancing Maintenance Planning with AI")