2021 Call for Code Awards: Live from New York, with SNL’s Colin Jost! Learn more

Predict equipment failure using IoT sensor data

Note: This pattern is part of a composite pattern. These are code patterns that can be stand-alone applications or might be a continuation of another code pattern. This composite pattern consists of:


IoT equipment failure prediction involves collecting sensor values and running algorithms to anticipate impending failures. Core building blocks include identifying the features or factors contributing to equipment failures. Then you configure a predictive model to train the model, followed by scoring the test data to check the reliability of the predictive model. Python 2.0 software is used, with sample sensor data loaded into the IBM Watson Studio cloud.


In a typical retail chain, there are hundreds of pieces of equipment in each store, spread across thousands of store locations across geographic locations. In such scenarios, it becomes difficult to schedule preventive maintenance – more so due to false alarms raised by rule-based systems that turn out to be less serious alerts upon actual inspection, such as an open door on a refrigeration unit.

Advanced predictive methods will enable you to switch from scheduled preventive maintenance to predictive maintenance. This developer pattern is intended for anyone who wants to experiment, learn, enhance, and implement a new method for predicting equipment failure using IoT sensor data. Sensors mounted on IoT devices, automated manufacturing robot arms, and process monitoring control equipment collect and transmit data on a continuous basis.

The first step is to identify any substantial shift in system performance using time-series data generated by a single IoT sensor.

Once a change point is detected in a key operating parameter of the IoT equipment, it makes sense to follow it up with a test to predict if this recent shift will result in the failure of a piece of equipment. This pattern is an end-to-end walk-through of a prediction methodology that utilizes multivariate IoT data to predict equipment failures. A binomial prediction algorithm using logistic regression is implemented for this purpose. We use predictive packages in Python 2.0, with sample sensor data loaded into the IBM Watson Studio cloud. The intermediary steps are modularized, and all code is open-sourced to enable you to use or modify the modules and sub-modules as you see fit for your application.

When you have completed this pattern, you will understand how to:

  • Read IoT sensor data stored in the database.
  • Configure the features and target variables for prediction model.
  • Split the multivariate data into train and test datasets by configuring the ratio.
  • Train the model using logistic regression.
  • Score the test data and measure prediction accuracy.
  • Evaluate the model’s predictive performance by computing a confusion matrix.
  • Re-run experiments by changing configuration parameters.



  1. User signs up for IBM Watson Studio.
  2. User loads sample IoT sensor time-series data to database.
  3. A configuration file holds key parameters for running the IoT time-series prediction algorithm.


  1. User signs up for Watson Studio.
  2. User loads the sample IoT sensor Time series data to database.
  3. A configuration file holds all the key parameters for running the IoT Time series prediction algorithm.
  4. The prediction algorithm written in Python 2.0 Jupyter notebook uses the Configuration parameters and Sensor data from DB.
  5. Python Notebook runs on Spark in IBM Watson Studio to ensure performance and scalability.
  6. The outputs of the prediction algorithm is saved in Object storage for consumption.