Forecasting mass and metallurgical balance at a gold processing plant using modern multivariate statistics

Knowing the quantity and the quality of products and tailings generated by a beneficiation plant, even before ore processing, can make the mining operations more sustainable, more profitable, and safer. To forecast these values, it is necessary to sub-mit samples to batch tests which mimic the processing workflow used on an industrial scale. Then, the results need to be analysed with the aim of finding a statistical model able to comprehend how Run of Mine (ROM) characteristics impact the performance at the beneficiation. After developing a model, it is possible to apply it to blocks where the ROM characteristics are known, but the metallurgical information is not, making it possible to estimate these. With this goal, a geometallurgical model was developed with a neural network technique using 37 samples collected at two Brazilian gold mines. The Au and S grades in ROM, and the mine from where the sample was collected, were used as input variables. The model was able to forecast the following variables with a Pearson correlation coefficient on the cross validation test set equal to the value in parenthesis: mass (0.55) and metallurgical (0.54) recovery in the gravimetric concentrate, mass (0.80) and metallurgical (0.12) recovery in the flotation tailings, mass (0.77) and metallurgical (0.11) recovery in the leaching tailings, mass recovery (0.84) of gas sent to the sulphuric acid plant, and metallurgical recovery (0.65) in the leaching concentrate. The results obtained with neural networks were superior to the ones obtained when three alternative techniques were tested.


Introduction
Geometallurgical models are frequently developed focussing on forecasting variables related to saleable products. Geometallurgy applied for tailings grades and mass are rarely explored, either for lack of investment to know variables which will not bring immediate financial return or for ignoring the fact that by knowing the quantity and the quality of tailings, financial benefit can also be added. Knowing the tailings grade beforehand opens up the possibility of deciding where to send it: to the tailings dam, as usual, or to stockpile the tailings to make possible further use of it, if the observed grade is high enough to offset the process costs. Adopting the second option, it would be possible to recover a metal which initially would be lost, so improving the metallurgical recovery. Furthermore, by knowing the complete plant mass balance, including tailings mass, it would enable one to forecast when the tailings dam will reach its maximum storage capacity, making it possible to better plan its height or building a new one. In a critical scenario, a new solution would be to use dried tailings deposition in waste dumps, aiming at minimising the environmental impact.
The need to predict concentrate geometallurgical characteristics beforehand is mandatory at most mining operations. By doing that, it is possible to classify a block as ore or waste, not only by considering the cut-off grade in ROM, but also by considering the characteristics that the material will present when processed. By adding this information into mine planning, it would avoid feeding the plant with a material above the cut-off grade but with several contaminants which impact on the flotation recovery, leading to a reduction in the metallurgical recovery and in the concentrate grade. Ultimately, this would avoid producing a concentrate which would not generate a revenue, as it was planned to do, so affecting the cash flow for that specific period of time. Following the same reasoning, it is possible to feed a material below the cutoff, but with low contaminant grades, which can generate a product within the desirable specifications. Basically, ore and waste classification, supported by geometallurgical studies, goes beyond the simple cut-off grade definition. Additionally, geometallurgical models provide the information needed to adjust the plant as the ore characteristics change. Knowing beforehand that a given ore can lead to a low metallurgical recovery, it would be possible to adjust the milling factors, or flotation circuit, to mitigate the expected loss in the metallurgical recovery.
Considering the benefits in predicting the products and tailings characteristics, this study focussed on building a geometallurgical model able to forecast the mass and the metallurgical balance that will be obtained when the gold ore from two Brazilian mines is processed. The novelty of this work is the capability to forecast, at each part of the flowsheet where there is a material output, either concentrate or tailings, the mass and the metallurgical recoveries and, ultimately, the gold grade in such materials simultaneously respecting mass closure.
A challenge related to dealing with geometallurgical data is that most are non-additive (Richmond andShaw, 2009). Carrasco et al., (2008) proved that mass recovery is an additive variable, but metallurgical recovery is not, and because of this, it needs to be studied with prudence. According to Coward et al., (2009), additivity is the "property that allows the mean of some variables to be calculated by a simple linear average". The nonadditivity of an attribute restricts the use of linear averages, since it would generate biased or inconsistent results according to the studied phenomenon.
One of the most applied techniques to forecast geometallurgical variables is linear regression analysis, uni-or multivariate, which uses, as independent variables, information about in situ ore characteristics including grade, grain size distribution, or lithology, to predict variables such as ore recovery at the processing plant. Examples in geometallurgical modelling are found in MacMillan et al., (2011), Montoya et al., (2011, Fernandes and Cabral (2016), and Vieira and Costa (2016), among others. Since regression analysis provides a linear estimation, its use to forecast non-additive variables can generate results that do not ideally represent the studied phenomenon.
In view of the increasing application of machine learning techniques in several fields, and their capacity to deal with nonadditive data, it was decided to compare the results obtained by using regression analysis with the ones obtained using machine learning techniques.

Application of machine learning techniques in the mineral industry
This section presents a brief review on the application of machine learning to forecast variables in mining context. Singh and Rao (2005) used a RBF neural networks to classify particles as manganese enriched, iron enriched or alumina enriched, using as input variables the red, green and blue in the RBG color space and four Harlic's textural parameters (energy, entropy, contrast and homogeneity). The overall accuracy of the model was 88.71%. Lucay et al. (2020) developed a methodology to use a RBF neural network and a multi-layer perceptron to better model the design of the experiment's (DoE) data. First, the authors created a DoE using the frother concentration, the collector concentration and the water conductivity as input variables to forecast the froth stability. After the results of the experiment were processed, they decided to estimate (using variography and kriging) the froth stability at unsampled points which were after sampled using the Monte Carlo method. Then, the created samples using kriging were used to train a RBF neural networks and a multi-layer perceptron and the real values from the DoE were used as test set samples. Other applications of this methodology were presented by the authors to forecast the ash recovery in coal flotation and gold recovery at a plant, using other input variables. In all cases, the methodology proposed overcame the classical response surface methodology.
Lishchuk, Lund and Ghorbani (2019) tested random forest, SMO (a variation of SVR), linear regression, M5 and M5P (variation of decision tree), among other machine learning techniques to forecast six geometallurgical variables at the Leveäniemi iron ore mine. Included among them the iron metallurgical recovery. The authors concluded that the best forecast was found when techniques which used decision trees were applied to forecast non-additive variables.
Prades and Deutsch (2016) evaluated the results obtained to forecast the acid consumption, the recovery and the impurity in a copper ore processing plant, using linear and quadratic regression, ACE (alternating conditional expectations), ridge regression, random forest and gradient boosted models (GBM). According to the authors, random forest and GBM presented the best results based on R² values.
Drumond (2019) applied logistic regression, discriminant analysis, support vector machine, random forest, neural networks, k-nearest neighbors, decision tree and naïve bayes techiniques to forecast mineral particles of ore and waste in an ore-sorting equipment, using X-ray sensor readings as independent variables. The author considered that the support vector machine, k-nearest neighbors, random forest and the neural networks showed the best results.
Panda and Tripathy (2014) adjusted a neural network to forecast the grade and the metallurgical recovery of chromite in a processing plant with a gravity concentrator using the wash water flow rate, the deck tilt angle and the slurry feed rate as input variables. The network built used only one hidden layer with eleven hidden nodes and the two output variables were forecasted simultaneously. The R² obtained in the test set was 0.96 to forecast the grade and 0.99 to forecast the recovery.
Other studies related to machine learning applied to problems in ore processing, excluding geometallurgy articles, can be read in McCoy and Auret (2018). Examples of the neural networks application to forecast variables related to transportation and blasting can be seen in Franco-Sepúlveda, Del Rio-Cuervo and Pachón-Hernández (2018).
According to the authors knowledge, no geometallurgical model has been elaborated so far to forecast simultaneously the grades and the mass and metallurgical recoveries of all outputs in a plant, either concentrates or tailings. To achieve this goal, it was necessary to build several models using different machine learning techniques aiming at identifying the one which would lead to the most precise and accurate forecast and to recognize the one able to better honor the mass and the metallurgical closure of the predictions. Among all techniques described in this section, three were chosen as the most promising to be evaluated: neural networks (NN), support vector regression (SVR), and random forest (RF).

Material and methods
The software used to build all models was developed in Python ® . The scikit-learn library was used to build the SVR and the random forest models, to standardize the variables in the preprocessing step and to calculate the mean absolute error and the mean squared error. The keras library was used to build the neural network model and the statsmodels package was used to build the linear regression model. To calculate the correlations between the true values and the forecasts made, the scipy library was used.
To better comprehend the variables involved in this problem, a brief explanation of the process flowsheet will be presented. The ROM is processed initially at Plant 1, which has crushing and milling circuits, followed by a gravimetric separation and a flotation circuit. Next, the flotation concentrate is sent to Plant 2, in which the material is submitted to a calcination followed by a leaching circuit. Figure 1 illustrates the simplified flowsheet with all mass and metal output points. The variables studied are the ones represented in the green and blue boxes. The gas metallurgical recovery box is shaded as no metal is lost in the gas generated by the calcination process, so its value is zero. The leaching concentrate mass recovery is also shaded as the mass related to this part of the process is irrelevant compared to the others, and consequently, this mass recovery is rounded to zero. Finally, the shaded variables will not be modelled, leaving the remaining eight to be studied.
Planning to mimic the performance of the processing plant, bench scale tests were run using samples with different chemical and geological features. Each sample passed through each of the concentrator steps: first, the samples entered a gravimetric concentrator and its tailings were fed to the flotation. Next, the flotation concentrate was fed into the calcination process and the material remaining was sent to the leaching. In total, 37 lab tests were made allowing building a statistical model able to relate the ROM grades to the quantity and quality of the concentrate and tailings generated at the plant. Table 1 presents the descriptive statistics for the 37 samples regarding Au (g/t) and S (%) grades at ROM, and the eight metallurgical variables, divided between the two mines under study. Note that the mean gold grade at Mine A is higher than that at Mine B (11.42 against 2.38 g/t). The same applies for the S mean grade, the Mine A mean is higher (8.55 against 7.53%).
The metal flow for Mine A ore shows that (on average) 60.49% of the gold fed to the plant goes to the gravimetric concentrate, 7.36% to the flotation tailings, 30.42% to the leaching concentrate, and 1.73% to the leaching tailings. For the Mine B ore, the average numbers are: 70.67% of the gold goes to the gravimetric concentrate, 4.95% lost to the flotation tailings, 22.51% to the leaching concentrate, and 1.88% lost to the leaching tailings. Analyzing the mass fed from Mine A, on average, 5.57% goes to the gravimetric concentrate, 78.70% to the flotation tailings, 11.01% to the leaching tailings, and 2.75% to the sulphuric acid gas. For Mine B, these numbers are: 5.16% of all mass fed goes to the gravimetric concentrate, 87.32% to the flotation tailings, 6.06% to the leaching tailings, and 1.53% goes to the sulphuric acid gas.  Thus, Au (g/t) and S (%) grades, and the variable D1 were used as independent (input) variables in this study.
To build a forecast model an isotopic database is necessary, which is not the case, since only 22 of the 37 samples have information about the sample mass after the calcination process. The lack of this information prevents the calculation of the gas mass recovery and the leaching tailings mass recovery. To complete the database, it was decided to use the maximum likelihood technique (Enders, 2010), which is the imputation state of the art for missing at random (Rubin, 1976) information.
After the imputation, the next step was to transform the Au and S grades into values within the 0 to 1 range (the same used for the D1 variable), to ensure that, in the models created, a variable does not impact more than the others due to its magnitude.
Finished the preprocessing step, the imputed and standardized dataset was used to create the geometallurgical models. Four different techniques were investigated: regression analysis (Hair et al., 2009), random forest (Hastie, Tibshirani and Friedman, 2009), support vector regression (Izenman, 2008), and artificial neural networks (Haykin, 1999). Basics on these methods are presented herein.
The models made with regression analysis were evaluated according to the significance t-tests (Triola, 2008) and the residual analysis (Hair et al., 2009) was run. The models developed for the flotation and leaching tailings metallurgical recovery presented coefficients statistically equal to zero, indicating that their use for prediction purposes is discouraged. The leaching tailings mass recovery and the flotation tailings metallurgical recovery models violated the normality assumptions of the residuals, which can affect the t-test results to such a point as to invalidate them. Thus, three of the eight models developed using regression analysis are not statistically valid, and the results obtained by using this technique will not be further discussed.
The random forest algorithm using 1000 trees was used to model the eight metallurgical variables under study. To determine the minimum number of samples by leaves in the trees, values were tested ranging from 2 to 15. The correlation coefficient obtained in the out-of-bag (Hastie, Tibshirani and Friedman, 2009) was calculated for each minimum number of samples in the leaves tested, and the value which presented the higher correlation value was chosen.
The models using support vector regression were divided into two parts: first, the models were adjusted using a linear kernel and then, adjusted using a non-linear kernel (Radial Basis Function). For both cases an epsilon (∈) value equal to 0.0001 was used. The determination of the best C parameter value, in the linear case, and of the best C and gamma (Izenman, 2008) values, for the non-linear case, was made using a grid search with values ranging from 0.001 and 100 for both parameters. For each dependent variable the parameter (linear SVR), or the combination of parameters (non-linear SVR), which returned the lower mean absolute error (MAE) in the test set was chosen.

1, if the sample belongs to Mine A
(1)  Using the developed models, it is possible to predict not only the mass and metallurgical recoveries of each product or tailings, but also their grades, according to: Consequently, the gravimetric concentrate, flotation tailings, and leaching tailings grades were calculated using the mass and metallurgical recoveries related to them. However, it is not possible to calculate the leaching concentrate grade, since it was assumed that the leaching concentrate mass recovery is zero. It was possible to estimate the mentioned grades and to compare them to the real ones. Table 4 summarises the results obtained when the 5-fold cross validation was applied to the data along with the 5-fold mean for the three studied variables. The first step to create a neural network is to determine the optimisation algorithm used in its construction. The gradient descent (Bishop, 1995) and the Adam (Kingma and Ba, 2015) algorithms were tested, with the latter producing the best results. Next, the learning rate (Haykin, 1999) needs to be determined. Values between 0.00001 and 0.5 were tested and the best results were obtained with a learning rate of 0.00003. Then, the number of hidden layers and hidden nodes needed to be defined. Bearing in mind the reduced number of samples available, and the possibility of overfitting, it was decided to use no more than three hidden layers and six hidden nodes in each hidden layer. Considering all possible combinations of hidden layers and hidden nodes, the best results were found when two hidden layers with four nodes in the first layer and five nodes in the second layer were used. Finally, it was necessary to determine which activation function will be used in each hidden layer and in the output layer. The following functions were tested: linear, sigmoid, ReLU, hyperbolic tangent, and softplus. The best results were obtained when the linear function was chosen in all the layers.
The results obtained using the techniques described earlier were compared. The k-fold cross validation technique (Hastie, Tibshirani and Friedman, 2009), using k = 5, was used to check each model's forecast capacity, in data not used to build them. The techniques were evaluated considering the mean absolute error (MAE), the square root of the mean squared error (RMSE), and the Pearson correlation coefficient between the predicted and the real values. Table 2 consolidates the results presenting the mean and the standard error of the built 5-folds. To make the comparison easier, the mean of the 5-fold mean for the eight dependent variables was calculated and presented.
Analysing the mean values for each metric calculated for all variables in the test set, leads to the result that the best correlation value was obtained when random forest was used, and the best MAE and RMSE values were obtained when the neural networks technique was applied.
The good correlation values found for the gas mass recovery and leaching tailings mass recovery were not impacted by the imputation method used, once when correlations were recalculated considering only the real samples, the test set mean ± standard error found was 0.8113±0.038 for the gas mass recovery and 0.7594±0.1568 for leaching tailings mass recovery, values close to the ones obtained when all data (real + imputed) were used.
Considering the neural networks results and thinking that the flotation and leaching tailings, and the gas mass recoveries, together, represent on average 93% of all mass from Mine A, allows one to conclude that correlations above 0.80 for these variables indicates that the models are good to forecast the mass balance. For Mine B, this percent is even higher, 95%. Considering that, on average for Mine A, 90% of all metal goes to the gravimetric and the leaching concentrates, it is possible to consider that the variables with the highest impact on the metallurgical balance, presented models with good results. For Mine B this percentage is 94%. Thus, the leaching and flotation tailings metallurgical recoveries, which are related to models with a poor predictive capacity, are the variables with the smallest metal outputs.
For each of the built 5-folds, the percentage of samples in which the closure error was below +/-1% was also evaluated. Next, the average percentage for all 5 folds was calculated. The closure results are in Table 3. Note that the neural networks presented the highest percentage for mass and metallurgical closures. All other techniques presented poor metallurgical closure results.

Conclusions
The forecasts obtained by the geometallurgical models presented herein can be used in several ways. The grade information of the flotation or leaching tailings makes it possible for the plant operators to decide the tailings destination. If the tailings grade is above the cut-off grade adopted to feed the plant, it is possible, for example, to store it in piles ready to re-feed it, opening up the possibility to better use the metal content and increase the operation profit. If the grade is below the cut-off, the material must be sent to the dam with the conviction that it will not contain a metal quantity that should belong to the saleable product.
Additionally, this study also provides the means to more precisely sizing the tailings mass sent to the pond (dam) by using the flotation and leaching tailings mass recoveries information. The environmental impact generated by the tailings can be determined even before the tailings are generated, making it possible to better plan its disposal. Moreover, it is possible to know the percentage of all metal feeds such that their destination to the flotation and leaching tailings, and to the concentrate, make it possible to study alternative processing routes and different dosing reagents, aimed at increasing the metallurgical recovery.
Another gain is related to the gas mass that is sent to the sulphuric acid plant. Knowing that this gas is sold to other companies, it is important to know beforehand the profit that will be generated by selling this material. When the gravimetric concentrate grade and mass recovery are known, it is also possible to predict the operating profit, making the predicted cashflow more adherent to the reality. After presenting all model benefits, it is necessary to discuss their limitations.
The first one is related to the model boundary conditions. It is important to apply the model in blocks (or piles) which kept the same grade range and the same lithologies used to build the neural networks. The second limitation is associated to the relation between the bench lab tests and the plant results. The bench tests led to higher metallurgical recovery than the plant, a fact related to the higher selectivity of the equipment used at laboratory scale. But the company was not able to quantify this difference at the moment. It is known the need to find an up-scaling factor to make the lab results comparable to the plant actual response. The last limitation is related to the number of samples used to build the model. Collecting and inserting more samples in the study will reduce the MAE and RMSE values found, making the model's predicitions more adherent to the reality.
The results indicated that, in terms of MAE and RMSE, the neural networks technique stood out when compared with the other techniques applied. The mass and metallurgical closure results also indicate that this technique presents adequate re-sults to be used in actual situations. Even though, it is important to note that this superiority is related to the specific data studied, being necessary to check its validity when data from other deposits are used.
The developed neural network model can be used to build 3D geometallurgical block models using the Au and S predicted at each block, and the mine which the ore came from. The same applies to piles built to feed the plant, making it possible to forecast the metallurgical ore behaviour before Table 4 -5-fold cross validation results for grades forecast.
Note that all metrics analysed presented the best results for the neural networks prediction models.