Introduction: Continuous monitoring in important water sources such as the Cauca River, the second largest in Colombia, is essential for environmental management. However, the extended measurement times associated with laboratory analyses limit real-time decision-making. Machine learning-based virtual sensors are proposed as early indicators of emergence of critical pollutants, overcoming the limitations of traditional laboratory methods.
Methods: This study analyzes a historical database (1990–2025) from 19 sampling stations along the Cauca River and includes more than 50 physicochemical, microbiological, and biological parameters. Physical measurements taken from sensors in situ (pH, temperature, turbidity, electrical conductivity, and dissolved oxygen) were selected as predictor variables, while variables measured in laboratories were selected as targets. Data was normalized using RobustScaler to reduce the effects of outliers, and mean imputation was used to handle missing values. Four machine learning models were trained, AdaBoost, XGBoost, Multilayer Perceptron and Random Forest, and results were compared using 5-fold cross-validation, while hyperparameter optimization was implemented using Random Search.
Results: Algorithms captured the nonlinear relationships within the river system. AdaBoost presents the highest coefficients of determination for total cadmium (R² of 0.801) and total phosphorus (R² = 0.746), while Random Forest exhibits a good performance for total iron (R² = 0.683) and calcium hardness (R² = 0.639).
Conclusions: By combining robust data scaling with ensemble learning models, a stable virtual sensor for water quality monitoring was developed, an approach that enhances the capabilities of existing physical sensor networks by transforming them into intelligent monitoring stations with the potential of estimating pollutant and heavy metal concentrations in real time. Early detection of phosphorus, cadmium, and iron may streamline the implementation of mitigation strategies, reducing their potential impact on the ecosystem and the health of riverside communities. Therefore, this machine learning-based virtual sensor contributes to establishing an efficient environmental early-warning system.