{'fraction_non_alphanumeric': 0.03145668656234877, 'fraction_numerical': 0.013832876270366189, 'mean_word_length': 4.818160488033787, 'pattern_counts': {'":': 1, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Machine Learning-Based Unbalance Detection of a Rotating Shaft Using Vibration Data

Fault detection at rotating machinery with the help of vibration sensors offers the possibility to detect damage to machines at an early stage and to prevent production downtimes by taking appropriate measures. The analysis of the vibration data using methods of machine learning promises a significant reduction in the associated analysis effort and a further improvement in diagnostic accuracy. Here we publish a dataset which is used as a basis for the development and evaluation of algorithms for unbalance detection. For this purpose, unbalances of various sizes were attached to a rotating shaft using a 3D-printed holder. In a speed range from approx. 630 RPM to 2330 RPM, three sensors were used to record vibrations on the rotating shaft at a sampling rate of 4096 values per second. A development and an evaluation dataset are available for each unbalance strength. Using the dataset recorded in this way, fully connected and convolutional neural networks, Hidden Markov Models and Random Forest classifications on the basis of automatically extracted time series features were tested. With a prediction accuracy of 98.6 % on the evaluation dataset, the best result could be achieved with a fully-connected neural network that receives the scaled FFT-transformed vibration data as input.


I. INTRODUCTION
Progress in the field of machine learning has led to impressive results in recent years, for example in the areas of image recognition [1]- [4], natural language processing [5]- [9] or reinforcement learning [10]- [13]. In addition to these examples, which are very present in the media, these algorithms also offer great potential for industrial applications [14]- [18]. For example, the analysis of vibrations on rotating shafts to detect damage to roller bearings or to detect unbalances has proven to be very promising [19]- [27]. Here, we focus on the second mentioned use case. Unbalances on rotating shafts can cause decreased lifetimes of bearings or other parts of the machinery and, therefore, lead to additional costs. Hence, early detection of unbalances is important in order to minimize maintenance expenses, avoid unnecessary production stops and increase the service life of machines. Algorithmic detection of unbalances is accompanied with the least additional effort. The automation achieved in this way also enables live analysis of streamed data, which means that unbalances can be detected and corrected with almost no time delay, even before potential damage to the drive train occurs.
We observe that there are only a few publicly available condition monitoring (CM) datasets with the help of which algorithms can be tested and compared. There are e.g. datasets for CM with hydraulic systems [28] and for detecting bearing damage [29]- [31], but there seems to be no dataset for detecting unbalances, which in turn can be a cause of bearing damage. For this reason, we publish a dataset for the detection of unbalances based on vibration data along with this study (available in the Fraunhofer Fordatis database [32]). In addition, we carry out analyses to determine which algorithms can detect the unbalance as accurately as possible and up to which unbalance strength these can still be reliably recognized by each algorithm. The Python code used for the investigations conducted in this study is open-sourced in a Github repository [33]. The setup for the simulation of defined unbalances and the measurement of the resulting vibrations is powered by an electronically commutated DC motor (WEG GmbH, type UE 511 T), which is controlled by a motor controller (WEG GmbH, type W2300) and is fixed to the aluminum base plate by means of a galvanized steel bracket. The motor controller allows for a rotation speed between approximately 300 and 2300 revolutions per minute (RPM), which can be continuously adjusted by varying a voltage that is applied to the motor controller. The motor powers a shaft with a diameter of 12 mm which is connected to another shaft of the same diameter and a length of 75 mm by a coupling (Orbit Antriebstechnik GmbH, type PCMR29-12-12-A). This shaft in turn passes through a roller bearing which is clamped in a roller bearing block (material: galvanized steel). The unbalance holder is attached directly behind it. This part was made using a 3D printer (Ultimaker 3, material: nylon) and consists of a disc (diameter: 52 mm) with axially symmetric recesses, in which weights can be inserted to simulate unbalances. Vibration sensors (PCB Synotech GmbH, type PCB-M607A11 / M001AC) are attached to both the bearing block and the motor mounting and are read out using a 4-channel data acquisition system (PCB Synotech GmbH, type FRE-DT9837). As shown in Figure 2, the rotation speed of the motor is acquired using a frequency counter in the DT9837, which digitizes the periodicity of the rotor position signal from the motor. A photo of the measurement setup is shown in Figure 1.

III. THE DATASET
Using the setup described in Section II, vibration data for unbalances of different sizes was recorded. By varying the level of unbalance, different levels of difficulty can be achieved, since smaller unbalances obviously influence the signals at the vibration sensors to a lesser extent. Several further requirements were taken into account: The dataset should be reproducible, relevant for industrial applications and it should represent a use case that is as realistic as possible. This requires the recording of vibration data for varying rotational speed, as an unbalance detector might have to work under varying conditions in some industrial applications. To ensure a high level of (re-)usability of the dataset, we provide tabular data in the csv-format.
In total, datasets for 4 different unbalance strengths were recorded as well as one dataset with the unbalance holder without additional weight (i.e. without unbalance). Each dataset is provided as a csv-file with five columns: V in The input voltage to the motor controller V in (in V), Measured RPM the rotation speed of the motor (in RPM; computed from speed measurements using the DT9837), Vibration 1 the signal from the first vibration sensor, Vibration 2 the signal from the second vibration sensor, and Vibration 3 the signal from the third vibration sensor. The sampling rate in each column amounts to 4096 values per second (the rotation speed has been upsampled accordingly).
In order to enable a comparable division into a development dataset and an evaluation dataset, separate measurements were taken for each unbalance strength, respectively. This separation can be recognized in the names of the csv-files, which are of the form "1D.csv": The digit describes the unbalance strength ("0" = no unbalance, "4" = strong unbalance), and the letter describes the intended use of the dataset ("D" = development or training, "E" = evaluation).
The unbalance on the measurement setup was completely dismantled and reassembled between the measurement of the development and the evaluation datasets to increase the significance of the evaluation of the algorithms to be trained on the data later on. For the development datasets, the motor voltage V in was increased from V start = 2.0 V to V end = 10.05 V in steps of ∆V = 0.05 V; see Fig. 3. For the evaluation datasets, the motor voltage was increased in steps of At each step the motor voltage value is kept constant for ∆t = 20 s. The voltage profiles were run through twice for each data record. The rotation speed of the motor was found to be approximately An overview of the parameters of the recorded datasets can be found in Table I. This includes the masses and radii for all the used unbalances. Since the absolute value of the centrifugal force F Cf as a function of the rotation speed ω can under a point mass approximation be expressed as  the product of the mass m and the radius r is a direct measure of the unbalance strength. In Table I there is also a column called Number of Samples for the development and the evaluation dataset. To calculate these values, the first 50,000 values from each dataset were removed (approx. 10 s) and the rest was then divided into windows, each corresponding to one second or 4096 values. The number of samples, therefore, equals the time range of the usable data of each measurement. When calculating prediction accuracies based on these samples, though, it has be taken into account that they are part of a continuous measurement and are therefore not completely independent from each other. Nevertheless, these accuracies are useful to compare the classification performance of different algorithms on the given datasets.
An overview of the amplitude progression at vibration sensor 1 over an entire measurement in the cases of no unbalance and the largest unbalance is shown in Figures 4(a) and 4(b). For each of the two cases an example curve for one second as well as the FFT transformation of a part of the measurement data is also depicted (Figure 4(c)-(f)).

A. Approach 1: Convolutional Neural Network on Raw Sensor Data
Convolutional Neural Networks (CNNs) are able to recognize patterns in data and to perform classification tasks based on these recognized patterns. An unbalance classification with CNNs, which receive the windowed data directly as input, is therefore promising. The advantage here is that no further data preprocessing is necessary and the effort involved in creating the algorithm is therefore comparatively low. Windowed samples from the data stream 'Vibration 1' were directly used as input. Figure 5 shows the CNN architecture used for the classification in this study. Since it was shown that an overparameterization of a neural network with regard to the number of training samples can have a positive effect on the overall performance [34], the depth of the network and thus the number of model parameters was varied. This was achieved by varying the number of convolutional blocks N conv , consisting of a convolutional layer, batch normalization, activation function and max pooling. After the convolution blocks, one fully-connected (FC) layer leads to the final output layer. Since only the task, whether or not an unbalance is present was used for classification, the output layer consists of one single node with a sigmoid activation.
To better monitor the training process, the development dataset was randomly divided into 90 % training data and 10 % test data. Based on the test data, a model checkpoint was initiated so that the model with the best result on the test data was always kept. Afterwards, all trained models were tested on the corresponding evaluation datasets of the same unbalance factors.
For a first attempt, the classification of whether an unbalance is present or not was trained using the data record without unbalance and only one single data record with unbalance each time. Afterwards, all trained models were tested on the corresponding evaluation datasets of the same unbalance factors. The resulting accuracies are shown in Figure 6(a).
Overall, a rather weak prediction accuracy can be observed in this classification task. It is striking that in particular the second smallest unbalance can hardly be distinguished from the not unbalanced case (dataset pair '0E' and '2E'). With a high prediction accuracy this is only possible for the largest unbalance (dataset pair '0E' and '4E'). With regard to the depth of the CNN, the best results are achieved with 4 and 2 convolutional blocks, with an average of 79.0 % and 82.2 % respectively.
In a further experiment, not only one unbalance strength at a time was used as training data, but all. Classifications were nevertheless made as to whether there was an unbalance or not. Therefore there is also one accuracy score describing the performance of the classification algorithm on this task. However, to gain insights into the distribution of correct and incorrect classifications, the resulting models were additionally evaluated in relation to the individual data records, resulting in one accuracy score per unbalance class (plotted in Figure 6(b)). With this classification task, a significantly better performance of the algorithms used can be observed. On the one hand, this is obviously due to the larger amount of training data available for each individual training. On the other hand, this variant also trains higher variability in the exact mounting of the unbalance. Since the unbalances have been completely disassembled between the measurement of the development and the evaluation datasets, minor changes in the vibration behavior of the entire system can be caused. As in the previous experiment, the best results are achieved with CNNs of 2 (94.0 %) and 4 (93.6 %) convolution blocks. With only one convolution block a deviating behavior is obtained: A high detection accuracy, even with small unbalances, is achieved by a reduced detection accuracy of the unbalanced case.
The same trained models were also evaluated as a function of the rotation speed (shown in Figure 6(c)). It can be seen that there are areas, for example around 1600 RPM, where all algorithms have a high prediction accuracy and areas in which this accuracy is low for all models (for example around 1100 RPM). In other areas, however, the prediction accuracy is widely spread (around 1500 RPM).

B. Approach 2: Fully-Connected Neural Network on FFTtransformed Data
For this approach, the FFT was calculated for each of the windows of one second or 4096 values of the first vibration sensor stream ('Vibration 1'). According to the Shannon-Nyquist sampling theorem, this results in 2048 physically meaningful Fourier coefficients for each window, which can be used for classification. Again, development dataset transformed in this way was randomly divided into 90 % training data and 10 % test data. Afterwards a robust scaling (quantile range interval (5,95)) was conducted based on the extent of the training dataset. Fully connected (FC) neural networks were then trained on the training data. An illustration of the used network architectures is shown in Figure 7. The input consisting of 2048 Fourier coefficients in each sample was followed by N hidden hidden and fully connected layers with LeakyReLU activation and the output layer. Neural networks of this type with zero (equivalent to logistic regression) to four hidden layers were trained using the respective training data. As described in approach 1 (Section IV-A), in the first experiment the dataset of the unbalance-free case and the datasets with unbalance were paired and the respective models were trained based on these datasets and evaluated on the corresponding dataset pairs from the evaluation data.
The resulting accuracies are shown in Figure 6(d). It is apparent that the trained models are only partially able to accurately conduct the classification between zero and the smaller unbalances. While the largest unbalance could be classified correctly in almost every case, the picture is inconsistent in the remaining cases. The data record '2E' can also be classified with a high accuracy, while this in turn works worse for the data record '3E'. A monotonically increasing prediction accuracy as a function of the unbalance strength was expected. One reason for the deviation observed here could be again effects caused by reassembling of the unbalance after each measurement. Additionally, there is a slight trend visible, that neural networks with one or two layers reach a better overall Fig. 6. Evaluation accuracies of the used classification approaches 1 (a-c), 2 (d-f) and 3 (g-i). In the first column (a,d,g), the results for models trained and tested on the task whether or not an unbalance exists and using pairs of the dataset without unbalance and one dataset of a single unbalance strength, is plotted. The results for models trained and tested using all measured unbalance strengths is shown in the second column (b,e,h). The models from the second column are additionally evaluated as a function of the rotation speed (third column, (c,f,i)). In the first two columns, the corresponding IDs of the datasets that were used for the evaluation are marked in red above the diagrams. performance in this task, possibly a better generalization could be achieved in these cases.
In the next experiment, again all datasets instead of pairs of datasets were used and classification was conducted, whether or not there was an unbalance at all. The results are depicted in Figure 6(e). The number of hidden FC layers was again varied between 0 and 4. Overall, an accuracy of 0.916 (zero hidden layers) to 0.986 (two hidden layers) was achieved on the evaluation dataset for the classification task. While the largest unbalance is recognized almost perfectly by all methods, there is no clear tendency for the other unbalance strengths, similar to the previous experiment. As with the CNN approach, the larger amount of training data also leads to better performance overall.
For the rotation speed dependent evaluation (Figure 6(f)), it can be seen that all models have a drop in prediction accuracy in the ranges around 1200 RPM and 1550 RPM. Outside these ranges, all algorithms except those with zero hidden layers achieve an accuracy of almost 100 %. One reason for the worse performance in the described ranges could be resonant oscillations of the measurement setup, resulting in a reduction of the signal-to-noise ratio of the signals caused by the unbalance.

C. Approach 3: Random Forest on Automatically Extracted Timeseries Features
In order to compare the generalization ability of all employed algorithms to a common baseline, and to find out to what extent a higher computational effort has an impact on a possibly improved prediction accuracy, classification was carried out using a minimum set of features. This small feature set consists of the mean of the 'Measured RPM' values, as well as the standard deviation and the kurtosis of the vibration values, which were calculated for each of the previously partitioned windows of the datasets. This feature calculation was carried out in two variants: First, standard deviation and kurtosis were only calculated for 'Vibration 1', resulting in a total of 3 features (including the mean of the 'Measured RPM' values). In the second variant, all three vibration sensors were used (7 features in total). Both variants shall be denoted to as 'minimal features'. A Random Forest model was then trained on these minimal features. As with the previous classification approaches, the classification training was conducted once with dataset pairs consisting of one unbalance strength and the unbalance-free case each and once with all existing unbalance strengths. The classification results of the evaluation are shown in the Figures 6(g)-(i). It can be seen that the highest unbalance can be detected almost perfectly by using only 3 features in both experiments. Using 7 features and trained on the whole dataset, even the dataset '3E' can be classified close to 100 % accuracy. With the smaller unbalances, on the other hand, there is a significant decrease in the prediction accuracy and also the unbalance-free case can only be detected to 82.2 % (3 features) or 94.6 % (7 features) in the second experiment ( Figure 6(h)). When looking at the rotation-speed-dependent evaluation, the high accuracy below 1200 RPM is particularly striking. In this range, the classification with the minimum set of features even achieves a significantly better result than with approach 1.
Besides the mentioned minimal features, the Python package tsfresh offers the possibility of computing a much wider range of features describing time series [35]. Using tsfresh (version 0.14.1), 748 features belonging to the class EfficientFCParameters() were extracted for 'Vibration 1' and afterwards used as input for a random forest algorithm. Since the classification task and algorithm remained the same, and only the number of input features changed, the prediction results on the evaluation dataset are depicted in the Figures 6(g)-(i), as well (green curve). In particular, a significant improvement in the detection rate for the smaller unbalances compared to the minimal features causes that, with a total prediction accuracy of 93.2 % when trained on all unbalance strengths and a mean prediction accuracy of 79.9 % when trained with the dataset pairs, a level similar to that of the CNNs in approach 1 (Section IV-A) is achieved overall.

D. Approach 4: Hidden Markov Model
One can obtain an outline of hidden markov models (HMMs) from the article [36]. Beyond speech recognition (e.g. in the Sphinx system [37], [38]), HMMs have also been used in biology (e.g. protein structure and genome research [39]), sports (e.g. recognition of sports activities [40]), and other use cases. In the field of condition monitoring, HMMs have e.g. been employed for the detection of defective roller bearings [41]. The latter paper has had a certain influence on the design of the unbalance detector, that is used in the present section: A possible approach to determine the unbalance state using a hidden markov model (HMM) is shown in Figure 8: The input signal (4096 consecutive values from 'Vibration 1' were used) is cut into (possibly overlapping) snippets of a fixed length. For each snippet, the mel-frequency cepstral components (MFCCs) are computed as features, which are then input into a HMM that is trained to recognize data without unbalance. To facilitate the interpretation of the HMM output, logistic regression is used to decide whether a given input signal results from a measurement with or without unbalance. The scalers in Figure 8 simplify the training process.  Because the MFCC features are sensitive to variations in the rotation speed, it was decided to train several models for different speeds. The training data was therefore assembled in the following way: One-second samples of the 'Vibration 1' signal (from the '0D' and '3D' datasets) were selected such that the speed ('Measured RPM') is always within a certain interval. The training data is then randomly split into three sets. One set is used to train the first scaler and the HMM (using data from '0D' only). The second set is used to train the second scaler and the logistic regression to recognize measurements with unbalance. The third set is used to determine hyperparameters (number of MFCC features, number of HMM states, snippet length and overlap), that maximize the balanced accuracy.
During development of the HMM approach, it was noticed that the MFCC features within one-second samples of the measurement without unbalance appear to be relatively stationary. And the hyperparameter optimization often results in the use of only one (!) HMM state. The problem at hand might therefore be inadequate for HMMs (which are usually applied to instationary processes). Figure 9 shows the results of the HMM approach to unbalance detection. It can be seen, that the balanced accuracy is in the range • 0.56-0.93, mean = 0.65 (for the union of '0E' and '1E'), • 0.57-1.00, mean = 0.80 (for the union of '0E' and '2E'), • 0.74-1.00, mean = 0.95 (for the union of '0E' and '3E'), and • 0.74-1.00, mean = 0.95 (for the union of '0E' and '4E').

V. SUMMARY AND OUTLOOK
For this study, a dataset with vibration data for the classification of unbalance on a rotating shaft with variable speed and unbalance strength was created. Various approaches to solve the associated classification task were tested. The largest unbalance could be detected by all algorithms with almost perfect prediction accuracy, even if only 3 characteristic values per sample were used for the classification. With the smaller unbalances, on the other hand, wider variations between the different approaches were found. The best way to classify the dataset was to use an FC network with two hidden layers, which received the scaled FFT-transformed vibration data as input. Measured on the entire evaluation dataset, 98.6 % of the cases could be classified correctly. In addition, the examined models showed a very different behavior regarding the dependence on the speed. In future studies, this behavior could be exploited by building ensembles of different models to further increase the prediction accuracy. Strengths and weaknesses of individual models in the different speed ranges would then at least partially compensate each other. Moreover, for the further improvement of the models as well as the understanding of the classifications, for example in a productive company, efforts with regard to enabling a traceability and explainability of the models used are necessary.