## 3 Tiny Federated Nearest Neighbor  
This paper proposes federated nearest neighbor (TFNN), an approach which aims to provide an energy-efficient FL solution for sensor networks, taking into account the memory, processing, and communication constraints of IoT nodes. Instead of forwarding raw sensory data to a central base-station for processing, the network utilizes in-network processing to analyze data and develop models locally. This approach proposes significantly reducing the energy consumed by minimizing direct transmissions of raw sensory data to the base-station. TFNN leverages the LEACH protocol, enabling IoT devices to autonomously form clusters and elect cluster heads. Each cluster head then aggregates the sensory data from its associated nodes to update the model. Additionally, this decentralized approach means that the base-station is not required to manage the network or monitor the status of active and inactive IoT nodes directly. While kNN can work with both types of data, its performance is generally more predictable and effective with IID data. With non-IID data, careful consideration of data characteristics and distance metrics is essential to optimize its performance [57]. Algorithm 3 outlines TFNN approach, wherein IoT devices collaboratively transform their local data into a unified global event recognition framework through a decision fusion process. Each IoT device in the network retains training patterns and executes kNN locally on the test (event) patterns, as detailed in Algorithm 2. In this local context, the class label for the event (test) pattern \(x\) is established through majority voting among the IoT devices. When an event is detected, each IoT device independently executes kNN, thereby contributing to the collective classification process. Each IoT node will find the \(k^{th}\) closest training pattern to the event pattern and then perform majority voting to find the winning class label. Let \(f_{i}(x)\) be the class label of the \(i^{th}\) neighbor of \(x\). The identity function \(\delta(c_{f_{i}})\) output is 1 if a match is found \(\langle f_{i}\ (x)=c\rangle\), and otherwise 0. The function \(g(c)=\sum_{i}\delta(c,f_{i}(x))\) is used to count the neighbors with label \(c\). The winning class will be the class label receiving the majority of votes (i.e., \(50\%+\epsilon\)) using \(c^{*}=argmax_{c}g(c)\). As a result, each IoT node will classify the event pattern and find the best matching class label from the training set. In this local context, the class label for the event (test) pattern \(x\) is determined through majority voting among the IoT devices. When an event is detected, each IoT device independently executes kNN, contributing to the overall classification process. Each IoT device identifies the \(K\)th closest training pattern to the event pattern and then performs majority voting to establish the winning class label. Next, majority voting is conducted within each cluster to aggregate the local class label results from all IoT devices belonging to that cluster. Each IoT device transmits its winning class label to the cluster head, which then processes the collected labels through majority voting to update the voting model, as described earlier. Finally, each cluster head communicates its aggregated model (the results from the cluster) to the base-station. The base-station performs a final model (\(\hat{g}_{f}\)) update by applying majority voting to the received models from the cluster heads, resulting in the winning class label for the event pattern \(P_{t}\). TFNN can benefit from utilizing a blockchain-based federated learning framework (FedCFB) to improve security, particularly data integrity and trustworthiness [58]. Traditional FL faces challenges like model poisoning, data heterogeneity, and free-riding behavior, which undermine its reliability. FedCFB addresses these by integrating blockchain technology to ensure tamper-proof storage of data and models, along with smart contracts for secure and automated processes.