Dynamic Time Warping Based Clustering Anonymization Approach for Patient Time Series

CWSF · 2026 Health & Wellness Bronze Medal

Thumbnail supplied by the source for Dynamic Time Warping Based Clustering Anonymization Approach for Patient Time Series

Overview

In this digital age, we give away our data everyday; by accepting website cookies or wearing smartwatches that track everything from heart rate to sleep cycles. The data we generate can be used to design solutions to problems faced across all fields of science but cannot be released without the guarantee of anonymity for subjects involved. Trying to strike a balance between privacy and the meaningfulness of the data, especially with time series data (data collected over a period), has stood as a challenge for researchers. This project aims to evaluate the efficacy of a novel approach: using clustering to group similar subjects and generate an averaged set of values (centroid), that in theory should maintain anonymity. The clustering method was evaluated by training a forecasting model to predict future values based on the centroid and compare with the actual values.

Video

Why?

Alberta’s electronic medical record system, Connect Care™, stores over 133.6 million patient encounters and events that can be accessed by physicians across the province. Almost none of this data can be publicly released without considering the risks: exposing identities and leaking sensitive information.

Anonymization of information, especially in a research context, must balance protecting subjects’ identities and the meaningfulness of the data. This challenge is much more complex with time series data (data collected over a period), as each individual has their own distinct pattern. Even the act of posting to social media when visiting the hospital can put an entire dataset in jeopardy of being breached.

In a time where wearable health devices, medical grade sensors, and apps that track physiological metrics are apart of everyday life, anonymization research is even more important.

The more access that researchers and even the public have to data, the more solutions that can be generated to problems we face. From designing artificial intelligence models to optimizing the operation of our healthcare system to patient trajectory predictions, time series data has the potential to impact the lives of not just researchers, but patients and healthcare workers.

Privacy is an issue that applies to all people. The exposure of identities, diagnoses and health conditions can have consequences for subjects involved, in their employment, eligibility for insurance, and government support.

This project aims to offer a potential approach to navigating the challenge of anonymizing time series data without sacrificing the meaningfulness of data.

How?

Patient time series data, specifically admissions to the ICU, patient diagnoses, and corresponding ICD codes were extracted from the MIMIC-IV v.31 database. The database contains the records of over 65,000 patients that were admitted to the Beth Israel Deaconess Medical Centre in Boston, Massachusetts.

Columns, besides the patient’s hospital admission IDs and the start time of admission, were removed. The ICD (International Classification of Diseases) codes and the corresponding diagnoses files were merged with the ICU database. In this merged dataset, patients with hyperlipidemia were selected for. The gaps between admissions were computed using the start time sequences of each patient. A logarithmic transformation was applied to the gaps.

Clustering is a technique that uses unsupervised machine learning to group similar subjects and generates a centroid (averaged set of values). Considering that I was working with time series data, I opted to use Dynamic Time Warping (DTW) clustering, a type of clustering that aligns alike patterns occurring at different points of time. To determine the optimal number of clusters, I used the elbow method, a visual technique that graphs inertia (measure of cluster’s tightness) versus the number of clusters. With the optimal number of clusters, I generated the sequences of each cluster’s centroid.

In theory, replacing patient’s actual sequences with centroid values could be a viable technique to ensure no patient’s information is explicitly given out, while maintaining the meaningfulness of the data.

To evaluate this method, I trained an ARIMA (AutoRegressive Integrated Moving Average) forecasting model on the centroid sequences and forecasted the next three admissions in the hospital. The predicted centroid values were compared with the actual values of patients using three different metrics: MSE (mean square error), MAE (mean absolute error), and RMSE (root mean square error).

What?

To compare the accuracy of the centroid predictions versus actual values, I utilized MSE (mean square error), MAE (mean absolute error), and RMSE (root mean square error) for my quantitative analysis. MAE measures the absolute difference between predicted values and actual values. MSE measures the average squared difference, which penalizes large errors more heavily. RMSE is the square root of MSE, which expresses the error in the original units while emphasizing larger errors.

All scores are given in hours, e.g. a MAE score of five would signify a difference of five hours between the predicted and actual value. The results suggest that the DTW (dynamic time warping) clustering-based method was effective in capturing temporal patterns in patient visit behavior.

The baseline for our study was a shift of thirty-six hours, considering the fact that the shortened sequence lengths limited the capabilities of the ARIMA model. Around 83.95% of subjects have MSE and RMSE scores below the threshold value, while an even greater percentage of 86.52% fall below the MAE threshold of 36.

While the model does sacrifice some individual precision, it is able to achieve the goal of anonymization with its ability to shift values without distorting the meaningfulness of the data significantly.

So What?

This research not only has the potential to alleviate the liabilities faced by data-holders, especially institutions e.g. hospitals, when releasing data, but to improve the landscape of our healthcare system for both professionals, patients and researchers. By addressing the challenges of anonymization, this approach can support a more open, collaborative healthcare research environment without the concern of compromising the identity of patients.

We can apply these methods for broader public release and use. Medical researchers will be able to gain access to large-scale, up-to-date, real-world databases without the need for extensive credentialling and confidentiality agreements. More effective anonymization methods reduce the red tape and barriers faced by researchers.

Robert Noyce once famously said, "Knowledge is power. Knowledge shared is power multiplied”; the more individuals that have access to information, the greater likelihood of finding solutions to problems we face every day.

What's Next?

To extend the study of my project, I could investigate a hybrid anonymization system, much like that of k-anonymity models utilized for static data in conjunction with our novel approach of DTW (Dynamic Time Warping) clustering for time series data. This pushes the model beyond exploration, but practical application in a healthcare setting to evaluate its efficacy.

By changing the random state for generating an elbow graph, this project could gain greater understanding of the stability of clusters, thus ensuring the optimal number is chosen.

Thanks

I would like to thank the University of Lethbridge's HYRS (Highschool Youth Summer Research) for providing me access to mentorship, the computer lab, and opportunities to refine my research skills. Thank you to Alberta Innovates for providing a $3000 stipend to research at the University of Lethbridge.

Special thanks to Dr. Robert Benkoczi and Dr. Sajad Fathi Hafshejani for providing expert insight on computer science, specifically anonymization techniques, throughout my summer at the University of Lethbridge.

References

[1] Johnson, A. E. W., Pollard, T. J., Shen, L., et al. (2016). MIMIC-III Clinical Database (Version 1.4). PhysioNet. Available at: https://physionet.org/content/mimic3-carevue/1.4/

[2] Johnson, R. (2019). Data Science for Cybersecurity. IEEE Xplore. Available at: https://ieeexplore.ieee.org/document/8663857

[3] Sweeney, L. (n.d.). Reidentification Risk. Electronic Privacy Information Center (EPIC). Available at: https://epic.org/wp-content/uploads/privacy/reidentification/Sweeney_Article.pdf

[4] Nau, R. (n.d.). Introduction to ARIMA Models. Duke University. Available at: https://people.duke.edu/~rnau/411arim.htm

Images (21)

Awards (2)

  • Bronze Medal
  • Selected for CWSF 2026

Competition history

Related projects

Closest projects by meaning, across every fair and year in the corpus.

Browse more like this

Source: ProjectBoard / Youth Science Canada

Save projects to your library

Sign in with Google to keep track of projects you find interesting, organized into folders. An account also raises your daily allowance for “Has this been done?”, and lets you create a key for the MCP server with a much higher limit than anonymous use. Browsing stays public.

Continue with Google