The world’s leading publication for data science, AI, and ML professionals.

Predictive maintenance – 5minutes demo of an end to end machine learning project

A step-by-step and end-to-end guide to building machine learning project

Photo by Luka Slapnicar on Unsplash
Photo by Luka Slapnicar on Unsplash

Background

Remaining useful life (RUL) refers to the the remaining life time when a system can continue to operate normally after working generally for a period of time. With RUL, engineers can schedule maintenance time, optimize operation efficiency and avoid unplanned downtime. Therefore, predicting RUL is the primary task in predictive maintenance planning.

Image by author
Image by author

This picture shows the degradation of the machine over time. If A is the current condition and B is the minimum acceptable condition that the machine will fail, the remaining service life is calculated as the time between these two points. If RUL is estimated in advance, it can be maintained or replaced to avoid unplanned downtime and economic losses. Since RUL’s forecast is significant for operation and decision-making, it is crucial to estimate it accurately.

Today, our task is to develop a real-time intelligent application for remaining service life prediction through a Machine Learning model. We use the Turbofan Engine Degradation Simulation Data Set provided by NASA as the training set and test set to develop an application for intelligent prediction of remaining hardware life and complete real-time prediction. The final prediction result is time in cycle, which means how many times the engine could rotate in the future in an acceptable condition.

You can operate directly according to the following steps. Later, we will also attach the code required for training. This article mainly shows how to quickly complete an end-to-end machine learning application, omitting the process of data exploration.

Using docker to pull the demo image

At first, please check if the docker(which is the only dependent component to run the demo) is installed on your computer.

$ docker pull 4pdosc/openmldb_turbo_rul_demo:0.7.0

Run the image

Here we choose the bash command to run it

$ docker run -it 4pdosc/openmldb_turbo_rul_demo:0.7.0 bash

Switch to the corresponding directory and initialize the environment.

The whole initialization process includes installing OpenMLDB and the related running environment. For the initialization script, please refer to init. sh

$ cd rul && sh init.sh

Import historical data to OpenMLDB

Historical data is required for time series feature calculation using [OpenMLDB](https://github.com/4paradigm/OpenMLDB), so we import historical data into OpenMLDB for real-time inference. Historical data can be used for feature inference.

  1. For the import code, please refer to import.py.
  2. Use t_est here_ Fd004. TXT_ as historical data, there are detection data of multiple engine cycles.
$ python3 import.py

Train the model

Model training requires training data. The following is the code used for generation.

  1. Training feature generation script code is in _train.p_y
  2. Training data is _train_ Fd004. TXT_, which has the detection data of multiple engine cycles

Finally, we could generate the model.

$ python3 train.py ./fe.sql /tmp/model.txt

Using the training model to build real-time reasoning HTTP service

Based on the training feature matrix generated in the previous step, we use ‘random forest regressor‘ for training. The obtained training model, combined with the historical data in OpenMLDB, to build a real-time reasoning service, and the whole inference service code refers to predict server.py._

$ sh start_predict_server.sh ./fe.sql 9887 /tmp/model.txt

Then we could send an inference request via HTTP request

$ python3 predict.py

Finally, the prediction result can be printed

----------------ins---------------
         1     2      3       4    5    6    7
0  35.0033  0.84  100.0  449.44  0.0  0.0  0.0
---------------predict rul -------------
[321.26]
Congraduation! You have finished the task.
Your Key:b'kSpmZICy0kuTqgAPGC8TMCg/3HmnscIfJrESkOEekOpfcW6+oGnltUf9Vts='

The ins section above shows the features calculated using OpenMLDB. Here the feature we use is simplified. You could read the fe.sql file for specific features;

The following prediction RUL shows the prediction result, time in cycle, which means the engine can continue to rotate 321 times.

With the help of a database, you can complete the end-to-end application of machine learning. Isn’t it amazing!

If you want to learn more, you could click: OpenMLDB

Architecture

Image by author
Image by author

Related Articles