## 2 Materials and Methods
Having completed the machining stage, the condition of the surface was evaluated (parameters Ra, Rz, RSm) in order to compare the effects of milling and brushing. Figure 3 shows the brushing treatment in the process. The surface free energy of the Mg alloys was obtained indirectly by contact angle measurement. Two standard liquids were used, distilled water and diiodomethane. The standard liquids with a constant volume of approximately 4 \(\mu\)L were automatically applied to the test surface with a PGX goniometer (Paul N. Gardner Company, Pompano Beach, FL, USA). The contact angle measurements with distilled water and diiodomethane were carried out in 10 repetitions at minimum for each Mg alloy surface [38]. The measurements were taken at the temperature range of 20 to 22 \({}^{\circ}\)C and the relative humidity of 40% to 45%. The experimental data were fed into the ANN to simulate the maximum height of the profile (Rz). The milling and brushing processes were approached as the control object and the modelled surface roughness parameter, Rz, became the output parameter. This allowed us to compensate for any inaccuracy issues resulting from the nonlinear character of the simulated processes. The variable parameters of machining were the cutting speed, v\({}_{\text{c}}\), and the trochoidal step, s\({}_{\text{tr}}\) (2 neurons in the hidden layer). The ANN schematics in Figure 4 show the analyzed process parameters, the variable input, v\({}_{\text{c}}\) and s\({}_{\text{tr}}\), and the output parameters, the surface roughness Rz (one neuron in the output layer). Four different neural networks were prepared to represent the process, including: One machining parameter; two types of machining, milling and brushing; and two workpiece materials, AZ31 and AZ91D. The black box model of ANNs was selected for the performance considerations. This model is suitable whenever mathematical equations fail to accurately describe the process under analysis, as in the studied case. Figure 3: The brushing treatment process. Figure 2: Schematic diagram: (**a**) test set-up (**b**) and the study object. The simulation works were carried out with the application of the specialist statistical software, Statistica Neural Networks, and employed two ANN types, MLP (multi-layered perceptron) and RBF (radial basis function). The former model used linear, exponential, logistic, tanh, and sinus activation functions, while for the BFGS gradient (Broyden-Fletcher-Goldfarb-Shanno), the conjugate gradient and the steepest descent training algorithm were used to train the network. The latter network's activation functions were for hidden neurons, the Gaussian distribution, and for output neurons, the linear function, and it was trained with the RBFT algorithm. The number of neurons in the hidden layer (2-9) and training epochs (150-300) were determined experimentally. The advantages of the selected ANNs are optimal training, validation quality, and error characteristics. The least-squares method was used to identify the network errors. The training data set involved 75% of the experimental data while the remaining 25% were used for validation. Given the insufficient amount of data from milling, it was resolved that the test data set would not be included [19].