This repository is the reproducibility package for the paper “Temporal Stability on Human Activity Recognition based on Wi-Fi CSI", submitted to the 13th International Conference on Indoor Positioning and Indoor Navigation (IPIN 2023).
M. Matey-Sanz, J. Torres-Sospedra and A. Moreira, "Temporal Stability on Human Activity Recognition based on Wi-Fi CSI," 2023 13th International Conference on Indoor Positioning and Indoor Navigation (IPIN), Nuremberg, Germany, 2023, pp. 1-6, doi: 10.1109/IPIN57070.2023.10332214.
You can explore the data and code used to obtain the results presented in the paper. To properly view the Jupyter Notebook files with their rendered figures, click on the "nbviewer" badge above.
Click the on the "Binder" badge above to open an interactive Jupyter environment with all required software installed.
Install Python 3.9, download the repository, open a command line in the root of the directory and install the required software by executing:
pip install -r requirements.txt
Install Docker for building an image based on a Dockerfile
with a Jupyter environment and running a container based on the image.
Download the repository, open a command line in the root of the directory and:
- Build the image:
docker build . --tag stability-csi-har-rp
- Run the image:
docker run -it -p 8888:8888 stability-csi-har-rp
- Click on the login link (or copy and paste in the browser) shown in the console to access to a Jupyter environment.
Open the desired Jupyter Notebook (*.ipynb) file. The notebook contains the code used for the analysis and its outputs. You can execute the code to reproduce the obtained results presented in the paper.
Note
When executing code with a component of randomness (i.e., ML models training), the obtained results could be slightly different than the reported ones. Notwithstanding, the conclusions should be similar as the reported ones.
Common files:
Dockerfile
: a recipe for the computational environment using Docker.requirements.txt
: file with the dependencies and versions used through all the code.
Jupyter Notebooks:
01.1_stanwifi-evaluation.ipynb
: Jupyter Notebook containing the code for evaluating the proposed preprocessing pipeline and the CNN model using the StanWiFi dataset and a 10-fold cross validation. Results are stored in02_RESULTS/01_STANWIFI/01_MODEL-REPORTS/reports.json
. The summary results at the end are the ones incorporated in Table III (StanWiFi > This work) of the paper.
Tip
To reproduce this notebook, please follow the instructions to download and setup the StanWiFi dataset.
01.2_multi-env-evaluation.ipynb
: Jupyter Notebook containing the code for evaluating the proposed preprocessing pipeline and the CNN model using the multi-environment dataset and a 10-fold cross validation. Results are stored in02_RESULTS/02_MULTI-ENV/01_MODEL-REPORTS/e1-reports.json
and02_RESULTS/02_MULTI-ENV/01_MODEL-REPORTS/e2-reports.json
for ENVIRONMENT 1 and ENVIRONMENT 2, respectively. The summary results at the end are the ones incorporated in Table III (Multi-environment (E1/E2) > This work) of the paper.
Tip
To reproduce this notebook, please follow the instructions to download and setup the multi-environment dataset.
02_collected-data-processing.ipynb
: Jupyter Notebook containing the code for preprocessing the collected dataset. The notebook loads the data in01_DATA/03_COLLECTED-DATASET/01_RAW
and generates four labelled datasets (D1, D2, D3 and D4) in01_DATA/03_COLLECTED-DATASET/02_LABELLED
. The data is labelled accordingly to the activity the user was performing at each moment: seated_rx, standing_up_rx, walking_tx, turn_tx, sitting_down_tx, seated_tx, standing_up_tx, walking_rx, turn_rx and sitting_down_rx. It also aranges the data in each dataset in windows of 50 samples with 50% overlap in01_DATA/03_COLLECTED-DATASET/03_WINDOWED
. It also contains the Table II (samples per activity and dataset) of the paper.03_evaluation-localized-har.ipynb
: Jupyter Notebook containing the code to evaluate the classification accuracy of the CNN model using five evaluation approaches:- 10-fold cross validation: results stored in
02_RESULTS/03_COLLECTED-DATASET/01_MODEL-REPORTS/cv_report.json
. - First 80% of D1T for training, the remaining 20% for testing (D1E): results stored in
02_RESULTS/03_COLLECTED-DATASET/01_MODEL-REPORTS/d1_report.json
and02_RESULTS/03_COLLECTED-DATASET/02_CONFUSION_MATRIXES/d1_cfm.pdf
. - Training wiht D1T, evaluation with D2: results stored in
02_RESULTS/03_COLLECTED-DATASET/01_MODEL-REPORTS/d2_report.json
and02_RESULTS/03_COLLECTED-DATASET/02_CONFUSION_MATRIXES/d2_cfm.pdf
. - Training wiht D1T, evaluation with D3: results stored in
02_RESULTS/03_COLLECTED-DATASET/01_MODEL-REPORTS/d3_report.json
and02_RESULTS/03_COLLECTED-DATASET/02_CONFUSION_MATRIXES/d3_cfm.pdf
. - Training wiht D1T, evaluation with D4: results stored in
02_RESULTS/03_COLLECTED-DATASET/01_MODEL-REPORTS/d4_report.json
and02_RESULTS/03_COLLECTED-DATASET/02_CONFUSION_MATRIXES/d4_cfm.pdf
. The results obtained in this notebook are included in the Table IV (summary metrics), Table V (decrement), Figure 5 and Figure 6 (confusion matrixes).
- 10-fold cross validation: results stored in
Directories:
01_DATA
:01_STANWIFI
: contains a README explaining how to download and setup the dataset.02_MULTI-ENV
: contains a README explaining how to download and setup the dataset.03_COLLECTED-DATASET
:01_RAW
(First unzip the compressed file): contains the collected raw dataset with the Wi-Fi CSI data (01_dataset.csv
) and four files containing information for data segmentation.02_LABELLED
: contains the four labelled datasets (D1, D2, D3 and D4) obtained from the raw dataset. Each folder, contains file of the form e{XX}_{rx_tx|tx_rx}-{x|y}.npy where:- {XX}: execution id.
- {rx_tx|tx_rx}: indicates the direction of the execution, i.e., rx_tx, goes from rx to tx.
- {x|y}: x files contain amplitudes (CSI data) and y files contain their associated labels.
03_WINDOWED
: contains the data of each dataset arranged in windows of 50 samples with 50% overlap. Each folder contains files with the same name pattern as the previous ones.amplitudes-heatmap.pdf
: plot showing the first and last sequence of activities from D1 and D4, respectively. It corresponds with the Figure 7 of the paper.
02_RESULTS
:01_STANWIFI
: contains the generated results in01.1_stanwifi-evaluation.ipynb
. Used to generate StanWiFi > This work (Table III).02_MULTI-ENV
: contains the generated results in01.2_multi-env-evaluation.ipynb
. Used to generate Multi-environment (E1/E2) > This work (Table III).03_COLLECTED-DATASET
: contains the generated results in03_evaluation-localized-har.ipynb
.01_MODEL-REPORTS
: contains the classification reports of each evaluation approach. Used to generate Table IV and Table V.02_CONFUSION-MATRIXES
: contains the confusion matrixes of each evaluation approach (except 10-fold cross validation). Used to generate Figure 5 and Figure 6.
functions
: contains several Python files defining common functions used in the notebooks:filters
: includes a DBSCAN based filtering and a discrete wavelet transform (DWT) based filter.json
: utils for loading and storing json-based data.ml
: includes functions for cross validation, model evaluation, building classification reports, etc.random
: includes function for fixing the random seeds.report_metrics
: functions for summarizing classification reports in table format.
The documents in this repository are licensed under Creative Commons Attribution 4.0 International License.
All contained code is licensed under the Apache License 2.0.
All data used in this repository is licensed under Open Data Commons Attribution License.
This work has been funded by the Spanish Ministry of Universities [grants FPU19/05352 and EST23/00320] and by MCIN/AEI/10.13039/501100011033 [grant PID2020-120250RB-I00].