## 2 Related Research
### Machine Learning-Based K-Means Clustering Protocols for WSN  
#### 2.2.1 Residual Energy  
In CH selection, residual energy plays a crucial role in extending the network lifespan and enhancing performance, as selecting a CH with higher energy among cluster members optimizes these factors. In Refs. [8; 9], improvements of the conventional LEACH protocol have been studied, LEACH-B and I-LEACH, respectively, to achieve near-optimal CH counts by considering the residual energy, neighboring node count, and distance to the base station (BS) during cluster formation. These extend the network lifespan more effectively than the original LEACH protocol, which used only a preset threshold function. In the LEACH-B protocol [8], nodes are aware of only their own position and the base station (BS) location, not other nodes. If the number of CHs falls below a specified threshold, additional nodes with sufficient energy become CHs, while low-energy CHs are removed, ensuring a consistent number of CHs. LEACH-B improves upon the original LEACH by extending the network lifespan through this uniform CH count. Meanwhile, the I-LEACH protocol further enhances clustering by selecting CHs based on residual energy, node location, and the number of neighbors, considering the optimal cluster count \(K_{opt}\), which improves network efficiency and longevity. The I-LEACH algorithm [9], like many clustering protocols, operates in three stages: CH selection, cluster formation, and data transmission. Unlike the original LEACH protocol, which selects CHs based solely on a preset threshold, I-LEACH incorporates additional factors--such as residual energy, the number of neighboring nodes, and the distance to the base station (BS)--to improve the network lifespan. In CH selection, each node generates a random number and is selected as a CH if this number is below the updated threshold. \[K_{opt}=\ \frac{\sqrt{N}}{\sqrt{2\pi}}\times\frac{\sqrt{\epsilon_{fs}}}{\sqrt{ \epsilon_{mp}}}\times\frac{M}{d_{to\_BS}^{2}} \tag{2}\]  
where \(K_{opt}\) is the optimal cluster number in the network and \(N\) is total number of nodes in the network. The variables \(\epsilon_{fs}\) and \(\epsilon_{mp}\) are, respectively, a free-space model energy constant and a multipath model constant. \(M\) represents the area or field dimension where the sensor nodes are deployed, and \(d_{to\_BS}\) is the average distance of the nodes to the BS. Thus, Equation (2) calculates the optimal number of clusters by balancing area coverage and energy efficiency. It divides the network area evenly and considers energy consumption patterns, accounting for both short- and long-distance transmission costs. By adjusting the number of clusters based on the node density, area size, and distance to the base station, it aims to extend the network lifespan and improve energy efficiency. The Improved-LEACH protocol is a clustering routing method that selects cluster heads (CHs) based on distance within the network. In this modified version, proposed by the authors in [10], CH selection considers two key parameters: the residual energy of each node and its distance to the base station (BS). In the original LEACH protocol, Equation (1) is used to elect the CH without taking into account the node's residual energy. Consequently, a node with low residual energy could still be chosen as a CH, which might lead to premature energy exhaust and reduced network lifespan. To address this, research in [10] proposed a modified threshold equation:  
\[T(n)_{new}=T(n)\times\frac{E_{current}}{E_{max}} \tag{3}\]  
where \(E_{max}\) represents the maximum (initial) energy of the node and \(E_{current}\) is the residual energy of each node. This adjustment in the threshold value (between 0 and 1) means that a value closer to 1 indicates a higher likelihood of CH selection, while a value nearer to 0 reduces the chances. The threshold for residual energy is adjusted by multiplying the Equation (1) value by the node's residual energy ratio.