MACHINE LEARNING MODEL FOR MECHANICAL ENGG.APPLICATIONS (ANN  ALGORITHM)

MACHINE LEARNING MODEL FOR MECHANICAL ENGG.APPLICATIONS (ANN ALGORITHM)

Shristi Nadakatti Pooja Nadakatti A. Mirzazadeh Uday Kumar Aditya Parida Vinit Parida Dr. Andrews A

Artificial intelligence (AI) is a broad field encompassing any technique that enables machines to mimic human cognitive functions. This includes everything from simple rule-based systems to complex algorithms capable of learning and adapting.

?Machine learning (ML) is a powerful subfield of AI that allows computers to learn from data without explicit programming. By analyzing massive datasets, ML algorithms can identify patterns, make predictions, and improve their performance over time. This makes them invaluable for a wide range of applications, from recommendation systems suggesting products you might like to medical diagnosis tools that can detect diseases with high accuracy.

?

Introduction to Artificial Neural Networks (ANN)

Artificial Neural Networks (ANN) are computational models inspired by the human brain's network of neurons. ANNs consist of interconnected nodes or neurons, organized in layers: an input layer, one or more hidden layers, and an output layer. Each connection has an associated weight, which is adjusted during the training process to minimize the error in predictions. This process of adjustment is known as learning, and it enables the network to recognize patterns, classify data, and make predictions based on the input data.

ANNs are widely used in various fields due to their ability to model complex, non-linear relationships. They excel in tasks such as image and speech recognition, natural language processing, and time-series forecasting. By learning from large datasets, ANNs can generalize and make accurate predictions on unseen data, making them powerful tools for solving real-world problems.

[1]
[2]
[3]
[4]

ANN Applications in Mechanical Engineering

In mechanical engineering, ANNs have found numerous applications, ranging from predictive maintenance and fault diagnosis to optimization and control of mechanical systems. One of the significant applications is in condition monitoring and predictive maintenance of machinery. By analyzing sensor data, such as temperature, vibration, and pressure, ANNs can predict the health and performance of mechanical components, enabling timely maintenance and reducing downtime.

Another application is in the design and optimization of mechanical components. ANNs can model complex relationships between design variables and performance metrics, allowing engineers to explore a vast design space efficiently. This capability is particularly useful in areas like material selection, structural analysis, and thermal management. It is now being extensively used in robotics and automation, estimation of? material properties, etc. For tribological predictions about friction, wear and lubrication, ANN applications are used. One of the most promising are of ANN? applications is Mechanical? Fault Diagnosis and condition monitoring. ANN is still in developing stage and needs greater study and research to attain wider acceptance.

?

ANN Applications in MATLAB

MATLAB is a powerful platform for implementing ANNs due to its extensive libraries and user-friendly environment. The Neural Network Toolbox in MATLAB provides tools for designing, training, and simulating neural networks. Users can create various types of neural networks, such as feedforward, recurrent, and convolutional networks, and train them using algorithms like backpropagation and Levenberg-Marquardt.

Using MATLAB, engineers can preprocess data, design network architectures, train models, and visualize the results seamlessly. The platform also supports integration with other toolboxes, enabling users to perform comprehensive analysis and validation. In mechanical engineering, MATLAB's capabilities are leveraged to develop predictive models for condition monitoring, optimize design processes, and simulate mechanical systems, enhancing the efficiency and reliability of engineering solutions.

The Mathworks Matlab Neural Network toolbox is utilized to build and train a suitable neural network. The nonlinear autoregressive network with exogenous inputs (NARX) neural network structure is employed.? Using MATLAB?? with Deep Learning Toolbox? and Statistics and Machine Learning Toolbox?, one can create deep and shallow neural networks for applications such as computer vision and automated driving.

With just a few lines of code, one can create neural networks in MATLAB without being an expert. The engineer ?can get started quickly, train and visualize neural network models, and integrate neural networks into his/her existing system and deploy them to servers, enterprise systems, clusters, clouds, and embedded devices. [5]

Developing an ANN Model for Bearing Condition Prediction using MATLAB ?CITATION Mat24 l 1033 [6]

In the present article, let us explore the development of an Artificial Neural Network (ANN) model to predict the condition of bearings using MATLAB. The model utilizes two key datasets: a training dataset and a testing dataset. The training dataset with file name as “BearingRPMVsTemp.csv”, consists of four columns:1) Bearing Age (in days), 2) Bearing RPM, 3) Bearing Temperature (in °C), and 4) Bearing Condition (categorized as Good, Average, Critical, or Dangerous). This dataset is used to train the ANN model to recognize patterns and relationships between these input features and the bearing conditions. The testing dataset with file name as, “TestDataBearingRPMVsTemp.xlsx”, contains three columns namely: 1) Bearing Age (in days), 2) Bearing RPM, 3) Bearing Temperature (in °C), which will be used to predict the bearing conditions using the trained ANN model.

The objective of this model is to accurately predict the condition of bearings based on the given input features, enabling timely maintenance and reducing the risk of unexpected failures. The next section will guide you through the process of developing and training the ANN model using the training dataset. We will then use this trained model to predict the bearing conditions for the test data.

A similar logic could be applied to predict outcomes of similar input and output data sets, like failure analysis, wear analysis, flow analysis, etc, by suitably altering the training and testing data sets.

Developing and training the ANN Model

To begin, we need to preprocess our training dataset to ensure the ANN model receives clean and well-structured data. This involves mapping the bearing condition categories to numerical values for the model to interpret them effectively. We assign numerical labels as follows: Good = 4, Average = 3, Critical = 2, and Dangerous = 1. This conversion allows the model to learn from the data efficiently.

Next, we normalize the numerical features—Bearing Age, Bearing RPM, and Bearing Temperature—to bring all values into a comparable range. This step is crucial because it prevents any single feature from disproportionately influencing the model. Normalization is performed by rescaling the values to a range between 0 and 1 using the formula: normalized?value=original?value?min?valuemax?value?min?value\text{normalized value} = \frac{\text{original value} - \text{min value}}{\text{max value} - \text{min value}}normalized?value=max?value?min?valueoriginal?value?min?value.

Once the data is pre-processed, we can train the ANN model. The architecture of our ANN consists of an input layer, two hidden layers, and an output layer. The hidden layers have varying numbers of neurons to capture complex patterns in the data. The model is trained using a portion of the dataset, typically divided into training, validation, and test sets. During training, the model adjusts its weights based on the error between predicted and actual bearing conditions, minimizing this error over several iterations.

Code for Section 1: Load and Prepare Training Data

?% Section 1: Load and Prepare Training Data

?

% Load the training data from CSV file

dataTable = readtable('BearingRPMVsTemp.csv');

?

% Display the first few rows of the loaded data

disp('Training data loaded:');

disp(dataTable(1:min(end, 5), :));

?

% Define a mapping for bearing conditions

conditionMapping = containers.Map({'Good', 'Average', 'Critical', 'Dangerous'}, [4, 3, 2, 1]);

?

% Add a new column with numeric values for bearing conditions

dataTable.BearingConditionNumeric = zeros(size(dataTable, 1), 1);

?

% Map each string condition to its corresponding numeric value

for i = 1:size(dataTable, 1)

??? conditionStr = dataTable.BearingCondition{i};

??? if isKey(conditionMapping, conditionStr)

??????? dataTable.BearingConditionNumeric(i) = conditionMapping(conditionStr);

??? else

??????? error(['Unrecognized condition at row ', num2str(i), ': ', conditionStr]);

??? end

end

?

% Display the updated table with numeric conditions

disp('Training data with numeric conditions:');

disp(dataTable(1:min(end, 5), :));

?

% Check for any NaN values in the data

if any(isnan(dataTable{:, 1}), 'all')

??? error('NaN values found in the original data.');

else

??? disp('No NaN values found in the original data.');

end

?

% Remove the original string-based BearingCondition column

dataTable.BearingCondition = [];

disp('Updated training data after removing string condition column:');

disp(dataTable(1:min(end, 5), :));

?

% Save the processed training data

save('ProcessedTrainingData.mat', 'dataTable');

?

Code Section 2: Normalizing the Training Data

% Section 2: Normalize the Training Data

?

% Load the processed training data

load('ProcessedTrainingData.mat', 'dataTable');

?

% Extract features (first three columns) and target (last column)

x = dataTable{:, 1:3};? % Features: Bearing Age, Bearing RPM, Bearing Temp

y = dataTable{:, 4};??? % Target: Bearing Condition Numeric

?

% Initialize arrays to store min and max values for normalization

x_min = min(x);

x_max = max(x);

?

% Normalize each feature to the range [0, 1]

x2 = zeros(size(x));

for i = 1:3

??? x2(:, i) = (x(:, i) - x_min(i)) / (x_max(i) - x_min(i));

end

?

% Display histograms of the normalized features

figure;

subplot(3, 1, 1);

histogram(x2(:, 1), 10);

title('Normalized Feature 1 (Bearing Age)');

?

subplot(3, 1, 2);

histogram(x2(:, 2), 10);

title('Normalized Feature 2 (Bearing RPM)');

?

subplot(3, 1, 3);

histogram(x2(:, 3), 10);

title('Normalized Feature 3 (Bearing Temp)');

?

% Save the normalized training data and normalization parameters

save('NormalizedTrainingData.mat', 'x2', 'y', 'x_min', 'x_max');

disp('Training data normalized and saved.');

?

Screenshots of Section 1 and 2:

Output from Section 1


Output from Section 2

Training the Model

The training process involves feeding the normalized training data into the ANN and iteratively adjusting the model's parameters. We use a backpropagation algorithm to minimize the error, which involves calculating the gradient of the error with respect to the model's weights and updating the weights in the opposite direction of the gradient. This optimization process continues until the model achieves satisfactory performance on the validation set.

To evaluate the model's performance, we use metrics such as Root Mean Squared Error (RMSE) for both training and validation sets. These metrics help us understand how well the model is learning and generalizing to unseen data. Once the model is trained and evaluated, we visualize the results using plots that compare the predicted bearing conditions with the actual conditions.

In the next section, we will apply the trained ANN model to the testing dataset to predict the bearing conditions. This step demonstrates the practical application of our model and its effectiveness in real-world scenarios.

Code for Section 3:

% Section 3: Train the Neural Network

?

% Load the normalized training data

load('NormalizedTrainingData.mat', 'x2', 'y');

?

% Transpose the data to match the network's input format

xt = x2';

yt = y';

?

% Define the architecture of the neural network

hiddenLayerSize = [10, 5];? % Example: Two hidden layers with 10 and 5 neurons

net = fitnet(hiddenLayerSize);

?

% Set up the division of data for training, validation, and testing

net.divideParam.trainRatio = 70/100;

net.divideParam.valRatio = 30/100;

net.divideParam.testRatio = 0/100;

?

% Train the neural network

[net, tr] = train(net, xt, yt);

?

% Save the trained neural network

save('TrainedBearingModel.mat', 'net');

disp('Neural network trained and saved.');

?

Screenshot? of Section 3: Train the Neural Network

Output of Section 3:


Applying the Trained ANN Model to the Testing Dataset

Once our ANN model is trained and validated, we move on to applying it to the testing dataset. This step will help us assess the model's performance on new, unseen data, which is critical for understanding its real-world applicability.

Preparing the Testing Data

Similar to the training data, we need to preprocess the testing dataset before feeding it into the model. This involves normalizing the testing data using the same min-max values derived from the training dataset. Consistency in preprocessing steps is crucial to ensure that the model's predictions are reliable.

By following these steps, we ensure that the testing data is accurately processed, and predictions are made and displayed in an interpretable format. In the next section, we will evaluate the performance of our ANN model and discuss the results.

In this section, we load the test data, normalize it using the same parameters as the training data, and prepare it for prediction. Normalizing the test data ensures that it is on the same scale as the training data, which is crucial for the ANN to make accurate predictions.

Explanation

After preparing the training data and training the ANN model, we need to apply the same normalization process to the test data. This step ensures that the features of the test data are on the same scale as the training data, which is critical for the ANN to produce accurate predictions.

1.??? Loading Test Data: We load the test data from an Excel file, which contains the same features (bearing age, RPM, and temperature) but lacks the condition labels.

2.??? Extracting Features: We extract the first three columns from the test data, which correspond to the bearing age, RPM, and temperature.

3.??? Loading Normalization Parameters: We load the normalization parameters (min and max values) that were computed during the training phase.

4.??? Normalizing Test Data: We normalize the test data using these parameters, ensuring that the test data is on the same scale as the training data.

?

Making Predictions

With the normalized testing data ready, we can now use the trained ANN model to predict the bearing conditions. The output from the model will be in numerical format, which we will then map back to the original string labels for better interpretability.

?

?

% Section 4: Validate the Neural Network Performance

% Section 5: Load and Normalize Test Data

?

% Load the trained neural network and normalized training data

load('TrainedBearingModel.mat', 'net');

load('NormalizedTrainingData.mat', 'xt', 'yt');

?

% Extract the indices of the training and validation sets

trainInd = tr.trainInd;

valInd = tr.valInd;

?

% Compute the predictions on the training set

yTrainPred = net(xt(:, trainInd));

yTrainTrue = yt(trainInd);

?

% Compute the predictions on the validation set

yValPred = net(xt(:, valInd));

yValTrue = yt(valInd);

?

% Convert predictions to numeric condition labels

yTrainPredRounded = round(yTrainPred);

yValPredRounded = round(yValPred);

?

% Plot the confusion matrix for the validation set

figure;

plotconfusion(ind2vec(yValTrue), ind2vec(yValPredRounded));

title('Confusion Matrix for Validation Set');

?

% Calculate the performance metrics (RMSE)

rmse_train = sqrt(mean((yTrainPred - yTrainTrue).^2));

rmse_val = sqrt(mean((yValPred - yValTrue).^2));

?

disp(['Training RMSE: ', num2str(rmse_train)]);

disp(['Validation RMSE: ', num2str(rmse_val)]);

?

Screenshots of Section 4

Output from Section 4:

Confusion Matrix

A confusion matrix is a valuable tool for visualizing the performance of our classification model. It shows the number of correct and incorrect predictions for each class, allowing us to see where the model performs well and where it may struggle.

Confusion Matrix Screenshot

Section 6: Predict Bearing Conditions for the Test Data :

After applying the trained ANN model to the testing dataset and obtaining predictions, it is crucial to evaluate the model's performance. This evaluation helps us understand how well the model generalizes to new, unseen data and identifies any potential areas for improvement.

Evaluating the Model

To assess the performance of our ANN model, we use several evaluation metrics. These metrics provide a comprehensive view of the model's accuracy, precision, and overall effectiveness in predicting bearing conditions.

Analyzing the Results

The confusion matrix provides a clear picture of the model's performance across different bearing conditions. By analyzing this matrix, we can identify:

·???????? The number of correct predictions for each condition.

·???????? The number of misclassifications and which conditions are often confused.

·???????? The overall accuracy of the model.

Other Evaluation Metrics

In addition to the confusion matrix, other metrics such as precision, recall, and F1-score can provide further insights into the model's performance. These metrics help us understand the balance between correctly identifying positive cases and avoiding false positives.

?

Code for Section 6:

?

Code for Section 6:

% Section 6: Predict Bearing Conditions for Test Data

% Load the processed training data

load('ProcessedTrainingData.mat', 'dataTable');

?

% Extract the relevant data from the training table

xTrain = dataTable{:, 1:3};? % First three columns are numeric

yTrain = dataTable.BearingConditionNumeric;? % Last column is the numeric label

?

% Normalize the training features using the same approach

x_min = min(xTrain, [], 1);

x_max = max(xTrain, [], 1);

xTrainNormalized = (xTrain - x_min) ./ (x_max - x_min);

?

% Train the neural network with the optimal hidden layer size found earlier

hiddenLayerSize = 5;? % Example size, adjust based on your optimal findings

net = fitnet(hiddenLayerSize);

?

% Set up the division of data for training and validation

net.divideParam.trainRatio = 70/100;

net.divideParam.valRatio = 30/100;

net.divideParam.testRatio = 0/100;

?

% Train the network

[net, tr] = train(net, xTrainNormalized', yTrain');

?

% Load the test data (make sure this file is in your MATLAB path)

testDataTable = readtable('TestDataBearingRPMVsTemp.xlsx');

?

% Extract the numeric columns from the test data

xTest = testDataTable{:, 1:3};? % Ensure these match your test data columns

?

% Normalize the test features using the same min-max from training

xTestNormalized = (xTest - x_min) ./ (x_max - x_min);

?

% Predict the conditions for the test data

yTestPred = net(xTestNormalized')';

yTestPredRounded = round(yTestPred);? % Round the predictions to nearest integers

?

% Ensure the predicted labels are within the expected range

yTestPredRounded(yTestPredRounded < 1) = 1;? % Clamp to minimum

yTestPredRounded(yTestPredRounded > 4) = 4;? % Clamp to maximum

?

% Define the reverse mapping from numeric to string labels

reverseConditionMapping = containers.Map([4, 3, 2, 1], {'Good', 'Average', 'Critical', 'Dangerous'});

?

% Convert numeric predictions back to string labels

yTestPredLabels = arrayfun(@(x) reverseConditionMapping(x), yTestPredRounded, 'UniformOutput', false);

?

% Check the structure of yTestPredRounded and yTestPredLabels

disp('yTestPredRounded (numeric labels):');

disp(yTestPredRounded);

?

disp('yTestPredLabels (string labels):');

disp(yTestPredLabels);

?

% Convert yTestPredRounded to a column vector if it isn't already

if size(yTestPredRounded, 2) > 1

??? yTestPredRounded = yTestPredRounded';

end

?

% Convert yTestPredLabels to a cell array with a single column

yTestPredLabels = yTestPredLabels(:);

?

% Combine the original test data with predictions

% Ensure all variables are aligned as columns

testDataWithPredictions = [testDataTable, table(yTestPredRounded, yTestPredLabels)];

?

% Display the updated table with predictions

disp('Updated test data with predictions:');

disp(testDataWithPredictions);

?

% Save the results into an Excel file for review

writetable(testDataWithPredictions, 'PredictedTestDataBearingRPMVsTemp.xlsx', 'Sheet', 1);

Screenshots of Section 6

Outcome of Section 6:? Predicted Bearing Condition !!!!

That’s it!!!!?? As can be seen from the last screenshot, the bearing condition is predicted by the ANN model for the given set of Test Data.

?These results correlate well with training data set.

Similar exercise in coding could be done for other problems of Mechanical Engineering where one needs to predict the outcomes based on some previously? known data conditions and their outcomes.

By thoroughly evaluating our ANN model, we can gain confidence in its ability to predict bearing conditions accurately. The insights gained from these evaluations are crucial for making informed decisions about model deployment and potential areas for further refinement.

Section 7: Conclusion and Future Work

Summary

In this project, we successfully developed an Artificial Neural Network (ANN) model to predict bearing conditions based on key parameters such as bearing age, RPM, and temperature. The process involved several critical steps:

1.??? Data Preparation: We began by loading and preprocessing the training data, including converting categorical bearing conditions into numerical labels.

2.??? Feature Normalization: We normalized the features to ensure the data was suitable for training the ANN model.

3.??? Model Training: We designed and trained the ANN model, carefully adjusting hyper-parameters to optimize performance.

4.??? Prediction: We used the trained model to predict bearing conditions on a test dataset, converting the numerical predictions back to categorical labels for clarity.

5.??? Evaluation: We evaluated the model's performance using metrics like the confusion matrix, which provided valuable insights into the model's accuracy and areas for improvement.

Throughout this process, we leveraged MATLAB's powerful tools and functions to streamline data handling, model training, and performance evaluation.

Potential Applications

The ANN-based bearing condition prediction model has several practical applications in the field of mechanical engineering and maintenance:

·???????? Predictive Maintenance: By accurately predicting bearing conditions, maintenance schedules can be optimized to prevent unexpected failures, reducing downtime and maintenance costs.

·???????? Quality Control: In manufacturing, this model can be used to monitor the condition of bearings in real-time, ensuring high-quality standards are maintained.

·???????? Research and Development: The model can assist in the development of new bearing materials and designs by providing insights into how different parameters affect bearing longevity and performance.

Future Work

While the current model demonstrates promising results, there are several areas for future improvement:

1.??? Enhanced Data Collection: Incorporating additional features such as vibration data or lubricant properties could further improve the model's accuracy.

2.??? Advanced ANN Architectures: Experimenting with deeper or more complex neural network architectures could yield better performance.

3.??? Real-time Implementation: Developing a real-time implementation of the model for live monitoring and prediction in industrial environments.

4.??? Cross-Validation: Implementing more robust cross-validation techniques to ensure the model generalizes well to new data.

Final Thoughts

The development and application of ANN models in predicting bearing conditions showcase the power of machine learning in solving real-world engineering problems. By leveraging MATLAB's capabilities, we have created a model that not only performs well but also offers practical benefits in maintenance and quality control. Future enhancements and continued research in this area will further solidify the role of ANN in mechanical engineering and predictive maintenance.


Acknowledgement:

YouTube video lecture uploaded by Mathieu Bauchy. Details of the video are mentioned in the Reference Section.

Reference


[1] civildaily, “What are Artificial Neural Networks (ANN)?,” [Online].

[2] GreeksforGeeks, “Artificial Neural Networks and its Applications,” [Online].

[3] F. L. P. f. B, “Artificial Neural Network Tutorial,” [Online].

[4] F. L. P. F. B. Future, “Artificial Neural Network Tutorial,” [Online]. Available: https://www.javatpoint.com/artificial-neural-network.

[5] MathWorks, “How Do You Create a Neural Network with MATLAB?,” [Online]. Available: https://in.mathworks.com/discovery/neural-network.html.

[6] M. Bauchy, “Step-by-Step Beginners Tutorial: How to Train an Artificial Neural Network with Matlab,” [Online]. Available: https://www.youtube.com/@MBauchy. [Accessed 09 07 2024].

?


要查看或添加评论,请登录

Dr.Nadakatti Mahantesh的更多文章

社区洞察

其他会员也浏览了