Industrial Motor Fault Classification using Deep Learning with IoT Implications | by Milan Kordic | Towards Data Science

Purpose
The following work is for educational purposes only and is not intended for commercial use.
I continually challenge myself to develop my skills in engineering, data science, communication, and business acumen. I enjoy working on projects that test my knowledge, push me out of my comfort zone, and allow me to express my creativity. I undertook this personal project to further develop my experience in machine learning by working with a real-world dataset related to electric motor operations.
I learned a lot — and am now sharing my learnings with you, the reader, using the Medium platform to increase my public portfolio of work and to develop my communication skills.
All of the source code is publicly available through a repository on my GitHub.
Enjoy!
One of my first assignments as a new electrical engineering graduate was to diagnose and troubleshoot an out-of-service induction motor. The first step was to exam the symptoms of the fault and determine the root cause of failure. In order to do this, I required a specific diagnostic tool and a detailed testing procedure. Unfortunately, the diagnostic tool was unavailable in the short-term and the testing procedure required a minimum of 3 weeks to execute.
I continue to think about this scenario and I classify it as an opportunity to improve the current standards for motor diagnostics and repair. My assumption is that there is a faster and more cost effective solution to classify motor faults and to reduce operations downtime.
Industrial motors are the workhorse of the modern economy. They are found in all of the major industries such as power generation, oil and gas, mining, and manufacturing. A failure of an industrial motor, and a prolonged diagnostics and repair process, would cause losses in production value.
In this article, I examine the feasibility of implementing an artificial intelligence (AI) solution to diagnose and report a motor fault in real-time to the system operator. Such a solution would reduce the time required by engineers and technicians to diagnose a failure and therefore reduce the duration of downtime in operations.
The scope of this experiment is to assess the feasibility of developing a machine learning model capable of classifying different motor operating states. I will develop two machine learning models:
Binary classifier to detect when a fault occurs
Multi-class classifier to categorize the type of fault
In order to develop a machine learning model capable of classifying motor faults, there must be sufficient data available to train the model.
For this experiment, I am using publicly available data from the Machinery Fault Database [1]:
“This database is composed of 1951 multivariate time-series acquired by sensors on a SpectraQuest’s Machinery Fault Simulator (MFS) Alignment-Balance-Vibration (ABVT). The 1951 comprises six different simulated states: normal function, imbalance fault, horizontal and vertical misalignment faults and, inner and outer bearing faults.”
The first step is to build a data acquisition module capable of ingesting the data from its source and storing the data in a data structure for processing. The data is organized in a batch of folders labelled by operating condition, in comma-separated values (csv) files sorted by speed of rotation. Each csv file is a training instance.
INPUT_DATA_DIR = get_project_root() / Path('data_acquisition/data')NORMAL_FILE_NAMES = glob.glob(str(INPUT_DATA_DIR)+'/normal/*.csv')HORI_MIS_FILE_NAMES = glob.glob(str(INPUT_DATA_DIR)+'/2.0mm/*.csv')IMBALANCE_FILE_NAMES = glob.glob(str(INPUT_DATA_DIR)+'/25g/*.csv')
For this project, I will focus on three distinct operating conditions: normal, imbalance, and horizontal misalignment. The normal and imbalance datasets contain 49 training instances each, and the horizontal misalignment dataset contains 47 training instances. Each training instance contains an encoder signal to measure the speed of rotation, six accelerometer signals: two in the axial direction, two in the tangential direction, and two in the radial direction, and an audible noise signal from a microphone. The signals are sampled at a rate of 50,000 Hz for 5 seconds; therefore, each signal is a time-series with 250,000 samples.
To get a better sense of the available data, listen to the motor performance under each condition.


633 plays633




569 plays569




558 plays558


Can you hear the difference?
My hypothesis is that these sound signals, and signals collected from the accelerometers, are sufficient to develop an AI model capable of classifying the different operating conditions.
Before we can feed the data into a machine learning algorithm, we need to perform some preliminary data processing. Let’s look at a plot of all the time-series signals under the normal operating condition for one training instance.
The initial analysis of the data and data plot reveal two key insights:
There are a large number of data points due to the high sample rate
The signals are not on the same scale
Both of these insights would have implications on the machine learning algorithm:
Too many data points would require longer model training times
The different scales would skew the machine learning model results
Data Resampling
First, we should resample the data at a lower frequency to reduce the size of each training instance and therefore speed up the training algorithm. To determine the resampling rate, let’s analyze the frequency spectrum of signals using a Fast Fourier transform (FFT):
The frequency spectrum is cut-off at the Nyquist frequency of 25,000 Hz. The FFT shows a large percentage of high signal strength frequencies located at a lower frequency bandwidth (0 Hz — 5,000 Hz). There is a second bandwidth of relatively high strength frequencies at 20,000 Hz — 25,000 Hz, and there is a dead-band between 5,000 Hz and 20,000 Hz. At the cost of losing information from the high-frequency bandwidth, a decision is made to resample the data at a lower rate of 500 Hz. The lower sampling rate would reduce the number of time-series data points from 250,000 to 2,500, which is two orders of magnitude lower; therefore, significantly reducing the model training time.
The frequency spectra of the resampled signals show specific characteristics to the operating conditions when contrasted across the same speed of rotation:
Data Scaling
The next data processing step is to rescale the signals to a common scale. This function would ensure that the machine learning model does not skew the final results.
Frequency Domain
The final step in the data processing pipeline is to convert the signals from time domain to frequency domain. This conversion is achieved by transforming the data using a FFT. The benefits of transforming the data to the frequency domain are:
By using only the positive spectrum of frequencies, the number of rows per training set decreased from 2,500 to 1,250; therefore, reducing the model training time
The frequency spectrum has more indicative characteristics per operating condition; therefore, improving the model accuracy
Train/Test Split
One final step is to set aside a portion of the data to be used at the very end for model validation. This is know as the test set.
To begin this section, I will reference a useful infographic on the relationship between artificial intelligence, machine learning, and deep learning.
Since the input data follows a sequence (frequency domain), I will be using a recurrent neural network (RNN) architecture which is a deep learning architecture. Specifically, I am using the long short-term memory (LSTM) architecture.
Implementing a LSTM model is quite straightforward using the TensorFlow library in Python. I will start with the simplest architecture which contains two layers: a LSTM input layer and a dense output layer with a configurable activation function.
For the binary classification model, I am using a sigmoid activation function and a binary cross-entropy loss function to train the model.
Model: "sequential"_________________________________________________________________Layer (type)                 Output Shape              Param #   =================================================================lstm (LSTM)                  (None, 100)               43600     _________________________________________________________________dense (Dense)                (None, 1)                 101       =================================================================Total params: 43,701Trainable params: 43,701Non-trainable params: 0
The model is trained on 116 training instances with a 20% validation hold-out set across 100 epochs. The model reaches a 100% accuracy score on the training and validation data.
For the multi-class classification model, I am using a softmax activation function and a sparse categorical cross-entropy loss function to train the model.
Model: "sequential"_________________________________________________________________Layer (type)                 Output Shape              Param #   =================================================================lstm (LSTM)                  (None, 100)               43600     _________________________________________________________________dense (Dense)                (None, 3)                 303       =================================================================Total params: 43,903Trainable params: 43,903Non-trainable params: 0
The model achieves a 100% accuracy score on the training and validation data.
The models are validated on a test set which was held out post-processing. The test set contains 29 instances and both models were able to accurately classify all 29 samples — achieving a 100% test score.
The final binary and the multi-class classification models proved to be successful at accurately identifying motor faults and classifying faults by type.
Some key lessons learned:
85% of my time was spent on the data processing and exploratory data analysis stage.
The final model, although it sounds very sophisticated (DL, RNN, LSTM), was the easiest part to set up.
I leveraged my industry and academic experience working with electric motors, and my background in electrical engineering, to produce a successful model. For example, I initially used the time domain as my input to the model, which produced training and validation scores no better than random sampling (66%). It wasn’t until I performed frequency domain transformations that I saw significant model improvements.
I made very little adjustments to the learning model; the most significant gains came from data processing.
The data used for this project is a subset of the available data. There are a total of six available states for classification: normal, imbalance, horizontal misalignment, vertical misalignment, underhang bearing fault, and overhang bearing fault. Additionally, some states have substates, for example, the horizontal misalignment can be classified by the amount of misalignment in millimetres: 0.5 mm, 1.0 mm, 1.5 mm, and 2.0 mm. A more useful model would be one which incorporates all of the fault conditions and can sub-classify each fault by the extremity of its condition.
As stated from my introduction, the purpose of this project is for educational purposes and not for commercial use. However, it is exciting to think about the potential that the results from the use case can have on our industrial world. The implementation of interconnected technologies in industrial environments has progressed to include faster connectivity networks, cloud computing systems, and big data analytics. I envision that the results of my work could be significantly improved, enhanced, and integrated into a larger asset management strategy across various industries to improve operations, efficiencies, reliability, and safety.
Final Remarks
Thank you for taking the time to read my article. I hope it was of some value to you and that you were able to learn at least one new piece of information. I hope to continue publishing similar articles and would appreciate any constructive criticism you can provide.
For any future publications please subscribe to my Medium profile and add me on LinkedIn.
To access my code repositories, where you can find all of the source code for this project and other projects I completed, please check out my GitHub.
Thank you
Milan Kordic
References
[1] Machinery Fault Database, Machinery Fault Dataset (2021), Web