# Optimizing Boleaching for Printed Circuit Board Copper Recovery: An AI-Driven RGB-Based Approach
## 2 Materials and Methods
### Experimental Data Acquisition  
A comprehensive range of datasets was collected from real-time sensor data to develop and evaluate nine machine learning models for predicting copper recovery. These datasets were systematically gathered to ensure diversity and representativeness of the operational conditions. Emphasis was placed on data quality and consistency to facilitate accurate model training, cross-validation, and performance evaluation. The model development pipeline comprised several key steps:  
Data Preprocessing: The dataset underwent preprocessing to handle missing values using median imputation. Feature normalization was performed using min-max scaling to ensure all features had comparable ranges, preventing bias due to scale differences across variables. Feature Engineering: Additional features were derived to improve model performance, including color intensity ratios and interaction terms extracted from the RGB sensor data. These engineered features aimed to capture more complex patterns in the data. Model Training: The dataset was split into training (70%) and testing (30%) subsets. A variety of regression models were evaluated, including linear regression, decision tree regression, random forest regression, polynomial regression, multilayer perceptron (MLP), support vector regression (SVR), gradient boosting regression, XGBoost, and AdaBoost. Model Evaluation: Model performance was assessed using several metrics, including root mean squared error (RMSE), mean absolute error (MAE), R\({}^{2}\) (coefficient of determination), and adjusted R\({}^{2}\). These metrics provided insights into the accuracy and robustness of each model. K-fold Cross-Validation: To ensure reliable performance and mitigate overfitting, K-fold cross-validation was applied. This technique, which partitions the dataset into k subsets, helps validate the model and estimate its performance. In each iteration, one subset is used as validation data while the remaining subsets are used for training. The mean performance across all iterations provides an assessment of the model's accuracy. Common k-values are 5, 10, or 20. For our study, the training-to-testing set ratio was 70% to 30%. To create each dataset, 25 bioleaching experiments were conducted to establish a correlation between the colors of Fe (II)/Fe (III) and their concentrations. Each experiment utilized a prototype plant column filled with 16 g of shredded cables and 10 g of a 3D-printed filler, combined with 1.3 L of Fe (III) solution produced by microorganisms. Throughout the experiments, multiple samples were collected to monitor Fe (II)/Fe (III) levels and to correlate ion concentrations with the solution color detected by the plant's smart color sensor and an onsite pH sensor. The solution samples were then analyzed for Fe (III) and Cu (II) concentrations, following the methodology outlined in [10]. Table 1 presents the measured concentrations of Fe (III) and Cu (II) ions obtained during the electrolysis stage of the experiment. After data collection, the data were formatted into a structure compatible with machine learning algorithms. The preprocessing steps included cleaning the data, addressing missing values (less than 5%) using median imputation, and normalizing the variables to a 0-1 scale through min-max scaling. Data visualization and correlation analyses revealed key relationships between RGB values, pH, and copper concentration (Cu) during the bioleaching process. The correlation matrix in Figure 3 shows a negative correlation between the red component (C1R1) and Cu concentration (\(-0.44\)), indicating that higher C1R1 values correspond to lower Cu concentrations. Conversely, moderate positive correlations were observed between the green component (C1G1) and pH (pH1) with Cu concentration (0.44 and 0.36, respectively), suggesting that increases in these parameters are associated with higher Cu levels.