# Applying Machine Learning to DEEC Protocol: Improved Cluster Formation in Wireless Sensor Networks
## 4 Discussion  
Clustering is a fundamental technique in Wireless Sensor Networks (WSNs) used to enhance energy efficiency and prolong network lifetimes. The Distributed Energy-Efficient Clustering (DEEC) protocol is a well-known approach that selects cluster heads (CHs) based on residual energy. This study compares the original DEEC with two enhanced variants: DEEC-K-NN (using K-Nearest Neighbours for CH selection) and DEEC-KM (using K-Means clustering for CH selection). The discussion is based on key performance metrics: network lifetime, energy consumption, packet delivery, and clustering efficiency. For network lifetime in the original DEEC, the first node died at round 1010, indicating  
Figure 4: DEEC-KM protocol simulation results. a moderate network lifetime. The protocol maintains a fixed number of clusters, which may not adapt well to changing network conditions as nodes die. In DEEC-K-NN, the first node died later (1131 rounds), and the last node died at round 1400, significantly improving network stability and longevity. The adaptive cluster count allows for better energy balancing as the network evolves. In DEEC-KM, the first node died at round 1078, and 70% of nodes remained alive until round 1204, outperforming both the original and K-NN variants regarding stable network operation. Both K-NN and K-Means clustering extended the stable period of the network, with K-Means providing the longest period with 70% of nodes alive. Regarding packet delivery, the original DEEC delivered 5982 packets to the base station, reflecting the baseline performance. DEEC-K-NN nearly doubled the packet delivery (11,865 packets), indicating more efficient data aggregation and transmission due to better cluster formation. DEEC-KM achieved the highest packet delivery (12,607 packets), suggesting that spatially balanced clusters further optimise communication paths and reduce energy waste. Both advanced clustering methods significantly improved throughput, with K-Means offering the best performance. For energy efficiency, the original DEEC consumed energy at a rate of 0.024997 J/round, with almost all energy depleted by the end of the simulation. DEEC-K-NN showed a similar energy consumption rate (0.025018 J/round) but with a slightly negative remaining energy, indicating some nodes may have died abruptly. In DEEC-K-Means, there was a slightly lower energy consumption rate (0.024952 J/round) and the highest remaining energy (0.0951 J), indicating more balanced and efficient energy usage. K-Means clustering not only conserves more energy but also distributes it more evenly, reducing the risk of early node death. For clustering efficiency, the original DEEC used a fixed number of clusters (10), which may not be optimal as network topology changes. DEEC-K-NN adapted the number of clusters (average of 5.93), leading to more efficient cluster sizes and better energy distribution. DEEC-KM also adapted the number of clusters (average of 6.30) and achieved a balanced average cluster size (8.66 nodes), which is ideal for load balancing and minimising intra-cluster communication costs. Adaptive clustering (K-NN and K-Means) is superior to fixed clustering, with K-Means providing the most balanced cluster sizes. Although the simulation results demonstrate significant improvements in network lifetime, energy efficiency, and packet delivery, it is important to acknowledge that these results were obtained under idealised conditions. Several non-ideal factors may influence the effectiveness of the proposed algorithms: - Node Mobility: In many real-world applications, sensor nodes may be mobile (e.g., attached to vehicles, animals, or moving equipment). Mobility can lead to frequent changes in network topology, causing cluster memberships and optimal cluster head assignments to change dynamically. The current versions of DEEC-K-NN and DEEC-K-Means are designed for static networks; thus, their performance may degrade in highly dynamic environments.