###### Abstract  
In the present day, the health of the populace is significantly jeopardized by the presence of contaminated water, and the majority of the population is unaware of the distinction between safe and unsafe water consumption. Agricultural, industrial, and other human-induced activities are causing a significant decline in the availability of drinking water. Consequently, the issue of ensuring the safety of ingesting water is becoming increasingly prevalent. People should be aware of the purity of the water and the locations where it can be used in order to resolve this situation. There are numerous IoT-based system architectures that are capable of monitoring water parameters; however, the majority of these architectures do not allow for real-time water quality prediction or visualization. In order to achieve this, we suggest a wireless framework that is based on the Internet of Things (IoT). The sensors are able to capture water parameters and transmit the data to the cloud, where a machine learning (ML) model operates to classify the water quality. After that, Crafana enables us to effortlessly visualize the real-time data and predictions from any location. We employed a multi-class dataset from China for the model's construction. GridSearchCV was implemented to identify the optimal parameters for model optimization. The proposed model is a combination of the Random Forest (RF), Extreme Gradient Boosting (XGB), and Histogram Gradient Boosting (HGB) models. The accuracy of the model for the China dataset was 99.80%. To assess the robustness of the proposed model, we acquired a new dataset from the Bangladesh Water Development Board (BWDB) and used it to test the proposed model. The model's accuracy for this dataset was 99.72%. In summary, the proposed wireless IoT framework enables individuals to effortlessly monitor the purity of water and view its parameters from any location. water quality index; machine learning; key water parameters; ensemble technique; hypertuning +
Footnote †: journal: MedicalThe IoT employs networked sensors and other devices to collect and transmit data from the environment to digital platforms. This allows for automated water quality monitoring with the ability to access real-time data remotely, resulting in a significant reduction in time and cost. Using cloud storage and resource management systems, we can easily retrieve data and ensure the confidentiality of the data. By utilizing ML techniques [10], it is possible to analyze the data collected from IoT sensors in order to detect complex patterns. ML algorithms have the capability to predict future water quality by analyzing the current conditions and historical data. This advanced technology aids in identifying potential issues before they become more serious. In order to fully utilize the potential of these technologies, it is vital to establish a comprehensive framework for classifying water quality using the IoT and ML. This framework should include trustworthy IoT sensors, optimized data processing and analysis techniques, and ML algorithms that can deliver accurate and reliable water quality predictions. Developing a water quality indexing (WQI) model by refining the best learning algorithms might be beneficial for predicting water quality. Datasets for determining water quality can contain many parameters, but only a few parameters can determine WQI [11]. Therefore, to optimize the use of learning methods, only useful parameters should be chosen using different feature selection methods. Determining the quality of the water is very important because more than two billion people are at risk of consuming water contaminated with harmful microorganisms and toxic substances according to the World Health Organization [12]. Drinking water from various sources is estimated to cause around 829,000 deaths annually due to water-related illnesses. Numerous cutting-edge studies [13; 14; 15; 16] developed ML and deep learning models for assessing surface water quality.