# Prediction of Total Petroleum Hydrocarbons and Heavy Metals in Acid Tars Using Machine Learning
## 3 Machine Learning Algorithm Description  
During the investigation, monitoring, and remediation of a site polluted with acid tars, the concentration of pollutants is an important factor in identifying the pollution level and spatial distribution [28]. Determining the treatment/elimination technologies of acid tars from the refineries and evaluating their feasibility was done by laboratory testing. Among the most important indicators of an acid tar sample and after applying the required treatment test, this paper focuses on the following: pH, TPH content, and heavy metals contents (Pb, Cd, Cu, Cr, Ni) and As. A software program was developed to estimate the properties of new acid tar samples without measuring them. It was written in Python 3.11.6, using PyCharm Community Edition as IDE [41]. The developed software uses machine learning techniques to estimate the following eight properties of acid tars:  
* Initial pH of the acid tar sample;
* Total Petroleum Hydrocarbons (TPH) of the acid tar;
* Initial lead concentration of the acid tar (mg/kg);
* Initial cadmium concentration of the acid tar (mg/kg);
* Initial copper concentration of the acid tar (mg/kg);
* Initial chrome concentration of the acid tar (mg/kg);
* Initial nickel concentration of the acid tar (mg/kg);
* Initial arsenic concentration of the acid tar (mg/kg). These eight properties are the dependent or response variables. The following properties are the predictor variables:  
* The X- and Y-coordinates of the places where the soil samples were extracted. The stereographic 70 projection was used to represent those coordinates. * The tar samples extraction depth (cm). A total of 82 samples were extracted either from 5 cm depth or 30 cm depth (41 samples each for the two depths of 5 and 30 cm). The algorithm used for the developed program was taken from [42]. It is the preferred method of the authors because it is simple to understand and implement. The chosen method has the following steps:  
* Obtaining the data. * Data visualization. * Preparing the data for the machine learning model. * Selecting and training a machine learning model. * Hyperparameter tuning. * Evaluating the model on the test set. Obtaining the data. This step involves obtaining the available data, which will be used for training the chosen algorithm. The data set contains 82 samples with the predictor and response variables mentioned above. Each row represents an acid tar sample, and each column represents one of the variables involved in this machine-learning project. The main statistical characteristics of every acid tar sample property are presented in Table 1. \begin{table}
\begin{tabular}{c c c c c} \hline \hline
**Property** & **Minimum Value** & **Maximum Value** & **Mean Value** & **Standard Deviation** \\ \hline X-coordinate & 385,380.6 & 385,533.507 & 385,451.47 & 45.96 \\ Y-coordinate & 581,167.73 & 581,268.73 & 581,213.77 & 30.42 \\ Sample depth & 5 & 30 & 17.5 & 12.58 \\ Initial pH & 0.2 & 5.28 & 1.12 & 1.12 \\ TPH & 48,333 & 477,062 & 169,685.37 & 80,568.12 \\ Initial Pb concentration & 42 & 2235 & 343.07 & 372.91 \\ \hline \hline \end{tabular}
\end{table} 
Table 1: Main statistical characteristics of every acid tar sample property. Figure 1 shows that the samples were taken from a well-defined, enclosed area. This means that there is a very high chance for the data to be consistent, and it will be helpful for future versions of the program to obtain training data from inside the area.