Machine Fault Classification using Hamiltonian Neural Networks
A new approach is introduced to classify faults in rotating machinery based
on the total energy signature estimated from sensor measurements. The overall
goal is to go beyond using black-box models and incorporate additional physical
constraints that govern the behavior of mechanical systems. Observational data
is used to train Hamiltonian neural networks that describe the conserved energy
of the system for normal and various abnormal regimes. The estimated total
energy function, in the form of the weights of the Hamiltonian neural network,
serves as the new feature vector to discriminate between the faults using
off-the-shelf classification models. The experimental results are obtained
using the MaFaulDa database, where the proposed model yields a promising area
under the curve (AUC) of $0.78$ for the binary classification (normal vs
abnormal) and $0.84$ for the multi-class problem (normal, and $5$ different
abnormal regimes).
Jeremy Shen, Jawad Chowdhury, Sourav Banerjee, Gabriel Terejanu
# Machine Fault Classification using Hamiltonian Neural Networks

###### Abstract

A new approach is introduced to classify faults in rotating machinery based on the total energy signature estimated from sensor measurements. The overall goal is to go beyond using black-box models and incorporate additional physical constraints that govern the behavior of mechanical systems. Observational data is used to train Hamiltonian neural networks that describe the conserved energy of the system for normal and various abnormal regimes. The estimated total energy function, in the form of the weights of the Hamiltonian neural network, serves as the new feature vector to discriminate between the faults using off-the-shelf classification models. The experimental results are obtained using the MaFauDa database, where the proposed model yields a promising area under the curve (AUC) of 0.78 for the binary classification (normal vs abnormal) and 0.84 for the multi-class problem (normal, and 5 different abnormal regimes).

Physics-Informed Neural Networks, Supervised Learning, Energy Conservation, Dynamical Systems

## 1 Introduction

A cost-effective method for ensuring component reliability is to enhance the current schedule-based maintenance approach with deterministic component health and usage data to inform selective and targeted maintenance activities. Condition monitoring and fault diagnosis systems are required to guard against unexpected failures in safety-critical and production applications. Early fault detection can reduce unplanned failures, which will in turn reduce life cycle costs and increase readiness and mission assurances. Irrespective of different machinery, manufacturing tools like CNC machines, heavy equipment, aircraft, helicopters, space vehicles, car engines, and machines generate vibrations. The analysis of these vibration data is the key to detecting machinery degradation before the equipment or the structure fails. Machine faults usually leave key indications of its internal signature through the changes in modal parameters. For example, they may change the natural frequency of the system, generate unique damping characteristics, degradation in stiffness, generation of acoustic frequencies, etc. The defects and faults in the system may also generate a different form of energy transduction from mechanical to electrical or to electromagnetic energy, which leaves unique signatures. The statistical features of vibration signals in the time, frequency, and time-frequency domains each have different strengths for detecting fault patterns, which has been thoroughly studied [21, 22, 23]. Various approaches have been proposed to extract features from these vibration signals using time-domain and frequency-domain analysis [18], Fourier and wavelet transform [11, 10], and manifold learning [15]. It is also shown that integration and hybridization of feature extraction algorithms can yield synergies that combine strengths and eliminate weaknesses [21, 16]. Most of the work done in this area is based on data collected from vibration sensors [21, 22, 20], which are cheap and enable non-intrusive deployments. However, they generate huge datasets. As these data sets are very big in nature finding the above-mentioned unique features, and their respective paraxial contributions are extremely challenging. Hence, recently several feature extraction-driven machine learning algorithms are deployed to solve this challenge [1, 23, 24, 25].

One of the challenges with building and deploying machine learning models to support decision-making is achieving a level of generalization that allows us
to learn on one part of the data distribution and predict on another. This challenge is amplified when learning using data from physical systems, as machine learning models such as neural networks (NN) capture an approximation of the underlying physical laws. Recently, new approaches have emerged under the umbrella of physics-informed neural networks (PINN) [10] to train NN that not only fit the observational data but also respect the underlying physics. This work leverages the Hamiltonian neural network (HNN) [11] to learn the Hamiltonian equations of energy-conserving dynamical systems from noisy data.

HNNs are used to characterize the total energy of rotating machinery, which is part of a wide range of applications such as power turbines, helicopters, and CNC machines just to name a few. In Ref. [12], the authors proposed a similarity-based model to calculate the similarity score of a signal with a set of prototype signals that characterize a target operating condition. These similarity score features are used in conjunction with time and spectral domain features to classify the behavior of the system using off-the-shelf classification models, such as random forests.

The main contribution of this work is to be intentional with respect to the underlying physics of the rotating machinery when generating discriminatory features. Namely, the conservation of energy is used as an inductive bias in the development and training of the HNN. While these mechanical systems are dissipative in nature, we assume that for short periods of time, the energy of the system is conserved due to the energy injected by the motor. The features derived by our approach are in the form of the weights of the HNN, which characterize the total energy of the system. In other words, we attempt to identify the operating regime based on the energy function. As with the previous approaches, these physics-informed features are then used to train off-the-shelf classifiers, such as logistic regressions and random forests to predict the condition of the mechanical system. The experimental results are performed on the Machinery Fault Database (MaFauIDa)1 from the Federal University of Rio de Janeiro. The proposed system yields a promising area under the curve (AUC) of 0.78 for both the binary classification (normal vs abnormal) and 0.84 for the multi-class problem (normal, and 5 different abnormal regimes).

Footnote 1: [http://www02.smt.ufrj.br/~offshore/mfs/page_01.html](http://www02.smt.ufrj.br/~offshore/mfs/page_01.html)

This paper is structured as follows: Section 2 introduces the background on the HNN and MaFauIDa dataset. Section 3 presents our proposed approach to derive physics-informed features to classify operating conditions. Section 4 shows the empirical evaluations and Section 5 summarizes our findings.

## 2 Background

### Hamiltonian Neural Networks

The Hamiltonian equations of motion, Eq. 1, describe the mechanical system in terms of canonical coordinates, position \(\mathbf{q}\) and momentum \(\mathbf{p}\), and the Hamiltonian of the system \(\mathcal{H}\).

\[\frac{d\mathbf{q}}{dt}=\frac{\partial\mathcal{H}}{\partial\mathbf{p}},\quad \frac{d\mathbf{p}}{dt}=-\frac{\partial\mathcal{H}}{\partial\mathbf{q}} \tag{1}\]

Instead of using neural networks to directly learn the Hamiltonian vector field \(\left(\frac{\partial\mathcal{H}}{\partial\mathbf{p}},-\frac{\partial\mathcal{ H}}{\partial\mathbf{q}}\right)\), the approach used by Hamiltonian neural networks is to learn a parametric function in the form of a neural network for the Hamiltonian itself [11]. This distinction accounts for learning the exact quantity of interest and it allows us to also easily obtain the vector field by taking the derivative with respect to the canonical coordinates via automatic differentiation. Given the training data, the parameters of the HNN are learned by minimizing the following loss function, Eq. 2.

\[\mathcal{L}=\left\|\frac{\partial\mathcal{H}}{\partial\mathbf{p}}-\frac{d \mathbf{q}}{dt}\right\|_{2}+\left\|\frac{\partial\mathcal{H}}{\partial\mathbf{ q}}+\frac{d\mathbf{p}}{dt}\right\|_{2} \tag{2}\]

### Machinery Fault Database

(MaFauIDa)

A comprehensive set of machine faults and vibration data was needed for the development and testing of the Hamiltonian-based feature extraction and classification of different operating states with damage/defects. The Machinery Fault Database (MaFauIDa) consists of a comprehensive set of vibration data from a SpectraQuest Alignment-Balance-Vibration System, which includes multiple types of faults, see Fig. 1. The equipment has two shaft-supporting bearings, a rotor, and a motor. Accelerometers are attached to the bearings to measure the vibration in the radial, axial, and tangential directions of each bearing. In addition, measurements from a tachometer (for measuring system rotation frequency) and a microphone (for capturing sound during system operation) are also included in the database. The database includes 10 different operating states and a total of 1951 sets of vibration data: (1) normal operation, (2) rotor imbalance, (3) underhang bearing fault: outer track, (4) underhang bearing fault: rolling
elements, (5) underhang bearing fault: inner track, (6) overhang bearing fault: outer track, (7) overhang bearing fault: rolling elements, (8) overhang bearing fault: inner track, (9) horizontal shaft misalignment, (10) vertical shaft misalignment.

**Normal Operation**. There are 49 sets of data from the system operating under normal conditions without any fault, each with a fixed rotating speed within the range from 737 rpm to 3686 rpm with steps of approximately 60 rpm.

**Rotor Imbalance**. To simulate different degrees of imbalanced operation, distinct loads of (6, 10, 15, 20, 25, 30, 35) g were coupled to the rotor. The database includes a total of 333 different imbalance-operation scenarios with combinations of loads and rotation frequencies.

**Bearing Faults**. As one of the most complex elements of the machine, the rolling bearings are the most susceptible elements to fault occurrence. Three defective bearings, each one with a distinct defective element (outer track, rolling elements, and inner track), were placed one at a time in each of the bearings. The three masses of (6, 10, 20) g were also added to the rotor to induce a combination of rotor imbalance and bearing faults with various rotation frequencies. There is a total of 558 underhang bearing fault scenarios and 513 overhang bearing fault scenarios.

**Horizontal Shaft Misalignment**. Horizontal shaft misalignment faults were induced by shifting the motor shaft horizontally of (0.5, 1.0, 1.5, 2.0) mm. The database includes a total of 197 different scenarios with combinations of horizontal shaft misalignment and rotation frequencies.

**Vertical Shaft Misalignment**. Vertical shaft misalignment faults were induced by shifting the motor shaft vertically of (0.51, 0.63, 1.27, 1.4, 1.78, 1.9) mm. The database includes a total of 301 different scenarios with combinations of vertical shaft misalignment and rotation frequencies.

## 3 Methodology

The approach proposed to identify the operating state of the rotating machinery is to learn the total energy of the system from vibration data using HNN and use the parameters of the Hamiltonian as discriminating features. The intuition is that the total energy signature is different under various faults. The main assumption that we make is that the energy of the system is conserved for short periods of time thanks to the energy injected by the motor, which allows us to use the HNN [1]. The overall model architecture is shown in Fig. 2.

The first step is to develop a set of generalized coordinates from the raw vibration data using an autoencoder trained only on the data from normal conditions. The encoder NN is then used to generate a low dimensional representation (2D in our case) from the 8 vibration measurements taken in any operating regime. This approach in developing arbitrary coordinates has been proposed in the original HNN paper [1].

Using the newly developed coordinates, the second step is to train an HNN for each sequence of data generated at 50 kHz sampling rate during 5 s. The parameters \(\theta\) of the Hamiltonian \(\mathcal{H}_{\theta}\) fully characterize the energy function of the operating state and they can be used to train a classifier.

The parameterization of the Hamiltonian is high-dimensional (\(41,200\) weights in our case) as it depends on the number of layers and hidden neurons per layer chosen in HNN. As a result, we have chosen to reduce its dimension using principal component analysis (PCA) before training a classifier as a random forest in the last modeling step.

## 4 Numerical Results

The proposed fault classification system has been used with the MaFaulDa dataset and a \(70:30\) split into train and test data. Given the imbalance of collected data, namely 49 datasets recorded for normally operating motors vs. 1800+ datasets recorded for all faulty operating motors, we have used the synthetic minority over-sampling technique (SMOTE) [1] to create synthetic data points for the minority class. The PyCaret2 framework was used to develop the classifiers and preprocess the HNN features.

Footnote 2: [https://pycaret.org](https://pycaret.org)

Two different tasks are considered. The first is the binary classification where we are discriminating between normal and abnormal conditions using a random forest, and the second is the multi-class problem where we are discriminating using a logistic regression between the classes listed in Table 1, where class 0 is the normal regime.

The receiver operating characteristic (ROC) curves are provided for both tasks in Figs. 3 and 4 respectively. The macro-averaged AUC calculated on the test data is 0.78 for the binary classification and 0.84 for the multi-class problem and the F1 score is 0.96 and 0.51 respectively, which demonstrates the viability of physics-informed features from HNN to
capture the state of the system. These classification problems are imbalanced due to the skewed distribution of examples across the classes and as a result, we have chosen not to report the accuracy as it was reported in prior work [10, 11]. We note however that Ref. [10] reports an F1-score of 0.99 on a 10-fold cross-validation exercise, which is higher that the 0.96 on our binary classification, and that our multi-class F1-score is lower due to the aggregation of bearing fault classes.

Table 1 shows the AUC for pairwise classification between each unique defective operating condition and the normal condition. Fig. 6 shows the phase spaces of 10 different operating conditions (1 normal and 9 faulty). Interestingly, among all the pairwise comparisons, the model finds the discrimination between normal and horizontal-misalignment regimes rather challenging, which we plan to further explore in future studies. We do expect that the faults introduced generate slight changes in the phase portraits of various regimes, see Fig. 6. However, we find qualitatively that the phase portrait of overhang/ball-fault is significantly different than the rest, which suggests that the sub-classes of overhang, namely ball-fault, cage-fault, and outer-race should be treated as classes on their own.

**Discussion on the effect of rotation frequency on the Hamiltonian**. Fig. 5 shows the Hamiltonian of normally operating motors operating at different speeds. Interestingly, even though this has not been enforced, the general structure of the Hamiltonian vector field remains largely the same across various speeds, while the magnitude of the Hamiltonian increases at higher speeds as expected. It can be concluded in this case that the vector field is dependent on the operating condition, and the magnitude is dependent on the operating speed.

**Discussion on HNN on Dissipative Systems**. The HNN has the ability to learn the total energy of a number of systems [1], including an ideal mass-spring system. Although the HNN is designed to conserve energy, it is interesting to consider what the HNN learns from dissipative systems. We believe that the methodology is more broadly applicable and it applies also when this assumption does not hold.

We have used a mass-spring-damper to experiment with the behavior of HNN for dissipative systems. This is a non-conservative system and the Hamiltonian formulated by the HNN is not a conventional solution to the mass-spring-damper system, the conserved quantity is not the total energy, and the generalized coordinates are not position and momentum defined by classical mechanics. Nevertheless, a qualitative analysis of the trajectories shows that the HNN creates unique solutions for each value of the damping ratio, see Fig. 7. While we are unable to use conventional physics to understand the results of the HNN on the mass-spring-damper system, it is evident that the results can be used to discriminate between the different systems.

\begin{table}
\begin{tabular}{|l|l|l|l|} \hline Class & **normal vs X** & **AUC** & **F1-score** \\ \hline
1 & horizontal-misalign. & 0.59 & 0.80 \\ \hline
2 & imbalance & 0.92 & 0.95 \\ \hline
3 & overhang & 0.85 & 0.85 \\ \hline
4 & underhang & 0.80 & 0.88 \\ \hline
5 & vertical-misalign. & 0.91 & 0.92 \\ \hline \end{tabular}
\end{table}
Table 1: Pairwise classification - results on testing set

Figure 1: SpectraQuest System: Alignment-Balance-Vibration
## 5 Conclusions

A novel predictive model is introduced to discriminate between normal and abnormal operating regimes of rotating machinery. The model is based on the total energy signature of the system learned using a Hamiltonian Neural Network. The performance measures obtained from the experimental data suggest that the proposed physics-informed features are an excellent candidate for machine fault classification.

Figure 4: Results on test set - multi-class problem

Figure 3: Results on test set - binary classification

Figure 2: The proposed fault classification model
## Acknowledgement

Research was sponsored by the National Institute of Food and Agriculture under Grant Number 2017-67017-26167 and by the Army Research Office under Grant Number W911NF-22-1-0035. The views and conclusions contained in this document are those of the authors and should not be interpreted as representing the official policies, either expressed or implied, of the Army Research Office, the National Institute of Food and Agriculture, or the U.S. Government. The U.S. Government is authorized to reproduce and distribute reprints for Government purposes notwithstanding any copyright notation herein.

Figure 5: The effect of rotation frequency on the Hamiltonian

Figure 6: Phase portraits of various operating conditions

Figure 7: HNN results on variable damping ratios