KNN-MMD: Cross Domain Wi-Fi Sensing Based on Local Distribution Alignment

Zijian Zhao, Zhijie Cai, Tingwei Chen, Xiaoyang Li, Hang Li, Guangxu Zhu

Abstract

Wireless sensing has recently found widespread applications in diverse environments, including homes, offices, and public spaces. By analyzing patterns in channel state information (CSI), it is possible to infer human actions for tasks such as person identification, gesture recognition, and fall detection. However, CSI is highly sensitive to environmental changes, where even minor alterations can significantly distort the CSI patterns. This sensitivity often leads to performance degradation or outright failure when applying wireless sensing models trained in one environment to another. To address this challenge, Domain Alignment (DAL) has been widely adopted for cross-domain classification tasks, as it focuses on aligning the global distributions of the source and target domains in feature space. Despite its popularity, DAL often neglects inter-category relationships, which can lead to misalignment between categories across domains, even when global alignment is achieved. To overcome these limitations, we propose K-Nearest Neighbors Maximum Mean Discrepancy (KNN-MMD), a novel few-shot method for cross-domain wireless sensing. Our approach begins by constructing a help set using KNN from the target domain, enabling local alignment between the source and target domains within each category using MMD. Additionally, we address a key instability issue commonly observed in cross-domain methods, where model performance fluctuates sharply between epochs. Further, most existing methods struggle to determine an optimal stopping point during training due to the absence of labeled data from the target domain. Our method resolves this by excluding the support set from the target domain during training and employing it as a validation set to determine the stopping criterion.

Introduction

Wireless sensing leverages Channel State Information (CSI) from Wi-Fi signals to detect human activities—such as gestures, falls, or identity—without the need for intrusive cameras. While promising, the practical deployment of these systems is hindered by the extreme sensitivity of CSI to environmental factors. A model trained to recognize a specific gesture in one room often fails when deployed in a different environment or used by a different person. This phenomenon, known as domain shift, necessitates robust adaptation techniques to make Wi-Fi sensing commercially viable.

The Problem of Domain Shift

The core challenge in cross-domain Wi-Fi sensing is that the feature space is influenced not just by the action being performed, but also by the environment and the individual. As shown in Figure 1, CSI features tend to cluster by both action and person, creating a complex distribution that is difficult to generalize across new "target" domains.

UMAP visualization of CSI features, showing clustering by both action and person.

Traditional solutions utilize Domain Alignment Learning (DAL) to map source and target data into a shared feature space. However, most DAL methods perform global alignment, which treats the entire dataset as a single distribution. This often leads to category misalignment, where a "wave" in the source domain might be incorrectly aligned with a "clap" in the target domain, destroying the model's classification accuracy.

The KNN-MMD Framework

To address the shortcomings of global alignment, we propose KNN-MMD, a few-shot learning framework that shifts the focus to local distribution alignment.

Comparison between traditional global alignment and the proposed local alignment method.

The framework introduces three primary innovations:

  1. Local Category Alignment: Instead of aligning the entire data "blob," KNN-MMD aligns the source and target domains category by category. This ensures that the feature representation for a specific action (e.g., "falling") in the source domain is mapped specifically to the same action in the target domain.
  2. The "Help Set" via KNN: Since target data is largely unlabeled, we use K-Nearest Neighbors (KNN) on UMAP-reduced features to assign pseudo-labels. We then select the most confident samples (the top $p\%$) to form a "Help Set" for local alignment via Maximum Mean Discrepancy (MMD).
  3. Adaptive Early Stopping: Few-shot models are notoriously unstable. We solve this by intentionally excluding the few labeled target samples (the "support set") from the training loss. This allows the support set to serve as a valid validation set, enabling a patience-based early stopping mechanism that stabilizes performance.

Evaluation and Results

We evaluated KNN-MMD across four tasks using three datasets: WiGesture, WiFall (a new dataset featuring various fall types), and WiDar3.0. In one-shot scenarios (only one labeled sample per class in the new environment), KNN-MMD achieved significant performance gains over state-of-the-art methods:

  • Gesture Recognition: 93.26% accuracy.
  • Person Identification: 81.84% accuracy.
  • Fall Detection: 77.62% accuracy.
  • Action Recognition: 75.30% accuracy.

Compared to standard ResNet18 models, which often drop to ~40% accuracy in zero-shot cross-domain tasks, KNN-MMD maintains high performance and exhibits much smoother convergence curves than traditional Siamese or MK-MMD networks.

Discussion and Future Work

While KNN-MMD effectively addresses domain shift, challenges remain regarding class imbalance in the pseudo-labeled help set. Future research will explore extending local alignment principles to regression tasks, such as respiration rate estimation, and integrating zero-shot learning techniques to further reduce deployment overhead.

Summary updated

Abstract

Wireless sensing has recently found widespread applications in diverse environments, including homes, offices, and public spaces. By analyzing patterns in channel state information (CSI), it is possible to infer human actions for tasks such as person identification, gesture recognition, and fall detection. However, CSI is highly sensitive to environmental changes, where even minor alterations can significantly distort the CSI patterns. This sensitivity often leads to performance degradation or outright failure when applying wireless sensing models trained in one environment to another. To address this challenge, Domain Alignment (DAL) has been widely adopted for cross-domain classification tasks, as it focuses on aligning the global distributions of the source and target domains in feature space. Despite its popularity, DAL often neglects inter-category relationships, which can lead to misalignment between categories across domains, even when global alignment is achieved. To overcome these limitations, we propose K-Nearest Neighbors Maximum Mean Discrepancy (KNN-MMD), a novel few-shot method for cross-domain wireless sensing. Our approach begins by constructing a help set using KNN from the target domain, enabling local alignment between the source and target domains within each category using MMD. Additionally, we address a key instability issue commonly observed in cross-domain methods, where model performance fluctuates sharply between epochs. Further, most existing methods struggle to determine an optimal stopping point during training due to the absence of labeled data from the target domain. Our method resolves this by excluding the support set from the target domain during training and employing it as a validation set to determine the stopping criterion.
BibTeX
@article{zhao2025knn,
  author = {Zijian Zhao and Zhijie Cai and Tingwei Chen and Xiaoyang Li and Hang Li and Guangxu Zhu},
  title = {{KNN-MMD: Cross Domain Wi-Fi Sensing Based on Local Distribution Alignment}},
  journal = {IEEE Transactions on Mobile Computing},
  year = {2025},
  url = {https://openreview.net/forum?id=qxLbiSemR3},
}
Figure