--- title: Intelligent Predictive Maintenance System emoji: 🏭 colorFrom: blue colorTo: indigo sdk: docker app_port: 7860 pinned: false license: mit --- # Intelligent Predictive Maintenance System A Streamlit-based educational prototype demonstrating collaboration between a trained Machine Learning model and Agentic AI components. ## Architecture ```text IoT Machine Parameters ↓ IoT Data Agent ↓ ML Prediction Agent ↓ Trained Random Forest Pipeline ↓ Failure Probability + Risk Level ↓ Engineering Reasoning Agent ↓ Qwen/Qwen2.5-0.5B-Instruct ↓ Maintenance Action Agent ↓ Structured Work Order ↓ Human Engineer Approval ``` ## Machine Learning Model The application uses the pre-trained file: ```text predictive_maintenance_rf_pipeline.pkl ``` The pipeline was trained separately using the AI4I 2020 predictive-maintenance dataset. The expected raw input features are: - Type - Air temperature [K] - Process temperature [K] - Rotational speed [rpm] - Torque [Nm] - Tool wear [min] The application does **not** retrain the Random Forest during startup. The exported pipeline is loaded and used only for inference. ## Local Reasoning Model The engineering reasoning layer uses: ```text Qwen/Qwen2.5-0.5B-Instruct ``` The model receives: - Current sensor readings - Random Forest failure probability - Random Forest prediction - Calculated risk level The language model explains the prediction and proposes an educational maintenance response. It does not replace the Random Forest prediction. ## Agent Design ### Agent 1 — IoT Data Agent Validates and structures incoming sensor data. ### Agent 2 — ML Prediction Agent Calls the trained Random Forest pipeline as a prediction tool. ### Agent 3 — Engineering Reasoning Agent Uses Qwen to interpret the ML result and sensor readings. ### Agent 4 — Maintenance Action Agent Creates a structured predictive-maintenance work order. ### Human-in-the-Loop A qualified engineer must validate any recommendation before a real maintenance, repair, or shutdown decision. ## Hugging Face Space Deployment Create a new Hugging Face Space and choose: ```text SDK: Docker ``` Upload these files to the root of the Space: ```text app.py requirements.txt Dockerfile README.md predictive_maintenance_rf_pipeline.pkl ``` The final repository should look like: ```text / ├── app.py ├── requirements.txt ├── Dockerfile ├── README.md └── predictive_maintenance_rf_pipeline.pkl ``` The Docker container exposes Streamlit on port `7860`, which matches the Hugging Face Space configuration. ## Hardware The Random Forest model is lightweight. The local Qwen 0.5B model can run on CPU, but response generation may take several seconds depending on the Space hardware. CPU Upgrade or GPU hardware will provide a smoother live demonstration. ## Important Model Compatibility Note The exported Random Forest pipeline was created with scikit-learn 1.6.1, so this project pins: ```text scikit-learn==1.6.1 ``` Keeping the same scikit-learn version is important when loading a Joblib/Pickle model. ## Educational Disclaimer This application is intended only for teaching and demonstration. It must not be used to make real industrial maintenance, repair, shutdown, or safety decisions without validation by qualified engineering personnel.