AWS Builder Center
Building PredictX: Predictive Maintenance with AWS IoT Core, Lambda and S3

Building PredictX: Predictive Maintenance with AWS IoT Core, Lambda and S3

How I built PredictX, a predictive maintenance project that spots unusual machine sensor behavior using Isolation Forest, AWS IoT Core, Lambda and S3.



Introduction

Machines in factories constantly produce sensor data such as temperature, rotational speed and torque. When those readings drift away from normal, it can be an early sign of a problem. But nobody can watch thousands of readings by hand, and an unexpected breakdown means delays and repair costs.
I built PredictX, an AI-based predictive maintenance platform. It identifies unusual patterns in industrial machine sensor data and gives insights into machine health. It uses Python and the Isolation Forest machine learning algorithm to analyse air temperature, process temperature, rotational speed, torque and tool wear. A Streamlit dashboard shows the sensor readings, anomaly detection results and maintenance insights.
The platform uses AWS IoT Core, AWS Lambda and Amazon S3 for cloud-based data ingestion, processing and storage. The goal is to show how machine learning and cloud computing can support proactive equipment monitoring and help reduce unexpected machine failures.
Note: The streaming data in this project is simulated. A Python script generates and replays readings based on a public dataset. It is not connected to real machines.

How it works

Here is the journey of a single machine reading:
  1. A simulator pretends to be several machines and publishes readings as JSON messages over MQTT. Readings can also come from an uploaded CSV file.
  1. AWS IoT Core receives each message and organizes it by topic.
  1. An IoT rule forwards every message to AWS Lambda.
  1. Lambda validates the reading and asks the Isolation Forest model whether it looks Normal or Anomalous.
  1. The result is saved in Amazon S3.
  1. The Streamlit dashboard reads the results and shows charts, machine status and alerts.
  1. When an anomaly appears, a local language model suggests possible causes and checks.


Why these AWS services

AWS IoT Core is the front door. It is built for receiving many small messages over MQTT and routing them onward. The simulator talks to it the same way a real device would, so the project could later connect to real machines without redesigning the cloud side.
AWS Lambda does the processing. Each message triggers one short function run. There is no server to manage, which suits a workload made of many small events.
Amazon S3 is the storage. Results are kept as small files organized by date, so the dashboard can show recent readings and the history of past anomalies.
I kept the list of AWS services short on purpose. Three services were enough, and a smaller design is easier to understand, test and explain.

The data and the model

I trained the model on the public AI4I 2020 Predictive Maintenance Dataset from the UCI Machine Learning Repository. It contains air temperature, process temperature, rotational speed, torque and tool wear.

My first design included a vibration sensor, but this dataset does not have one. I changed the design to match the real columns. Checking your data before finalizing your design saves a lot of rework.
For detection I used scikit-learn's Isolation Forest. In simple terms, it learns what usual readings look like and flags readings that are easy to separate from the rest. It is an unsupervised method, so it finds unusual behavior and does not claim to catch every failure. For that reason, PredictX reports an anomaly as something worth checking, not as a confirmed fault.

Validating data before predicting

Before any reading reaches the model, it passes a validation step. Readings with missing fields, non-numeric values or impossible values are rejected and recorded separately instead of being scored. Bad data produces misleading predictions, so it is better to catch it early and see exactly what was rejected.



Build locally first

The validation and detection logic lives in one small shared module that the dashboard and the cloud function both use. That let me build and test the whole system on my laptop with sample data before connecting anything to AWS. When something broke in the cloud, I already knew the core logic worked, which made problems much easier to find.

Explaining anomalies with an open-source language model

When the dashboard shows an anomaly, it sends the sensor values and how far each one is from normal to a small open-source language model running locally through Ollama. The model replies in simple English with possible causes and suggested checks.
One rule shaped this part: the machine learning model decides, and the language model only explains. The explanation is always worded as a possibility, and it comes with a reminder that a person must verify it. If the language model is unavailable, the dashboard falls back to a simple rule-based summary, so the system keeps working.





The dashboard

The Streamlit dashboard has four areas:
  • Overview: how many machines are normal and how many show anomalies.
  • Sensor monitoring: live charts for each machine, with anomalies marked in red.
  • Anomalies and AI assistant: the list of detected anomalies and the generated explanation for each.
  • Data upload: upload a CSV file, see a validation report, and review the analysed results.



What I learned

  1. Build locally first. Testing without AWS made every cloud problem easier to find.
  1. Keep the architecture small. Three AWS services were enough.
  1. Validate before you predict. Bad data should be rejected and logged, not scored.
  1. Be honest about limits. The data is simulated, the model is unsupervised, and AI explanations are suggestions, not diagnoses.
  1. Match your Python and library versions. Using the same versions locally and in the cloud avoids confusing errors with saved models.

What's next

  • Add notifications when an anomaly is detected.
  • Compare Isolation Forest with other anomaly detection methods.
  • Test the pipeline with data from a real device.

Conclusion

PredictX shows that a cloud project does not need to be big or expensive to be useful. With a clear flow, a small set of AWS services and honest limits, a student can build a working predictive maintenance pipeline.
Thanks for reading! I would love to hear your feedback in the comments.
Github Repo link:  PredictX-AI 



Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article