import streamlit as st import pandas as pd import numpy as np st.set_page_config(page_title="Machine Failure Predictor") st.title("🛠️ Machine Failure Prediction App") # Upload sensor data uploaded_file = st.file_uploader("Upload sensor data (CSV)", type="csv") if uploaded_file: data = pd.read_csv(uploaded_file) st.subheader("🔍 Sensor Data Preview") st.dataframe(data.head()) # Example health score calculation (mock) st.subheader("📊 Predicted Health Score") health_score = np.random.uniform(30, 100) st.metric("Health Score", f"{health_score:.2f}%", delta_color="inverse") if health_score < 40: st.error("⚠️ High Risk of Failure!") elif health_score < 70: st.warning("⚠️ Moderate Risk") else: st.success("✅ Low Risk") # Line chart st.subheader("📈 Sensor Trends") st.line_chart(data) else: st.info("Please upload a CSV file to begin.")