Predicting Corrosion Behaviour of Magnesium Alloy Using Machine Learning Approaches
Abstract
1. Introduction
2. Construction of a Literature-Based Dataset and Machine Learning Modelling Using the PyCaret AutoML
2.1. Data Collection Methodology
2.2. Dataset Variables and Their Definitions
2.2.1. Alloy Composition
2.2.2. Processing Conditions
2.2.3. Testing Parameters
2.2.4. Target Variable
2.3. Data Preprocessing for Machine Learning Analysis
3. Literature-Based Dataset and Machine Learning Results and Discussions
3.1. Data Analysis
3.2. Hyperparameter Optimization
3.3. Evaluation of Selected Regression Models
3.3.1. Comparison Tables
3.3.2. Distribution of Real and Predicted Values
3.4. Sensitivity Analysis in Machine Learning Models
4. Conclusions
Author Contributions
Funding
Data Availability Statement
Acknowledgments
Conflicts of Interest
References
- Bai, J.; Yang, Y.; Wen, C.; Chen, J.; Zhou, G.; Jiang, B.; Peng, X.; Pan, F. Applications of Magnesium Alloys for Aerospace: A Review. J. Magnes. Alloys 2023, 11, 3609–3619. [Google Scholar] [CrossRef]
- Turan, M.E.; Sun, Y.; Akgul, Y. Mechanical, Tribological and Corrosion Properties of Fullerene Reinforced Magnesium Matrix Composites Fabricated by Semi Powder Metallurgy. J. Alloys Compd. 2018, 740, 1149–1158. [Google Scholar] [CrossRef]
- Abdulgadir, M.M.; Demir, B.; Turan, M.E. Hybrid Reinforced Magnesium Matrix Composites (Mg/Sic/GNPs): Drilling Investigation. Metals 2018, 8, 215. [Google Scholar] [CrossRef]
- Zengin, H.; Turen, Y.; Turan, M.E. Tensile and Wear Properties of As-Cast and as-Extruded ZK60 Magnesium Alloys Containing Minor Nd Additions. Mater. Res. Express 2019, 6, 086528. [Google Scholar] [CrossRef]
- Atrens, A.; Song, G.-L.; Liu, M.; Shi, Z.; Cao, F.; Dargusch, M.S. Review of Recent Developments in the Field of Magnesium Corrosion. Adv. Eng. Mater. 2015, 17, 400–453. [Google Scholar] [CrossRef]
- Zengin, H.; Ari, S.; Turan, M.E.; Hassel, A.W. Evolution of Microstructure, Mechanical Properties, and Corrosion Resistance of Mg–2.2 Gd–2.2 Zn–0.2 Ca (Wt%) Alloy by Extrusion at Various Temperatures. Materials 2023, 16, 3075. [Google Scholar] [CrossRef]
- Praveen, T.S.; Padmanaban, R.; Vignesh, R.V.; Baghad, A. Investigations on the Corrosion Characteristics of Additive Manufactured Mg–Ag Alloy in Simulated Body Fluids for Biodegradable Implants. Prog. Addit. Manuf. 2024, 10, 1281–1292. [Google Scholar] [CrossRef]
- Gong, C.; Yan, X.; He, X.; Su, Q.; Liu, B.; Chen, F.; Fang, D. Influence of Homogenization Treatment on Corrosion Behavior and Discharge Performance of the Mg–2Zn–1Ca Anodes for Primary Mg-Air Batteries. Mater. Chem. Phys. 2022, 280, 125802. [Google Scholar] [CrossRef]
- Li, B.; Duan, Y.; Zheng, S.; Li, M.; Peng, M.; Qi, H. Microstructural Homogeneity, Texture and Corrosion Properties of RE-Doped 55Mg-35Pb-9.2Al-0.8B Alloy Fabricated via Equal Channel Angular Pressing (ECAP). J. Alloys Compd. 2023, 966, 171607. [Google Scholar] [CrossRef]
- Bai, R.; Feng, Y.; Li, J. Effect of Extrusion Temperature on the Microstructure, Mechanical Properties, and In Vitro Corrosion Behavior of a Biodegradable Mg-Zn-Ca-Mn-Sn Alloy. J. Mater. Eng. Perform. 2024, 34, 10448–10459. [Google Scholar] [CrossRef]
- Huang, S.-J.; Wang, C.-F.; Subramani, M.; Fan, F.-Y. Effect of ECAP on Microstructure, Mechanical Properties, Corrosion Behavior, and Biocompatibility of Mg-Ca Alloy Composite. J. Compos. Sci. 2023, 7, 292. [Google Scholar] [CrossRef]
- Zerankeshi, M.M.; Alizadeh, R.; Gerashi, E.; Asadollahi, M.; Langdon, T.G. Effects of Heat Treatment on the Corrosion Behavior and Mechanical Properties of Biodegradable Mg Alloys. J. Magnes. Alloys 2022, 10, 1737–1785. [Google Scholar] [CrossRef]
- Li, D.-W.; Wang, H.-Y.; Wei, D.-S.; Zhao, Z.-X.; Liu, Y. Effects of Deformation Texture and Grain Size on Corrosion Behavior of Mg–3Al–1Zn Alloy Sheets. ACS Omega 2020, 5, 1448–1456. [Google Scholar] [CrossRef] [PubMed]
- Guo, Y.; Sun, M.; Zhang, W.; Wang, L. Machine Learning in Enhancing Corrosion Resistance of Magnesium Alloys: A Comprehensive Review. Metals 2023, 13, 1790. [Google Scholar] [CrossRef]
- Ghorbani, M.; Boley, M.; Nakashima, P.N.H.; Birbilis, N. A Machine Learning Approach for Accelerated Design of Magnesium Alloys. Part B: Regression and Property Prediction. J. Magnes. Alloys 2023, 11, 4197–4205. [Google Scholar] [CrossRef]
- Moses, A.; Chen, D.; Wan, P.; Wang, S. Prediction of Electrochemical Corrosion Behavior of Magnesium Alloy Using Machine Learning Methods. Mater. Today Commun. 2023, 37, 107285. [Google Scholar] [CrossRef]
- GitHub—Pycaret/Pycaret: An Open-Source, Low-Code Machine Learning Library in Python. Available online: https://github.com/pycaret/pycaret (accessed on 20 September 2025).
- Samiei, S.; Dini, G.; Ebrahimian-Hosseinabadi, M. Correlation Between Microstructure, Mechanical Properties, and Corrosion Characteristics of AZ31 Mg Alloy Processed by Accumulative Roll Bonding Process. Met. Mater. Int. 2023, 29, 192–203. [Google Scholar] [CrossRef]
- Sadeghi, A.; Hasanpur, E.; Bahmani, A.; Shin, K.S. Corrosion Behaviour of AZ31 Magnesium Alloy Containing Various Levels of Strontium. Corros. Sci. 2018, 141, 117–126. [Google Scholar] [CrossRef]
- Chaudry, U.M.; Farooq, A.; bin Tayyab, K.; Malik, A.; Kamran, M.; Kim, J.-G.; Li, C.; Hamad, K.; Jun, T.-S. Corrosion Behavior of AZ31 Magnesium Alloy with Calcium Addition. Corros. Sci. 2022, 199, 110205. [Google Scholar] [CrossRef]
- Zohdy, K.M.; El-Sherif, R.M.; El-Shamy, A.M. Effect of pH Fluctuations on the Biodegradability of Nanocomposite Mg-Alloy in Simulated Bodily Fluids. Chem. Pap. 2023, 77, 1317–1337. [Google Scholar] [CrossRef]
- Rogachev, S.O.; Bazhenov, V.E.; Bautin, V.A.; Li, A.V.; Plegunova, S.V.; Ten, D.V.; Yushchuk, V.V.; Komissarov, A.A.; Shin, K.S. Influence of Hot Rolling on Microstructure, Corrosion and Mechanical Properties of Mg–Zn–Mn–Ca Alloy. Metals 2024, 14, 1249. [Google Scholar] [CrossRef]
- Pourhasan, N.; Sabbaghian, M.; Pishbin, F.; Mahmudi, R. Enhanced Corrosion Behavior and SCC Resistance of a Cast Mg–0.4 Zr Alloy after Hot Extrusion. J. Mater. Res. Technol. 2025, 39, 585–596. [Google Scholar] [CrossRef]
- Abdelfattah, K.B.; Abbas, M.A.; El-Garaihy, W.H.; Mohamed, A.M.; Salem, H.G. Corrosion and Degradation Behavior of MCSTE-Processed AZ31 Magnesium Alloy. Sci. Rep. 2025, 15, 4072. [Google Scholar] [CrossRef] [PubMed]
- Ma, Y.; Xiong, H.; Chen, B. Effect of Heat Treatment on Microstructure and Corrosion Behavior of Mg-5Al-1Zn-1Sn Magnesium Alloy. Corros. Sci. 2021, 191, 109759. [Google Scholar] [CrossRef]
- Liang, M.; Liu, H.; Wu, C.; Li, Y.; Guo, Z.; Murugadoss, V. Effects of Rare Earth Neodymium (Nd) and Heat Treatment on Anti-Corrosion Behaviors of the AZ80 Magnesium Alloy. Adv. Compos. Hybrid Mater. 2022, 5, 1460–1476. [Google Scholar] [CrossRef]
- Dargusch, M.S.; Shi, Z.; Zhu, H.; Atrens, A.; Song, G.-L. Microstructure Modification and Corrosion Resistance Enhancement of Die-Cast Mg-Al-Re Alloy by Sr Alloying. J. Magnes. Alloys 2021, 9, 950–963. [Google Scholar] [CrossRef]
- Bazhenov, V.E.; Li, A.V.; Komissarov, A.A.; Koltygin, A.V.; Tavolzhanskii, S.A.; Bautin, V.A.; Voropaeva, O.O.; Mukhametshina, A.M.; Tokar, A.A. Microstructure and Mechanical and Corrosion Properties of Hot-Extruded Mg–Zn–Ca–(Mn) Biodegradable Alloys. J. Magnes. Alloys 2021, 9, 1428–1442. [Google Scholar] [CrossRef]
- Zhang, M.; Deng, W.-L.; Yang, X.-N.; Wang, Y.-K.; Zhang, X.-Y.; Hang, R.-Q.; Deng, K.-K.; Huang, X.-B. In Vitro Biodegradability of Mg–2Gd–xZn Alloys with Different Zn Contents and Solution Treatments. Rare Met. 2019, 38, 620–628. [Google Scholar] [CrossRef]
- Yavuzyegit, B.; Karali, A.; De Mori, A.; Smith, N.; Usov, S.; Shashkov, P.; Bonithon, R.; Blunn, G. Evaluation of Corrosion Performance of AZ31 Mg Alloy in Physiological and Highly Corrosive Solutions. ACS Appl. Bio Mater. 2024, 7, 1735–1747. [Google Scholar] [CrossRef]
- Feliu, S., Jr.; Llorente, I. Corrosion Product Layers on Magnesium Alloys AZ31 and AZ61: Surface Chemistry and Protective Ability. Appl. Surf. Sci. 2015, 347, 736–746. [Google Scholar] [CrossRef]
- Rogachev, S.O.; Bazhenov, V.E.; Komissarov, A.A.; Li, A.V.; Munzaferova, N.E.; Plegunova, S.V.; Ten, D.V. Microstructure, Mechanical, and Corrosion Properties of Mg-Zn-Ga Alloy after Hot Rolling. J. Mater. Eng. Perform. 2025, 34, 3970–3978. [Google Scholar] [CrossRef]
- Liu, J.; Han, E.-H.; Song, Y.; Shan, D. Effect of Twins on the Corrosion Behavior of Mg–5Y–7Gd–1Nd–0.5 Zr Mg Alloy. J. Alloys Compd. 2018, 757, 356–363. [Google Scholar] [CrossRef]
- Whig, P.; Gupta, K.; Jiwani, N.; Jupalle, H.; Kouser, S.; Alam, N. A Novel Method for Diabetes Classification and Prediction with Pycaret. Microsyst. Technol. 2023, 29, 1479–1487. [Google Scholar] [CrossRef]
- Pillay, N.; Qu, R. (Eds.) Automated Design of Machine Learning and Search Algorithms; Natural Computing Series; Springer International Publishing: Cham, Switzerland, 2021; ISBN 978-3-030-72068-1. [Google Scholar]
- Baratchi, M.; Wang, C.; Limmer, S.; Van Rijn, J.N.; Hoos, H.; Bäck, T.; Olhofer, M. Automated Machine Learning: Past, Present and Future. Artif. Intell. Rev. 2024, 57, 122. [Google Scholar] [CrossRef]
- Tekin Ünver, R.; Bayraktar, C.; Demir, B. The Regression Analysis of Dry—Wet Wear Outcomes and Materials Properties of Biodegradable MgCu and MgZn, Made by P/M, Using Machine Learning Models. Appl. Phys. A 2025, 131, 311. [Google Scholar] [CrossRef]
- Gholamy, A.; Kreinovich, V.; Kosheleva, O. Why 70/30 or 80/20 Relation Between Training and Test Sets: A Pedagogical Explanation; University of Texas at El Pase, Departmental Technical Reports: El Paso, TX, USA, 2018. [Google Scholar]
- Joseph, V.R. Optimal ratio for data splitting. Stat. Anal. Data Min. 2022, 15, 531–538. [Google Scholar] [CrossRef]
- Qi, J.; Du, J.; Siniscalchi, S.M.; Ma, X.; Lee, C.-H. On Mean Absolute Error for Deep Neural Network Based Vector-to-Vector Regression. IEEE Signal Process. Lett. 2020, 27, 1485–1489. [Google Scholar] [CrossRef]
- Rutkowski, L.; Jaworski, M.; Duda, P. Stream Data Mining: Algorithms and Their Probabilistic Properties; Studies in Big Data; Springer International Publishing: Cham, Switzerland, 2020; Volume 56, ISBN 978-3-030-13961-2. [Google Scholar]
- Deperlioğlu, Ö.; Köse, U. Python Ile Makine Öğrenmesi; Seçkin Yayıncılık: Ankara, Turkey, 2024; ISBN 978-975-02-9027-5. [Google Scholar]
- Poldrack, R.A.; Huckins, G.; Varoquaux, G. Establishment of Best Practices for Evidence for Prediction: A Review. JAMA Psychiatry 2020, 77, 534–540. [Google Scholar] [CrossRef]






| Test Duration (h) | pH | Al (%) | Test Method | Deformation Rate (%) | Corrosion Rate (mm/Year) | Reference |
|---|---|---|---|---|---|---|
| 336 | 7 | 3 | Immersion | - | 0.28 | [30] |
| 2.5 | 7.5 | 3 | PD | 50 | 2.387 | [18] |
| 0.25 | 7 | 0 | PD | 5 | 1.321 | [33] |
| 216 | 7.4 | 0 | Immersion | - | 19 | [29] |
| 24 | 7 | 4 | HE | - | 0.28 | [27] |
| 0.25 | 7.4 | 0 | PD | 500 | 2.520 | [28] |
| 0.75 | 8 | 0 | PD | 97 | 0.23 | [22] |
| 1 | 7 | 5 | PD | - | 1.740 | [25] |
| 192 | 7 | 0 | HE | 94 | 0.28 | [32] |
| 72 | 7 | 8.52 | Immersion | - | 11.500 | [26] |
| 72 | 7 | 8.52 | Immersion | - | 12.800 | [26] |
| 0.5 | 7.3 | 0 | PD | 90 | 5.400 | [23] |
| 12 | 7 | 3 | Immersion | - | 0.82 | [19] |
| 2.5 | 7.5 | 3 | PD | - | 2.123 | [18] |
| 0.8 | 6 | 3 | PD | 72 | 1 | [24] |
| 72 | 7 | 3 | Immersion | - | 1.32 | [19] |
| 336 | 7.2 | 6 | EIS | - | 3.500 | [31] |
| 72 | 7 | 3 | Immersion | - | 1.35 | [19] |
| 24 | 7 | 5 | PD | - | 3.700 | [25] |
| 72 | 7 | 8.52 | Immersion | - | 5.500 | [26] |
| Description | Value | Description | Value |
|---|---|---|---|
| Session id | 42 | Categorical Imputation | Mode |
| Target | Corrosion Rate | Max. one-hot encoding | 25 |
| Target type | Regression | Transform Target | True |
| Original data shape | (103, 15) | Transform target method | Yeo |
| Transformed data shape | (103, 48) | Fold Generator | K-Fold |
| Transformed train set | (72, 48) | Fold Number | 10 |
| Transformed test set | (31, 48) | CPU Jobs | −1 |
| Numeric features | 10 | Use GPU | False |
| Categorical features | 4 | USI | Fb37 |
| Rows with missing values | 1.9% | Numeric Imputation | Mean |
| Preprocess | True | Log Experiment | False |
| Imputation Type | Simple | Experiment Name | Reg |
| Regressor Models | MAE | MSE | RMSE | R2 | RMSLE | MAPE | TT (Sec) | |
|---|---|---|---|---|---|---|---|---|
| GBR | Gradient Boosting | 0.1996 | 0.4489 | 0.4115 | 0.9901 | 0.0347 | 0.0572 | 0.0980 |
| ET | Extra Trees | 0.3578 | 0.8375 | 0.6459 | 0.9785 | 0.0725 | 0.1451 | 0.1650 |
| ADA | AdaBoost | 0.4664 | 1.9206 | 0.9438 | 0.9601 | 0.0704 | 0.2609 | 0.1110 |
| RF | Random Forest | 0.3537 | 1.2113 | 0.7420 | 0.9550 | 0.0616 | 0.2644 | 0.5870 |
| DT | Decision Tree | 0.4280 | 1.2917 | 0.8578 | 0.9375 | 0.0791 | 0.1145 | 0.0810 |
| KNN | K Neighbours | 2.4782 | 21.6102 | 3.8918 | −0.3468 | 0.6214 | 4.0365 | 0.0850 |
| LR | Linear | 1.4848 | 19.0384 | 2.9840 | −0.6181 | 0.3480 | 1.0001 | 0.0850 |
| SVM | Support Vector | 2.9848 | 32.0513 | 4.8763 | −1.5108 | 0.7888 | 5.5706 | 0.0990 |
| Regressor Models | MAE | RMSE | Subsample | n_Estimators | Learning_Rate | |
|---|---|---|---|---|---|---|
| GBR | 0.9577 | 1.0712 | 1.5565 | 1.0 | 300 | 0.15 |
| ET | 0.9290 | 1.2630 | 2.0173 | NaN | 500 | NaN |
| ADA | 0.8915 | 1.6852 | 2.4934 | NaN | 50 | 0.01 |
| Model Id | Corrosion Rate Real (mm/Year) | Corrosion Rate Predicted (mm/Year) | Residual |
|---|---|---|---|
| 30 | 18.00 | 19.00 | −1.000 |
| 67 | 0.930 | 0.976 | −0.046 |
| 62 | 8.410 | 9.753 | −1.343 |
| 47 | 0.280 | 0.280 | 0.000 |
| 42 | 0.300 | 0.300 | 0.000 |
| 40 | 0.275 | 0.275 | 0.000 |
| 90 | 2.030 | 1.960 | 0.070 |
| 45 | 1.700 | 1.699 | 0.001 |
| 10 | 1.100 | 1.050 | 0.050 |
| 0 | 0.280 | 0.280 | 0.000 |
| 18 | 1.000 | 0.976 | 0.024 |
| 31 | 26.200 | 24.514 | 1.686 |
| 97 | 7.800 | 7.298 | 0.502 |
| 85 | 0.410 | 0.409 | 0.001 |
| 76 | 0.480 | 0.479 | 0.001 |
| Model Id | Corrosion Rate Real (mm/Year) | Corrosion Rate Predicted (mm/Year) | Residual |
|---|---|---|---|
| 30 | 18.00 | 18.84 | −0.840 |
| 67 | 0.930 | 0.736 | 0.194 |
| 62 | 8.410 | 8.133 | 0.277 |
| 47 | 0.280 | 0.286 | −0.006 |
| 42 | 0.300 | 0.319 | −0.019 |
| 40 | 0.275 | 0.301 | −0.026 |
| 90 | 2.030 | 2.023 | 0.007 |
| 45 | 1.700 | 1.701 | −0.001 |
| 10 | 1.100 | 1.109 | −0.009 |
| 0 | 0.280 | 0.926 | −0.646 |
| 18 | 1.000 | 0.989 | 0.011 |
| 31 | 26.200 | 24.981 | 1.219 |
| 97 | 7.800 | 7.818 | −0.018 |
| 85 | 0.410 | 0.382 | 0.028 |
| 76 | 0.480 | 0.461 | 0.019 |
| Model Id | Corrosion Rate Real (mm/Year) | Corrosion Rate Predicted (mm/Year) | Residual |
|---|---|---|---|
| 30 | 18.00 | 15.54 | 2.460 |
| 67 | 0.930 | 0.973 | −0.043 |
| 62 | 8.410 | 11.67 | −3.260 |
| 47 | 0.280 | 0.260 | 0.002 |
| 42 | 0.300 | 0.305 | −0.005 |
| 40 | 0.275 | 0.256 | 0.019 |
| 90 | 2.030 | 1.946 | 0.084 |
| 45 | 1.700 | 1.736 | −0.036 |
| 10 | 1.100 | 1.157 | −0.057 |
| 0 | 0.280 | 0.260 | 0.020 |
| 18 | 1.000 | 0.985 | 0.015 |
| 31 | 26.200 | 15.792 | 10.408 |
| 97 | 7.800 | 7.191 | 0.609 |
| 85 | 0.410 | 0.389 | 0.021 |
| 76 | 0.480 | 0.390 | 0.009 |
| Test_Duration | 0.483318 |
| pH | 0.131010 |
| Al | 0.093299 |
| Zn | 0.076419 |
| Heat_Treatment_Temperature | 0.070875 |
| Test_Temperature | 0.045259 |
| Mn | 0.028079 |
| Mg | 0.027290 |
| Test_Method | 0.022538 |
| Deformation_Rate | 0.011346 |
| RE | 0.006233 |
| Heat_Treatment_Time | 0.002653 |
| Other_Elements | 0.001681 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Yıldırım, T.; Zengin, H. Predicting Corrosion Behaviour of Magnesium Alloy Using Machine Learning Approaches. Metals 2025, 15, 1183. https://doi.org/10.3390/met15111183
Yıldırım T, Zengin H. Predicting Corrosion Behaviour of Magnesium Alloy Using Machine Learning Approaches. Metals. 2025; 15(11):1183. https://doi.org/10.3390/met15111183
Chicago/Turabian StyleYıldırım, Tülay, and Hüseyin Zengin. 2025. "Predicting Corrosion Behaviour of Magnesium Alloy Using Machine Learning Approaches" Metals 15, no. 11: 1183. https://doi.org/10.3390/met15111183
APA StyleYıldırım, T., & Zengin, H. (2025). Predicting Corrosion Behaviour of Magnesium Alloy Using Machine Learning Approaches. Metals, 15(11), 1183. https://doi.org/10.3390/met15111183

