1 Introduction

The development of lightweight materials is a trend in industrial development due to their favorable environmental and economic impacts. Magnesium and alloys are lightweight metals that are lighter than steel and aluminum. These materials have excellent mechanical properties and are promising for industrial applications [1]. There are several types of magnesium and alloys, such as aluminum–manganese (AM), aluminum–silicon (AS), and aluminum–zinc (AZ) [2]. Aluminum–zinc elements are commonly used as magnesium alloying elements because they are economical and highly soluble. The addition of aluminum to magnesium alloys improves the alloy’s strength and melting point [3].

AZ–magnesium alloys, especially AZ91, can be developed as metal matrix composites with carbon-based reinforcement, such as graphene, to enhance their mechanical properties. Graphene is a carbon-based material that provides an alternative reinforcement to enhance the mechanical properties of magnesium composites [4]. Stir-casting is commonly used to fabricate magnesium composites owing to its ease of use and high-scale production. The mechanical properties of metal matrix composites, especially with AZ–magnesium alloys, can be improved by applying different heat treatments, such as T6 heat treatment [5]. In addition to heat treatment, these materials can also be improved using mechanical working, such as equal channel angular pressing (ECAP) [6].

The mechanical properties of composites are evaluated by determining yield strength (YS) and ultimate tensile strength (UTS), which are derived from the engineering stress–strain curve [7]. The engineering stress–strain curve illustrates the deformation behavior of the specimen under a progressively increasing applied load until fracture takes place [8]. Stress, measured in megapascals (MPa), is defined as the applied force (F, in newton) divided by the initial cross-sectional area of the specimen (A, in square millimeters) as shown in Eq. (1). Strain, expressed as a percentage (%), represents the material’s deformation under applied stress and is calculated as the ratio of the change in length (ΔL) to the original length of the specimen (L₀) before loading, as presented in Eq. (2) [9].

$${\varvec{\sigma}} = \frac{F}{A}$$
(1)
$$e \, = \frac{{l_{i} - l_{o} }}{{l_{0} }} = \frac{\Delta l}{{l_{0} }}$$
(2)

The mechanical properties of materials can significantly influence their fractographic resource, which is often analyzed to evaluate the joining efficiency and fracture patterns of tensile specimens. However, the fracture area alone cannot effectively reveal the detailed fracture behavior. Instead, examining the cross-sectional area and conducting observations using scanning electron microscope (SEM) provides more comprehensive insights. Images from fractography illustrate the surface features, which allow the classification of two types of fractures, i.e., brittle and ductile [9].

Fractography examination is used to evaluate improvements in mechanical properties and surface features. However, it has some limitations since it is time-consuming, high-cost, and requires labor. Thus, an effective method is required to solve these limitations. The machine learning (ML) method, an artificial intelligence branch, can be utilized as a novel approach for designing AZ91 magnesium alloy composites. ML can transform material design by predicting the behavior of materials, especially their mechanical properties [10]. For instance, Huang et al. [11] used ML to predict the mechanical properties of magnesium matrix composites as an innovative tool for designing materials.

Regression is one of the ML models that can be used as a prediction tool because it is suitable for predicting continuous data, such as mechanical properties. In addition, many researchers have used regression models to predict mechanical properties. A previous study employed linear regression to predict mechanical properties with an accuracy of more than 95% [12]. Although linear regression can be an effective prediction tool, other methods, such as the random forest regression model, can provide better accuracy and efficient handling of nonlinear data [13]. For example, Kwan et al. [14] used random forest regression to predict the mechanical properties of γ-TiAl alloys, achieving an R2 of approximately 0.9856 (98.56%) for tensile strength prediction. Additionally, Zhao et al. [15] applied ML methods, including random forest regression, to predict the mechanical properties of carbon fiber-reinforced polymers with an accuracy of 99%. Dong et al. [16] further stated that the random forest model had good performance in small data prediction on alloy properties.

Random forest is a tree-based ML model that uses multiple weak decision tree learners grown in parallel to simultaneously reduce bias and variance. The proposed method combines the outputs of numerous decision tree algorithms to improve predictive performance. The random forest predictor can be defined in Eq. (3), where (x) represents the input vector comprising various values from the training data. Here, \(T(x)\) represents the prediction of a single individual decision tree, K denotes the number of trees, and the final prediction \((rf\left(x\right))\) is obtained by averaging the outputs of all the trees. The term \(\sum_{k-1}^{k}T(x)\) represents the sum of predictions from all K trees [17].

$$\mathop \smallint \nolimits_{rf}^{K} \left( x \right) = \frac{1}{K }\mathop \sum \limits_{k - 1}^{k} T\left( x \right)$$
(3)

The random forest is widely used not only for regression but also for classification tasks, making it a versatile method for developing predictive models across various fields [18]. This model offers several advantages, including the ability to predict numerical values without requiring feature standardization and a strong resistance to overfitting [19]. However, it also has limitations, such as a lack of interpretability and reduced performance in situations involving class imbalance [11]. A schematic representation of the random forest model is shown in Fig. 1. Bahl et al. [20] applied random forest classification for nanomaterial grouping, achieving a high R2 value of approximately 0.82. Furthermore, the proposed random forest classification model is well-suited for predicting surface features using fractography, particularly when dealing with categorical data.

Fig. 1
figure 1

Schematic representation of random forest machine learning model [21]

In this study, we used AZ91 magnesium alloy as the matrix material and graphene as the reinforcement. The composite was further enhanced using T6 heat treatment and ECAP, with fabrication performed through stir-casting. We observed the optimal mechanical properties and ductile fractographic examination in the AZ91-0.2 wt% graphene composite under T6, ECAP 1 Pass, and ECAP 2 Pass treatments [22]. Data from these composites were integrated into a random forest ML model to predict mechanical properties and fractographic examination with the goal of achieving high accuracy and identifying new optimal mechanical properties [15].

The random forest successfully predicted the mechanical properties and fracture behavior of AZ91 magnesium alloy composites reinforced with graphene. Furthermore, the model identified new optimization possibilities for the composites, which were experimentally validated. This novel approach highlights the potential of the random forest model, incorporating both regression and classification tasks, in industrial composite design, enabling the identification of optimal parameters to achieve desired properties effectively.

2 Methodology

In this study, we fabricated an AZ91 magnesium (comprising 8.95 wt% Al and 0.84 wt% Zn) matrix composite reinforced with graphene using stir-casting, achieving notable enhancements (datasets are provided in Table 1) as previously published [22]. Data from this study were collected for integration into an ML model. The input parameters included the reinforcement type (as-cast or without reinforcement and reinforced with graphene), reinforcement variation (0–0.2 wt%), heat treatment (no heat treatment, T4, and T6), and ECAP (0 to 2 passes). The output parameters were the YS and the UTS predicted using the random forest regression, while the fracture behavior was classified using a random forest classification model.

Table 1 Dataset of the study

Figure 2 presents the schematic methodology used in this study. During data collection, data preprocessing was performed to define the input and output parameters. The statistical data are summarized in Table 2, focusing specifically on the variations in the reinforcement as input parameters, with the output parameters representing the mechanical properties in float form. Other input and output parameters related to fractographic examination, provided in character form, were excluded from the statistical calculations. The statistical data included key metrics, such as mean, standard deviation (SD), minimum, maximum, and Q1–Q3 values.

Fig. 2
figure 2figure 2

Schematic methodology of the study

Table 2 Statistical dataset

Before running the predictions, the data were split into training and test sets80% were allocated for training while the remaining 20% were allocated for testing. In the second step, a random forest ML model was applied using 100 estimators and a random state of 42 for both regression and classification tasks. We used the Python programming language with JupyterLab software. The models were evaluated using performance evaluations, such as R2, mean absolute error (MAE), and root mean square error (RMSE).

In the performance evaluation, the regression models were assessed using various mathematical formulas. In these equations, \({X}_{i}\) denotes the predicted \({i}^{th}\) value, while \({Y}_{i}\) represents the actual data with value from the ground-truth dataset. In addition, m represents the total number of actual values, and \(\overline{Y}\) represents the mean of the actual values. Equation (4) displays the coefficient of determination (R2 or R-squared), which can be interpreted as the proportion of the variance in the dependent variable that can be predicted from the independent variables (accuracy) [23]. Next, the MAE was used to calculate the average absolute differences between the predicted and actual values, as shown in Eq. (5). Meanwhile, Eq. (6) represents the RMSE, which is the average root squared difference between the actual and predicted values [24].

$$R^{2} = \, 1 \, - \frac{{\mathop \sum \nolimits_{i = 1}^{m} \left( {X_{i} - Y_{i} } \right)^{2} }}{{\mathop \sum \nolimits_{i = 1}^{m} \left( {\overline{Y} - Y_{i} } \right)^{2} }}$$
(4)
$${\mathbf{MAE}} = \frac{1}{m} \mathop \sum \nolimits_{i = 1}^{m} \left| {X_{i} - Y_{i} } \right|$$
(5)
$${\mathbf{RMSE}} = \sqrt {\frac{1}{m}\mathop \sum \limits_{i = 1}^{m} \left( {X_{i} - Y_{i} } \right)^{2} }$$
(6)

In the classification model, performance was evaluated using metrics distinct from those used in regression, including Accuracy (ACC), as defined in Eq. (7), which represents the ratio of correct predictions. Precision (P), defined in Eq. (8), was employed to calculate the proportion of correctly predicted positive patterns. Recall (R), defined in Eq. (9), was used to calculate the proportion of actual positive patterns that were correctly identified. These metrics use true positives (TP) and true negatives (TN), which are summed to derive their respective values. In addition, false positives (FP) and false negatives (FN) represent the total number of incorrect positive and negative predictions, respectively [25].

$${\mathbf{ACC}} = \frac{{{\text{TP}} + {\text{TN}}}}{{{\text{TP}} + {\text{FP}} + {\text{TN}} + {\text{FN}}}}$$
(7)
$${\varvec{P}} = \frac{{{\text{TP}}}}{{{\text{TP}} + {\text{FP}}}}$$
(8)
$${\varvec{R}} \, = \frac{{{\text{TP}}}}{{{\text{TP}} + {\text{FN}}}}$$
(9)

Following the performance evaluation, the regression model was analyzed using a residual plot to visualize the differences between the actual and predicted values. Meanwhile, a correlation matrix was utilized to illustrate the relationships between the parameters. The classification model was determined using a confusion matrix and a correlation matrix. Subsequently, the predicted values were validated to assess the differences between the predicted and actual outcomes.

In the third step, new mechanical property optimizations were derived from the regression ML model and used to predict new fractographic examination based on the regression results. These predictions were validated through laboratory experiments by fabricating composites using the stir-casting method, followed by enhancement processes, such as T6 heat treatment and ECAP, via the A route (120°). Microstructure characterization was conducted using X-ray diffraction (XRD), Raman spectroscopy, and optical microscopy (OM) combined with energy-dispersive X-ray spectroscopy (SEM–EDS), while the tensile test was performed to evaluate the mechanical properties according to ASTM E8-69 standards. An average of three samples was taken for the characterization. Fractographic analysis was performed using SEM. Furthermore, all fabrication processes, microstructure characterization, and mechanical testing equipment and parameters were consistent with those used in a previous study [22].

3 Results and discussion

3.1 Prediction of mechanical properties and fractography examination using random forest machine learning model

3.1.1 Prediction of mechanical properties using random forest regression

In this prediction model, various input parameters were used to predict multiple-output parameters using software, specifically YS and UTS, based on the mechanical properties. Figure 3 illustrates the graph of the actual versus predicted data for these properties. The blue and green dots represent the training and test data, respectively, while the red line represents the perfect fit. In addition, the performance evaluation metrics for both the training and test outputs are shown in Table 3. The model demonstrated high accuracy, ranging from 92.52% (0.9252) to 98.80% (0.9880), which are close to 1. These results reflect the model's robust predictive capabilities [26].

Fig. 3
figure 3

Graphs depicting the actual vs. predicted a yield strength (YS) and b ultimate tensile strength (UTS)

Table 3 Performance evaluation from the prediction model with various input parameters from random forest regression

The model was explained using a residual plot and correlation matrix generated using software (Fig. 4). In the residual plot, blue and green dots represent training and test residuals, respectively, while the red line indicates the perfect fit. The residual values for the training data were closer to the perfect fit line than those for the test data for both output parameters. In the correlation matrix, the highest value was approximately 0.92, and the lowest value was approximately 0.00. Higher values closer to 1 indicate a strong correlation between parameters [27].

Fig. 4
figure 4

Model explanation: actual residual vs. predicted plots of a yield strength (YS) and b ultimate tensile strength (UTS), as well as the c correlation matrix

The prediction of the output parameters, YS and UTS, along with the validation calculated from the percentage error between the actual and predicted values, is presented in Table 4. The highest error was 17.82% for the AZ91-0.2 wt% graphene as-cast UTS, whereas the lowest error was 0.33% for the AZ91-0.1 wt% graphene T6 YS. The highest performance was observed for the AZ91-0.2 wt% graphene ECAP 2 Pass sample (highlighted in bold in Table 4). This was further validated by the percentage error, which showed a YS error of approximately 4.57% and a UTS error of approximately 0.04%. In addition, most errors were less than 10%, which is generally acceptable for industrial applications [28]

Table 4 Prediction of mechanical properties and its validation

The proposed model also provides a new optimization recommendation based on the reinforcement variations. Before the ML predictions, the optimum sample was identified as AZ91-0.2 wt% graphene under T6 and both ECAP passes treatments. However, the random forest regression model recommended AZ91-0.16 wt% graphene as the optimal composition in the mechanical properties prediction as illustrated in Fig. 5. Furthermore, to validate this recommended value, an experimental study was conducted to confirm its accuracy and effectiveness.

Fig. 5
figure 5

Graph of new sample optimizations based on the random forest regression model

3.1.2 Prediction of fractography examination using random forest classification

In this classification model, the predicted fractography types for the training and testing datasets are illustrated in Fig. 6, which were generated using software. The performance evaluation metrics for training and testing were set to 1.0000 for all metrics (Table 5). The results indicate that the model achieved excellent prediction accuracy. In addition, all predicted samples matched the actual data. As shown in Table 6, the confusion matrix shows that the model has 10 TP, 2 TN, and no FP or FN.

Fig. 6
figure 6

Graph classification of a training and b testing results from machine learning random forest classification

Table 5 Performance evaluation from prediction with various input parameters from random forest classification
Table 6 Fractography examination prediction and its validations

The mean ductile type was positive, whereas the mean brittle type was negative. A TP indicates that both the actual and predicted data are positive, whereas a TN demonstrates that both the actual and predicted values are negative. Conversely, FP and FN occur when the actual and predicted values are opposite [29]. In this study, all predictions matched the actual values, demonstrating a perfect fit between the actual and predicted results.

The random forest classification model is explained using the confusion and correlation matrices, as shown in Fig. 7. First, the confusion matrix highlighted the performance of each classifier, illustrating the relationship between the predicted and actual classifications. In Fig. 7a, the training data results show seven ductile types and two brittle types, while Fig. 7b shows the test data results, with all predictions classified as ductile types. In the correlation matrix, the highest value was approximately 0.87, indicating a strong positive correlation between the parameters, whereas the lowest value was around 0.00, suggesting little to no correlation. Values closer to 1 indicate a strong relationship, whereas values closer to 0 indicate weaker or no correlation.

Fig. 7
figure 7

Model explanation of random forest classification: a a confusion matrix training, b a confusion matrix test, and c a correlation matrix

As discussed in the previous section, the new optimization recommendation based on the variations in the reinforcement identified AZ91-0.16 wt% graphene as a new optimal composition. The random forest classification model predicted that the fracture behavior of AZ91-0.16 wt% graphene under T6, ECAP 1 Pass, and 2 ECAP passes treatments would exhibit ductile characteristics (Fig. 8). To validate this prediction, an experimental study was later conducted to confirm the model's accuracy and effectiveness.

Fig. 8
figure 8

Prediction of the fractography examination of AZ91-0.16 wt% graphene using random forest classification

3.2 Validation of new optimizations through experiments

In the predictions using various parameters for the mechanical properties and fractography examination, several factors—such as the reinforcement type, reinforcement variation, heat treatment, and ECAP—play a role. First, the reinforcement type and variation in the composite materials can enhance the strength by promoting strong bonding between the matrix and the reinforcement [30]. Second, heat treatment processes involving controlled heating and cooling can modify a material's microstructure and increase its ductility before ECAP, significantly influencing its mechanical properties [5]. Lastly, ECAP can produce ultrafine-grained materials with high strength at room temperature [31].

When correlated with the ML prediction model, the optimal parameter type for each parameter was selected to achieve desirable mechanical properties, allowing the YS and UTS to be determined due to the multiple-output approach. Based on the new optimization recommendations from the random forest regression model, we re-fabricated the AZ91-0.16 wt% graphene composite, and enhanced it with T6 heat treatment, ECAP 1 Pass, or ECAP 2 Pass using route A at 120°. The next subsection presents the experimental validation with microstructure characterization and its correlation with mechanical properties and fractography, followed by the comparison of the prediction and the actual results.

3.2.1 Microstructure characterization

The microstructure of all samples was analyzed using XRD to identify the phases, while Raman spectroscopy was employed to detect graphene reinforcement. Phase composition and morphology were determined using SEM–EDS, and grain size was determined by OM.Additionally, the microstructural characterization results were correlated with the mechanical properties.

First, the XRD analysis, as shown in Fig. 9, revealed the existence of three phases in the magnesium composites: the primary phase, Mg0.97Zn0.03 (PDF 65-4596); and the secondary phase, Mg17Al12 (PDF 73-1148) and MgC2 (PDF 89-7745), which formed due to the addition of graphene reinforcement, leading to improved mechanical properties [32].

Fig. 9
figure 9

XRD pattern

The intensity of the prismatic (10 \(\overline{1 }\) 1) plane was stronger in both ECAP samples than in the T6 sample due to dynamic recrystallization (DRX), which weakened the intensity of the basal (0002) plane [33]. Additionally, MgC₂ (magnesium carbide) was detected at 32.15° in all composite samples. The graphene peak (PDF 26-1080) was typically observed at 26.60° and/or 54.79° in the composite samples. However, due to the very small fraction of reinforcement, the XRD equipment could not detect graphene, showing the limited detection capability of XRD [34].

To determine each percentage of the phase, phase quantification analysis was performed (Table 7). The reference intensity ratio (RIR) method, which is suitable for bulk sample determination, was employed to determine the number of phases. The sum of the weights of all phases must be equal to 1 as shown in Eq. (10). To estimate the quantitative values of the significant phases, the RIR method was utilized again as outlined in Eq. (11). RIR is defined as the ratio of the most prominent peak of an unknown phase to the peaks of a standard phase. In this equation, Iiα denotes the highest intensity of the unknown phase, while RIRαc represents the strongest intensity ratio between the unknown and standard phases. Likewise, Iik corresponds to the highest intensity of the Iiα unknown phase, and RIRkc represents the strongest intensity ratio between the unknown k phase and the standard phase.

$$\mathop \sum \nolimits_{k = 1}^{n} W_{k} = 1$$
(10)
$$W_{\alpha } = {\text{ Ii}}\alpha /{\text{RIR}}\alpha {\text{c }} \times \left( {\sum\nolimits_{k = 1}^{n} {{\text{Iik}}/{\text{RIRkc}}} } \right)^{1} \times 100\%$$
(11)
Table 7 Phase quantification

The secondary phase, Mg17Al12, has a detrimental effect on AZ91 composites [35]. The percentage of secondary phases was higher in both ECAP passes than in the T6 sample because of the fragmentation and redistribution of the phases. These variations were primarily influenced by DRX during ECAP, which significantly affected the microstructure and mechanical properties of the composites [36].

Several equations were utilized to quantify the effects of T6 and ECAP treatments on the composites as these processes influence the broadening and intensity of each composite’s diffraction peaks.  Scherrer equation (12) was applied to determine the average crystallite size, where k represents the Scherrer constant (typically 0.9), λ denotes the X-ray radiation wavelength, β corresponds to the full width at half maximum (FWHM) of the peak (in radians), and θ is the Bragg angle. Additionally, crystallinity index was determined using the Segal equation (13), where Iₕₖₗ represents the maximum intensity measured at the (hkl) plane, and Im denotes the intensity of the amorphous phase [37].

$${\text{Crystallite}} {\text{size}}\, \left( d \right) = \frac{k\lambda }{{\beta \cos \theta }}$$
(12)
$${\text{Crystallinity index}} \left( {{\text{CI}}} \right) = \left( { \frac{{{\text{Ihkl}} - {\text{Iam}}}}{{\text{ Iam}}}} \right) \times 100\%$$
(13)
$$\beta {\text{Cos}} \theta = \frac{K\lambda }{d} + 4\varepsilon {\text{Sin}} \theta$$
(14)
$$\rho = \frac{3.463 \varepsilon }{{db}}$$
(15)

In addition to phase quantification, microstrain was determined using the Williamson–Hall method as described in Eq. (14). In this equation, ε represents microstrain, which is plotted against βcosθ and 4sinθ. ORIGIN software was used to derive the slope of the curve. Furthermore, dislocation density was calculated using Eq. (15) after determining the microstrain. In this equation, ρ represents dislocation density, d denotes crystallite size, b is the Burger’s vector (0.325 nm), and ε corresponds to the microstrain [37].

Table 8 presents all values calculated using Eqs. (1215). Crystallite size, microstrain, and dislocation density values decreased from T6 to ECAP 2 Pass, while the crystallinity index decreased from T6 to ECAP 1 Pass and then increased at ECAP 2 Pass. These variations are attributed to the effects of grain refinement, which influence the microstructure and directly impact grain size, as explained in the SEM-EDS and OM analyses in the following paragraph, along with their effects on mechanical properties [38].

Table 8 Crystallite size, crystallinity index, microstrain, and dislocation density of composites

Raman spectroscopy was used to detect the graphene reinforcement in the samples. The results are shown in Fig. 10. Several characteristic peaks corresponding to the D, G, G*, and G’ bands were observed in the graphene reinforcement [39]. However, only the G* band was detected in all composite samples, with specific values of 2438.3188 cm⁻1 in the graphene reinforcement sample, 2437.61 cm⁻1 in the T6 sample, 2437.0681 cm⁻1 in the ECAP 1 Pass sample, and 2438.1594 cm⁻1 in the ECAP 2 Pass sample. Furthermore, the sole detection of the G* band confirmed the presence of graphene reinforcement in the samples, as reported in previous studies [22].

Fig. 10
figure 10

Raman Spectra

SEM observations revealed the presence of Mg17Al12 and MgCphases in all samples (Fig. 11). The Mg₁₇Al₁₂ phase in the T6 sample exhibited a lamellar structure, whereas that in the ECAP samples appeared spherical. These structural changes were attributed to the effects of DRX during ECAP, which was conducted at high temperatures to induce plastic deformation, leading to grain refinement. As a result, the lamellar structure was broken down into fine particles [40]. These treatments were also previously explained in Table 7, which presents the phase quantification results. The composition of secondary phases was higher in both ECAP samples than in the T6 sample.

Fig. 11
figure 11

Microstructure of the AZ91-graphene composites from SEM (left side) and EDS mapping (right side)

The size of the secondary Mg17Al12 phase was measured using ImageJ software (highlighted with red circles). In the T6 sample, the phase size ranged from 11.01 µm to 30.56 µm, while in the ECAP 1 Pass sample, it ranged from 2.96 µm to 17.41 µm. Meanwhile, the phase size of the ECAP 2 Pass sample ranged from 0.86 µm to 17.30 µm. As illustrated in Fig. 11, EDS mapping confirms the presence of Mg, Al, Zn, and C within the sample microstructure, depicting the distribution of each element and the Mg0.97Zn0.03 phase. The presence of Mg17Al12 and MgC2 phases was further supported by EDS point analysis (Fig. 12). The formation of both phases has been previously reported [22].

Fig. 12
figure 12

EDS point analysis of AZ91-graphene composites: a Mg17Al12 T6, b Mg17Al12 on both ECAP passes, and c MgC2

The effects of the T6 and ECAP treatments resulted in grain refinement, leading to a reduction in grain size (Fig. 13). The average grain size of the T6 sample was significantly larger than that of both ECAP samples, where a noticeable reduction in grain size of the ECAP samples was observed. Specifically, the average grain sizes were 56.12 µm in the T6 sample, 19.76 µm in the ECAP 1 Pass sample, and 16.69 µm in the ECAP 2 Pass sample. Furthermore, the effect of DRX induced by ECAP resulted in the presence of both deformed and undeformed regions within the grains of both ECAP samples [41]. Figure 13 also presents the grain size distribution histogram for each sample, providing a detailed visualization of the grain size variations. Additionally, the grain refinement observed in the OM analysis correlates with the XRD and SEM results and influences the mechanical properties.

Fig. 13
figure 13

Microstructure observation of the AZ91-graphene composites using optical microscopy (left side) and grain distribution histogram (right side)

3.2.2 Mechanical properties and fractography

The mechanical properties of all composite samples were assessed using the tensile test. The engineering stress–strain curve is shown in Fig. 14. Results in Table 9 suggest that YS and UTS increased from T6 until ECAP 2 Pass. However, there was only a slight increase in UTS value from ECAP 1 Pass to ECAP 2 Pass. In addition, the ductility also increased because the elongation values increased from T6 until ECAP 2 Pass. These treatments resulted in grain refinement from T6 to ECAP 2 Pass, which increased the mechanical properties of the samples. Similarly, the secondary precipitate Mg17Al12 phase of T6 to ECAP was split into smaller particles, as explained in the previous section.

Fig. 14
figure 14

Engineering stress–strain curve of AZ91-0.16 wt% graphene composites

Table 9 Summary of mechanical properties

The grain refinement can be explained by the Hall–Petch equation, as shown in Eq. (16), where σy represents the yield strength of the composite, σ0 and K (130 MPa µm1/2) are constants related to the materials, and d represents the grain size [42, 43]. In this study, Eq. (17) can be used to estimate the increase in YS caused by grain refinement due to T6 heat and ECAP treatments, where dcom is the average grain size of the AZ91 composites and daz91 is the average grain size of the matrix composite [44].

$$\sigma y = \sigma_{0} + \, Kd^{ - 1/2}$$
(16)
$$\Delta \sigma_{{{\text{HP}}}} = \, K \, \left( {d_{{{\text{com}}}}^{ - 1/2} {-} \, d_{{{\text{AZ}}91}}^{ - 1/2} } \right)$$
(17)

The addition of graphene to metal matrix composites can significantly enhance their strength and lead to the formation of a new phase, MgC2. This phase influences the load transfer mechanism during tensile testing, where the load is transferred from the matrix to the nanoreinforcement (graphene). Improved interfacial bonding between the matrix and reinforcement further contributed to this effect. Equation (18) shows the load transfer equation with Vf as the reinforcement volume, S is the aspect ratio (1272), and \(\sigma\)m as the yield of the matrix of the composite [45].

$$\Delta \sigma_{LT} = \left( \frac{S}{4} \right)\sigma_{m} V_{f}$$
(18)

In this study, weight fractions were used to determine the volume fraction of the reinforcement for calculating the load transfer mechanism using the formula in Eq. (19), where V represents the volume fraction, W denotes the weight fraction, and ρ signifies density. In addition, the subscripts f and m refer to the reinforcement and matrix, respectively [9].

$$V_{f} = \frac{{\frac{Wf}{{\rho f}}}}{{\frac{Wm}{{\rho m}} + \frac{Wf}{{\rho f}}}} \times \, 100$$
(19)

Both the Hall–Petch and load values of all samples increased from T6 to ECAP 2 Pass. However, the load value was higher than the Hall–Petch value because the load transfer mechanism plays a more significant role as observed in earlier studies utilizing graphene reinforcement [46]. In addition, effective load transfer ensured strong interfacial bonding between the matrix and reinforcement. The higher load value also contributed to the reduction of the secondary phase particle size from T6 to ECAP 2 Pass, while the higher Hall–Petch value was associated with the decrease in grain size of the samples [33].

To determine the fracture behavior, the cross section of the fractured tensile specimen was observed using SEM, as depicted in Fig. 15. Dimple (ductile) fractures were present on all AZ91-0.16 wt% graphene composites treatments, and microvoids were identified in all samples due to the effect of stir-casting that formed harmful cavities. Furthermore, these fractures were observed on all samples since T6 and ECAP treatments can enhance ductility due to grain refinement. Next, the microvoids were decreased from the T6 until ECAP 2 Pass samples due to the ECAP filling effect and improved mechanical properties [47].

Fig. 15
figure 15

Fractography of AZ91-0.16 wt% graphene composites under a T6, b ECAP 1 Pass, and c ECAP 2 Pass

3.2.3 Comparison of prediction and actual results from experimental validation

The mechanical properties of AZ91-0.16 wt% graphene composites were predicted based on recommendations from the random forest regression model as shown in Table 10. The prediction errors were below 10%, except for the UTS of AZ91-0.16 wt% graphene ECAP 2 Pass despite an R2 value above 0.90. Additionally, the lowest error observed was 3% for the UTS of AZ91-0.16 wt% graphene ECAP 1 Pass.

Table 10 Actual versus predicted mechanical properties of AZ91-0.16 wt% graphene composites

Meanwhile, the error predictions for the YS of AZ91-0.16 wt% graphene ECAP 2 Pass exceeded 10%, which could be attributed to the R2 test for YS prediction being lower than the R2 test for UTS prediction, as explained in Sect. 3.1.1.

Compared to the optimum experimental results, the UTS values of AZ91-0.16 wt% graphene T6 and ECAP 2 Pass exceeded those of AZ91-0.2 wt% graphene under the same treatments (Fig. 16). However, the UTS of AZ91-0.16 wt% graphene in ECAP 1 Pass was slightly lower than that of AZ91-0.2 wt% graphene in ECAP 1 Pass. Furthermore, the YS values of AZ91-0.16 wt% graphene did not exceed those of AZ91-0.2 wt% graphene.

Fig. 16
figure 16

Actual a yield strength (YS) and b ultimate tensile strength (UTS) values comparison of AZ91-016 wt% graphene vs. AZ91-012 wt% graphene

Although the recommendations from the ML model did not exceed the experimental optimum for all values, an analysis of the strain-hardening capacity of both composites revealed that the strain-hardening of all AZ91-0.16 wt% graphene composites was higher than that of AZ91-0.2 wt% graphene composites. The strain-hardening capacity, as shown in Eq. (20), represents the work-hardening ability of the composites, calculated using values of YS and UTS [37].

$$H_{c} = \frac{\sigma uts - \sigma ys}{{\sigma ys}} = \frac{\sigma uts}{{\sigma ys}} - 1$$
(20)

All strain-hardening values are presented in Table 11, with the highest value of approximately 1.1887 observed in AZ91-0.16 wt% graphene ECAP 2 Pass and the lowest value of approximately 0.7030 in AZ91-0.2 wt% graphene ECAP 2 Pass. Furthermore, strain-hardening influences both strength and ductility during plastic deformation and is also affected by grain refinement [48]. In addition, a higher strain-hardening capacity (Hc > 1) indicates that the sample exhibits greater ductility and toughness before fracture compared to samples with a lower strain-hardening capacity [49].

Table 11 Strain hardening

In correlation with the strain-hardening capacity of the materials, the work-hardening behavior can also be evaluated using Eq. (21), which defines the true plastic stress as a function of the derivative of true stress with respect to true strain—commonly referred to as the strain-hardening rate [37]. The calculated strain-hardening rates for each sample are plotted in Fig. 17. All samples exhibited a decreasing trend in strain-hardening rate as the stress increased, indicating a reduction in the material’s ability to harden at higher stress levels.

$$\theta \, = \frac{{{\text{d}}\sigma }}{{{\text{d}}\varepsilon }}$$
(21)
Fig. 17
figure 17

Strain hardening rate of AZ91-graphene composites

Compared to the experiment-based optimized samples, the strain-hardening rate of the ML-based optimized samples showed a smoother decreasing trend, indicating more stable hardening behavior. For example, in AZ91-0.2 wt% graphene, the strain-hardening rates under all treatments exhibited noticeable fluctuations, whereas AZ91-0.16 wt% graphene demonstrated a more consistent trend across all treatments. Furthermore, the samples optimized through ML showed better strain-hardening performance than those optimized solely through experimentation.

In contrast to the predictions of mechanical properties, results presented in Table 12 indicate that the predictions from the random forest classification model are consistent with the actual outcomes, with both the predicted and actual results classified as ductile. These results aligned with the optimal recommendation from the random forest regression model, which indicated that AZ91-0.16 wt% graphene composites exhibited good strain-hardening capacity, suggesting good sample ductility (values exceeding 1). Furthermore, the output was identical across all samples, and all outcomes were classified as TP. This consistency can be linked to the high ACC of the ML model.

Table 12 Actual versus predicted fractography examination of AZ91-0.16 wt% graphene composites

4 Conclusion

This study employed a random forest ML model to examine the mechanical properties and fractography prediction of the AZ91-graphene composites. The conclusions are as follows:

  1. 1.

    The random forest regression model demonstrated a high coefficient of determination with low error rates in predicting mechanical properties. The random forest classification model also achieved near-perfect accuracy of approximately 1.0 in predicting fractographic examination results. The validation errors for the predicted mechanical properties were mostly below 10% of the actual values. Furthermore, for the prediction of fractographic examination, all data points were correctly classified into their respective categories.

  2. 2.

    Based on the experimental validation of the mechanical properties, the optimized predictions from the random forest regression model did not exceed the values obtained experimentally, except for the UTS under the T6 and ECAP 2 Pass treatments. However, the strain-hardening capacity of the samples recommended by the ML model was higher than that of the experimental samples. The predictions of fractographic examination from the random forest classification model were also experimentally validated, showing consistent results with correct categorization and TP outcomes.

This study can serve as a reference or guide for researchers to explore new mechanical properties and conduct fractography examinations using ML to design metal composites. The study results further demonstrate that the ML approach can be an effective tool for designing metal composites in a more cost-efficient and time-saving manner.