Pump Failure Detection App-Application based on IIoT

Why is Pump Failure Detection important?

A pump is a device that moves fluids by mechanical action, typically converted from electrical energy into hydraulic energy. There are different types of pumps depending upon the method that is used for moving the fluid. In India, pumps are one of the main reasons for the growth of the economy, as India is an agriculture-based country and the requirement of water pumps is huge in the case of agriculture.

Hence, it is very important to detect the failures in pump machines beforehand to ensure smooth operation. We generally take the help of sensor data to detect the failure caused in pumps.

Photo by Tarun P on Dribbble

In this article, we will learn about a MLP (Multilayer perception), that predicts whether a water pump will fail in a future time window or not.

The input for the MLP is a time window of some specified length of the pump sensor data (52 sensors, called “sensor_00” till “sensor_51”)and, the output is a single output neuron.

OUTPUT STATUS :

> 0 means: there will be no failure (machine status “NORMAL”)

>1 means: there will be a pump failure (machine status “BROKEN”/”RECOVERING”).

We will prepare 2000 random samples, out of which 2000/2 = 1000 random samples (x,y) will be used for training and the other 1000 random samples(x,y) will be used for testing the model.

Note: Here ‘x’ denotes the input vector taken from the input window, and ‘y’ denotes the output vector which is calculated by checking whether in the following time window the pump failed or not.

Sketch of the approach

Reading the Sensor and Status data

As defined earlier, we have taken 52 sensors, called “sensor_00” till “sensor_51”.

>First line of Code!

https://gist.github.com/Gunjan933/2944981e23e7c188837fb063396f7271

> Checking machine_status!

Previously defined, our output is designed for three machine_status i.e Normal, Broken, and Recovering.

Calculating the percentage value for machine_status = Normal:

https://gist.github.com/Gunjan933/3d5abec2dd661a181d7ca417a1690732

Similarly, we can calculate percentage values for Broken and Recovering status. The obtained graph will be somewhat like :

Prepare data for training and testing

Scale data column-wise to feature range [0,1]. If all inputs are in the same range, it makes it easier for a MLP to learn.

https://gist.github.com/Gunjan933/806e8c7f06ae50dc28a95e82d888c7d2https://gist.github.com/Gunjan933/d2e66ebba831e82d80d2512949e69063

A single_input_window contains data for 60 minutes for each of the 52 sensors. Next, we map the window to a vector since we need a 1D input for the MLP.

https://gist.github.com/Gunjan933/5f59fa8c20c220c89d5de6d310e6adf5

Check whether the pump failed in some time window after the input window

https://gist.github.com/Gunjan933/da986520e58f2098e8e4f17a47385eec

Prepare Example Data

https://gist.github.com/Gunjan933/03ce3612495aa2d2aedaa8f74d42bbe6

The training pairs are further stored into a data matrix D for the further splitting of training and testing samples. The shape of matrix D is (2000,3121).

Creating the matrix D!

https://gist.github.com/Gunjan933/ec5eeaaab4ab85e69434310140a748bd

Train Test Split

https://gist.github.com/Gunjan933/d62b0efa14725073f33f6f64d88c296e

Build MLP and train it

The model to be created consists of 3 fully connected layers, ReLU activation function is present in every layer except the last layer. We will train the model for 3000 epochs, in which we have taken MeanSquaredError as our loss function and SGD optimizer for compilation.

Testing the Final MLP

Testing the final MLP we can conclude that the MLP can predict 972 out of 1000 test examples with an accuracy of 97.20%.

True positive: 29
True negative: 943
False-positive: 12
False-negative: 16

> The Accuracy graph :

Accuracy — 97.20%

Compiling with deepC:

https://gist.github.com/Gunjan933/7edbe03ebb17dfa225e5976c30bf1d14

Here’s the link to the complete notebook: https://cainvas.ai-tech.systems/use-cases/pump-failure-detection-app/

Credits : Jürgen Brauer, Sanlap Dutta