Predictive maintenance using machine learning | Towards Data Science

Different types of maintenance strategies have been widely deployed in oil and gas industry. Oil and gas industry today can utilize data science or machine learning instead of relying on old maintenance practices to better predict equipment failures and for conducting root cause analysis. Maintenance activities can be broadly divided into three major categories Corrective, Preventive and Predictive maintenance. Corrective maintenance refers to repair work after equipment outage occur. Preventive maintenance is based on certain periodic intervals to prevent equipment failure before it occurs. Predictive maintenance relies on engineering tools and statistical analysis to process the data and analyze health condition of equipment. Condition monitoring is also a form of predictive maintenance which relies on equipment sensors data to predict any failure.
Oil and gas companies have a complex system of machinery, like huge extractions platforms and thousands of kilometers of hydraulic systems to transport the product. Guarantee the perfect functioning of this structure is not an easy task. Oil and gas companies spend millions of dollars in maintenance cost to keep their equipment running 24/7. Using better data analytics approach they can not only cut down their maintenance cost but can increase their asset productivity to many folds. In this article we will discuss and present a real-life scenario where hydraulic systems data is used to train machine learning model for better predicting equipment failure.
Monitoring sensors in hydraulic systems capture measures such as pressures, volume flows and temperatures. This sensor collects this information at tiny periods (every 60 seconds, per example)
These extractions generate a huge time-series raw data set, with thousand or even millions of observations! This data is used by the computers to predict failures in these systems. The monitoring reduces downtime and maintenance costs and allows preventive health checks.
There is a large variety of models to use on the data collected. A powerful one is Neural Networks or more precisely, Artificial Neural Networks (ANN). How fun this name is! If you are imagining some brain activity with synapses occurring, you are not totally wrong.
This name comes from the idea that a unique neuron alone is a fairly complex structure, but when we join together some thousand of them, related all its connections and the exchange of information that occurs from this interaction, this structure becomes highly intricate and the brain could do incredible things.
In the Machine Learning environment, Artificial Neuron Networks could be used for a regression or a classification problem. Remember that we can divide the Machine Learning into two groups, the regression models and the classification models. They simply differentiate one from the other by the class of its variable of interest. Regression models: the output is a continuous variable. Classification models: the output is a categorical variable (discrete).
So, let’s go to work!
doing a good job.
#The ann_leakage data frame contains data from a sensor installed on #a hydraulic system in an oil and gas company. Take a look!kable(head(ann_leakage[,-(8:9)]))
The variable ann_leakage is 0 if the is no pump leakage, 1 if the is a weak leakage, and 2 for a severe leakage. PSxx stands for pressure measures, FSxx is the measures for volume flow, and TSxx is temperature measures. I take just 2 attributes for each variable.
To work on Neural Networks, we can divide the process into 4 steps:
1. Transform the categorical variables into binary variables;
2. Subset the data into a train set and a test set;
3. Train the data;
4. Test the data.
Ok, does this sound very technical to you? Don’t worry, I will explain each step separately.
Step 1: Transform the categorical variables into binary variables
Categorical variables describe characteristics of something. In the hydraulic systems of an oil and gas company, per example, a categorical variable could be an internal pump leakage, this is a preoccupation for the company’s engineers. We can classify this problem into three categories: No leakage; weak leakage; severe weak leakage.
So, to evaluate the probability for one of them, we have to set a binary variable of 1 if it is the category of interest and 0 if not. Doing this, we have the output variable.
#One should transform the ann_leakage variable into binary #variables. To predict just pump leakage I join weak and severe pump #leakage in the same variable.ann_leakage <- profile[,3]ann_leakage <- cbind(ann_leakage, PS1[,1:2], FS1[,1:2], TS1[,1:2])ann_leakage <- cbind(ann_leakage, ann_leakage$ann_leakage == 0)ann_leakage <- cbind(ann_leakage, ann_leakage$ann_leakage >= 1) colnames(ann_leakage)[8] <- “no”colnames(ann_leakage)[9] <- “leakage” kable(head(ann_leakage[,c(1,8,9)]))
Step 2: Subset the data
We have to separate the data set into two groups. With the first we perform a test model, to tell the data how it will handle the data. The other set, the train set, is to verify if the models are efficient in predicting the output.
#shuffle the data. subset into training and test setsset.seed(2403)redux <- sample(nrow(ann_leakage), 2000)ann_leakage <- ann_leakage[redux,] #scaling data ann_leakage <- cbind(scale(ann_leakage[,-(c(8,9))]), ann_leakage[,c(8,9)]) n <- nrow(ann_leakage)ntrain <- round(n*0.6) # 60% for the training settindex <- sample(n, ntrain) # create an indextrain_ann <- ann_leakage[tindex,] # create training settest_ann <- ann_leakage[-tindex,] #create test set
Neural Networks model is a non-linear regression that uses as its argument linear combinations from the variables in the data. Despite this fancy name, Artificial Neural Networks (ANN), can be defined by this simple phrase. It doesn’t look so complicated now, does it?
Step 3: Training the data
Training the data means to tell the computer how it will handle the data and how it will relate the input (sensor measures) with the output (binary variable from the pump leakage categories). We can use the Neural Network specification to do this.
#training the data set using the training datasetlibrary(neuralnet)ann <- neuralnet(no+leakage ~ PS11+PS12+FS11+FS12+TS11+TS12,data = train_ann, hidden = c(3)stepmax = 1e+05, threshold = 0.3) plot(ann, show.weights = FALSE, col.entry = “darkgreen”,col.hidden = “blue”, col.hidden.synapse = “blue”, col.out = “red”, col.out.synapse = “red”,col.entry.synapse = “darkgreen”, intercept = FALSE, information = FALSE)
The circles are the neurons and the arrow are the synapses. In green are the inputs, in blue the hidden layer (neurons), and in red the output.
Step 4: Test the data
Once we perform the model, we obtain the parameters associated. Now we have to predict the values using a different input data set (the test set) and compare the results from the predicted model and the output variable in the test set cresting what is named the confusion matrix, that counts how many predictions the model did correctly and how many predictions the model missed.
#Validate the model by predicting using the test data set predict <- neuralnet::compute(ann, test_ann[-1])predict <- predict$net.result#create a vector containing the response variables predcited#by the neural network and create a confusion matrix#to check the accuracy of the model pred_idx <- function(x) {return(which(x == max(x)))}idx <- apply(predict, c(1), pred_idx)predict_leakage <- c(“no”, “leakage”)[idx]library(expss)test_leakage <- if_else(test_ann[,”leakage”] == TRUE, “leakage”, “no”)xtab <- table(predict_leakage, test_leakage)library(knitr)kable(table(xtab, 1))
Doing this we are able to calculate the accuracy rate, that is simply a percentage rate of right predictions. So in this case, the model predicts 94 % of the pump leakages. It is very accurate and very fun, doesn’t?
Conclusion
Oil and Gas industry now a days is struggling for its survival due to downturn in oil prices. Instead of using old fashioned methods which relies on OEM manuals and best practices for predicting equipment failures, machine learning can be used for predicting equipment failures. The prediction from the ANN model emphasizes proactive maintenance and provides the right time to conduct inspection. ANN captures the possible reasons, like the timeline of the equipment failure event, reasons, duration and relevance information of the equipment by triggered sensory information. With systematic maintenance in advanced, unplanned equipment failure can be eliminated which will result in increased profits and productivity
1. Gutierrez DD (2015) Machine Learning and Data Science: An Introduction to Statistical Learning Methods with R. Technics Publications. LLC.
2. Hastie T, Tibshirani R, Friedman J (2013) The Elements of Statistical Learning: Data Mining, Inference, and Prediction, 2nd ed.
3. Helwig N, Pignanelli E, Schutze A (2015) Condition monitoring of a complex hydraulic system using multivariate statistics. 2015 IEEE International Instrumentation and Measurement Technology Conference (I2MTC) Proceedings
4. Nikolai Kelwig, Eliseo Pignalli, Andreas Schutze (2015) Detecting and compensating sensor faults in a hydraulic condition monitoring system. AMA Conferences 2015 — SENSOR 2015 and IRS2 2015