# Applying Machine Learning to DEEC Protocol: Improved Cluster Formation in Wireless Sensor Networks
## 3 Implementation
### Dee-Km
#### 3.3.3 Performance Results  
The experimental results showed that the K-Means based approach significantly improved several key performance metrics compared with the original DEEC protocol. Energy management was also enhanced. The protocol achieved a slightly lower energy consumption rate per round and a much higher amount of residual energy remaining in the network at the end of the simulation. The adaptive clustering mechanism resulted in an average of 6.3 clusters, each with about 8.7 nodes, which helped distribute the workload more evenly and prevented premature energy depletion in any single area. Table 6 shows that the proposed protocols significantly outperformed the original DEEC in several critical aspects.  
As shown in Figure 4, the node death curve was more gradual and the network remained operational for longer. Packet delivery rates were higher and more consistent, and energy depletion was more uniform across nodes. The spatial distribution of clusters was also improved, leading to better coverage and organisation throughout the network's lifetime.  
Regarding simulation results, the time until the first node died was extended by 6.7% and the network maintained 70% of its nodes until round 1204, indicating better stability and longevity. Most notably, the total number of data packets delivered more than doubled, reflecting a 110.7% increase in communication throughput and reliability, as shown in Table 7.  
The motivation for introducing K-NN and K-Means into the DEEC protocol arose from several key limitations of the original DEEC approach. First, DEEC's cluster head (CH) selection is primarily based on residual energy and follows a probabilistic, largely static process. This means it does not dynamically adapt to changes in node distribution, energy heterogeneity, or network topology. The result of implementation can lead to unbalanced cluster formation, uneven energy consumption, and premature node failures, especially in large-scale or dynamic networks. Additionally, DEEC does not explicitly consider the spatial proximity of nodes when forming clusters, which can increase communication costs and reduce network efficiency. The modified approaches for DEEC address these shortcomings: K-NN enables adaptive, proximity-aware cluster formation that responds to local network changes, while K-Means ensures spatially balanced clusters and more even workload distribution. Together, these ML-based enhancements make the protocol more robust, energy-efficient, and better suited for heterogeneous and evolving WSN environments.  
\begin{table}
\begin{tabular}{c c c} \hline
**No** & **Metric** & **Original DEEC** \\ \hline
1 & Total Nodes & 100 \\
2 & Initial Energy per Node & 0.5 J \\
3 & First Node Death at Round & 1078 \\
4 & Last Node Death at Round & 1276 \\
5 & Total Packets Sent to BS & 12,607 \\
6 & Remaining Network Energy & 0.0951 J \\
7 & Energy Consumption Rate & 0.024952 J / round \\
8 & Average Number of Clusters & 6.30 \\
9 & Network Lifetime (70\% alive) & 1155 rounds \\ \hline \end{tabular}
\end{table}
Table 6: DEEC-KM protocol simulation results summary.  
\begin{table}
\begin{tabular}{c c c c} \hline
**No** & **Metric** & **Original DEEC** & **DEEC-KM** & **Improvement** \\ \hline
1 & First Node Death (FND) & 1010 rounds & 1078 rounds & 6.7\% \\
2 & Total Packet Delivery & 5982 packets & 12,607 packets & 110.7\% \\
3 & Average Cluster Formation & 10 (static) & 6.30 (dynamic) & Enhanced efficiency \\
4 & Network Stability Period & Not quantified & 1204 rounds & Enhanced \\
5 & Energy Consumption Rate & 0.024997 J / round & 0.024952 J / round & 0.18\% \\ \hline \end{tabular}
\end{table}
Table 7: Comparative analysis of DEEC and DEEC-KM protocols.