## 2 Materials and Methods
### Methodology  
The primary objective of this work is to develop algorithms for solving regression and classification tasks. The regression task focuses on predicting numerical target features that serve as indicators of water quality after treatment. A separate model is trained for each feature. The pipeline for model selection and training consists of the following components:  
* Data processing (encoding and scaling of features). * Randomized cross-validation of selected models to find the optimal value of the chosen metric. * Model evaluation, including adequacy testing, assessment on a test set using a set of metrics, and evaluation of feature importance using SHAP values. The Shapley values are calculated using Formula (1), as follows:  
\[\Phi_{i}(p)=\sum_{S\in N/\{i\}}\frac{|S|!(n-|S|-1)!}{n!}(p(S\cup\{i\})-p(S)), \tag{1}\]  
where \(n\) represents the number of features in the model, \(S\) is a subset of features that does not include feature \(i\), \(|S|\) --denotes the number of features in subset \(S\), \(p(S)\) is the value \begin{table}
\begin{tabular}{c c} \hline \hline
**Parameter** & **Values** \\ \hline Fill time [min] & 15 \\ Idle time [min] & 5 \\ Aeration time [min] & 210 \\ Mixing time [min] & 210 \\ Settling time [min] & 30 \\ Decanting time [min] & 10 \\ Hydraulic retention time (HRT) [h] & 8 \\ Mixed liquor volatile suspended solids (MLVSS) [g/L] & 4.5 \\ Dissolved oxygen (aeration stage) [mg/L] & 3.5 \\ Dissolved oxygen (anoxic stage) [mg/L] & 0.2 \\ External carbon source (BOD\({}_{5}\) eq.) [mgO\({}_{2}\)/L] & 150 \\ Temperature (t) [\({}^{\circ}\)C] & 15–30 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Lab-scale bioreactor operation parameters. Figure 2: The data collection scheme for the laboratory setup. obtained from subset \(S\), and \((p(S\cup\{i\})\) is the value obtained from subset \(S\) that includes feature \(i\). In addressing the regression task, the following machine learning models were employed: DecisionTreeRegressor, LinearRegression, ElasticNet, Lasso Regression, Ridge Regression, XGBoost, LightGBM, and CatBoost. The defining metric for cross-validation was the Symmetric Mean Absolute Percentage Error (SMAPE), which is determined using Formula (2). \[SMAPE=\frac{100\%}{n}\sum_{t=1}^{n}\frac{|F_{t}-A_{t}|}{(|A_{t}|+|F_{t}|)/2}, \tag{2}\]  
where \(n\) is the number of observations, \(F_{t}\) is the predicted value, and \(A_{t}\) is the actual value. After selecting significant features, re-cross-validation is performed. When the values of the target metric increase, a new model with the selected hyperparameters is accepted. Subsequently, the model metrics are evaluated on the test set. For the regression task, the metrics R\({}^{2}\), RMSE, and MAE are assessed (as defined in Formulas (3)-(5), respectively). \[R^{2}=1-\frac{D[y|x]}{D[y]}=1-\frac{\sigma^{2}}{\sigma_{y}^{2}}=1-\frac{\sum_{ i=1}^{n}(y_{i}-\hat{y_{i}})^{2}}{\sum_{i=1}^{n}(\overline{y_{i}}-y_{i})^{2}}, \tag{3}\]  
\[RMSE=\sqrt{\frac{1}{n}\sum_{i=1}^{n}{(y_{i}-\hat{y_{i}})^{2}}}, \tag{4}\]  
\[MAE=\frac{1}{n}\sum_{i=1}^{n}{|y_{i}-\hat{y_{i}}|}, \tag{5}\]  
where \(D[y]=\sigma_{y}^{2}\) represents the variance of the random variable, \(D[y|x]=\sigma^{2}\) denotes the variance of the model error, \(n\) is the number of observations, \(y_{i}\) is the target value, \(\hat{y_{i}}\) is the predicted value, and \(\overline{y_{i}}\) is the mean value. The adequacy of the model was assessed by comparing the target metric of the model with the metric of the constant model, DummyRegressor. In addressing the classification task, the following models were considered: DecisionTreeClassifier, LogisticRegression, KNeighborsClassifier, SVC (Support Vector Classification), as well as XGBoost, LightGBM, and CatBoost. The metric employed for the evaluation was the ROC-AUC (Receiver Operating Characteristic--Area Under the Curve), which is a metric used to assess the performance of binary classifiers.