Unsupervised Contrastive Learning for Time Series Data Clustering
Abstract
:1. Introduction
2. Task Setting
3. The Proposed Method
3.1. Multi-View Feature Fusion
3.2. Positive and Negative Sample Pair Construction
3.3. Contrastive Loss Function
3.3.1. Clustering Loss
3.3.2. Feature-Level Loss
3.3.3. Regularization Term
3.4. Training Process
Algorithm 1 Training Algorithm |
Input: Time series data X, number of cluster K, batch size B. Output: The clustering results.
|
4. Experimental Evaluation
4.1. Experimental Dataset and Evaluation Indicators
4.2. Experimental Details
4.3. Experimental Results
4.3.1. Analysis of UCL-TSC Performance
4.3.2. Analysis of Contrastive Loss
4.3.3. Comparison Experiment
4.3.4. Hyperparametric Experiment
4.3.5. Ablation Experiment
5. Conclusions
Author Contributions
Funding
Data Availability Statement
Conflicts of Interest
Abbreviations
TSC | Time series data clustering |
AGNES | Agglomerative nesting algorithm |
DIANA | Divisive analysis algorithm |
DBSCAN | Density-based spatial clustering of applications with noise |
OPTICS | Ordering points to identify the clustering structure |
HDBSCAN | Hierarchical density-based spatial clustering of applications with noise |
ARIMA | Autoregressive integral sliding average models |
DTW | Dynamic time warping |
UCL-TSC | Unsupervised contrastive learning for time series data clustering |
TCN | Temporal convolutional neural network |
CNN | Convolutional neural network |
ACC | Unsupervised clustering accuracy |
NMI | Normalized mutual information |
PUR | Purity |
References
- Vera, J.F.; Angulo, J.M. An MDS-Based Unifying Approach to Time Series K-Means Clustering: Application in the Dynamic Time Warping Framework. Stoch. Environ. Res. Risk Assess. 2023, 37, 4555–4566. [Google Scholar] [CrossRef]
- Huang, X.; Ye, Y.; Xiong, L.; Lau, R.Y.K.; Jiang, N.; Wang, S. Time Series K-Means: A New k-Means Type Smooth Subspace Clustering for Time Series Data. Inf. Sci. 2016, 367–368, 1–13. [Google Scholar] [CrossRef]
- Ozkok, F.O.; Celik, M. A Hybrid Validity Index to Determine K Parameter Value of K-Means Algorithm for Time Series Clustering. Int. J. Inf. Technol. Decis. Mak. 2021, 20, 1615–1636. [Google Scholar] [CrossRef]
- Wang, C.; Zhao, S.; Ren, Z.; Long, Q. Place-Centered Bus Accessibility Time Series Classification with Floating Car Data: An Actual Isochrone and Dynamic Time Warping Distance-Based k-Medoids Method. ISPRS Int. J. Geo-Inf. 2023, 12, 285. [Google Scholar] [CrossRef]
- Li, F.; Wang, C. Develop a Multi-Linear-Trend Fuzzy Information Granule Based Short-Term Time Series Forecasting Model with k-Medoids Clustering. Inf. Sci. 2023, 629, 358–375. [Google Scholar] [CrossRef]
- Dewi, D.A.; Surono, S.; Thinakaran, R.; Nurraihan, A. Hybrid Fuzzy K-Medoids and Cat and Mouse-Based Optimizer for Markov Weighted Fuzzy Time Series. Symmetry 2023, 15, 1477. [Google Scholar] [CrossRef]
- Serra, A.P.; Zárate, L.E. Characterization of Time Series for Analyzing of the Evolution of Time Series Clusters. Expert. Syst. Appl. 2015, 42, 596–611. [Google Scholar] [CrossRef]
- Patnaik, A.K.; Bhuyan, P.K.; Krishna Rao, K.V. Divisive Analysis (DIANA) of Hierarchical Clustering and GPS Data for Level of Service Criteria of Urban Streets. Alex. Eng. J. 2016, 55, 407–418. [Google Scholar] [CrossRef]
- Chang, D.; Ma, Y.; Ding, X. Time Series Clustering Based on Singularity. Int. J. Comput. Commun. Control 2017, 12, 790–802. [Google Scholar] [CrossRef]
- Nicolis, O.; Delgado, L.; Peralta, B.; Díaz, M.; Chiodi, M. Space-Time Clustering of Seismic Events in Chile Using ST-DBSCAN-EV Algorithm. Environ. Ecol. Stat. 2024, 31, 509–536. [Google Scholar] [CrossRef]
- Fu, J.-S.; Liu, Y.; Chao, H.-C. ICA: An Incremental Clustering Algorithm Based on OPTICS. Wirel. Pers. Commun. 2015, 84, 2151–2170. [Google Scholar] [CrossRef]
- Zhao, Y.; Li, H.; Yu, X.; Ma, N.; Yang, T.; Zhou, J. An Independent Central Point OPTICS Clustering Algorithm for Semi-Supervised Outlier Detection of Continuous Glucose Measurements. Biomed. Signal Process. Control 2022, 71, 103196. [Google Scholar] [CrossRef]
- Lee, T.; Kim, Y.; Hyun, Y.; Mo, J.; Yoo, Y. Unsupervised Anomaly Detection Process Using LLE and HDBSCAN by Style-GAN as a Feature Extractor. Int. J. Precis. Eng. Manuf. 2024, 25, 51–63. [Google Scholar] [CrossRef]
- Neto, A.C.A.; Sander, J.; Campello, R.J.G.B.; Nascimento, M.A. Efficient Computation and Visualization of Multiple Density-Based Clustering Hierarchies. IEEE Trans. Knowl. Data Eng. 2021, 33, 3075–3089. [Google Scholar] [CrossRef]
- Péalat, C.; Bouleux, G.; Cheutet, V. Improved Time Series Clustering Based on New Geometric Frameworks. Pattern Recognit. 2022, 124, 108423. [Google Scholar] [CrossRef]
- Zhang, Q.; Wu, J.; Zhang, P.; Long, G.; Zhang, C. Salient Subsequence Learning for Time Series Clustering. IEEE Trans. Pattern Anal. Mach. Intell. 2019, 41, 2193–2207. [Google Scholar] [CrossRef]
- Aslan, S.; Yozgatligil, C.; Iyigun, C. Temporal Clustering of Time Series via Threshold Autoregressive Models: Application to Commodity Prices. Ann. Oper. Res. 2018, 260, 51–77. [Google Scholar] [CrossRef]
- Euán, C.; Ombao, H.; Ortega, J. The Hierarchical Spectral Merger Algorithm: A New Time Series Clustering Procedure. J. Classif. 2018, 35, 71–99. [Google Scholar] [CrossRef]
- Piccardi, C.; Calatroni, L.; Bertoni, F. Clustering Financial Time Series by Network Community Analysis. Int. J. Mod. Phys. C 2011, 22, 35–50. [Google Scholar] [CrossRef]
- Wong, C.; Versace, M. CARTMAP: A Neural Network Method for Automated Feature Selection in Financial Time Series Forecasting. Neural Comput. Appl. 2012, 21, 969–977. [Google Scholar] [CrossRef]
- Javed, A.; Rizzo, D.M.; Lee, B.S.; Gramling, R. Somtimes: Self Organizing Maps for Time Series Clustering and Its Application to Serious Illness Conversations. Data Min. Knowl. Discov. 2024, 38, 813–839. [Google Scholar] [CrossRef] [PubMed]
- Pei, D.; Luo, C.; Liu, X. Financial Trading Decisions Based on Deep Fuzzy Self-Organizing Map. Appl. Soft Comput. 2023, 134, 109972. [Google Scholar] [CrossRef]
- Li, Y.; Du, M.; Jiang, X.; Zhang, N. Contrastive Learning-Based Multi-View Clustering for Incomplete Multivariate Time Series. Inf. Fusion. 2025, 117, 102812. [Google Scholar] [CrossRef]
- Moradinasab, N.; Sharma, S.; Bar-Yoseph, R.; Radom-Aizik, S.; Bilchick, K.C.; Cooper, D.M.; Weltman, A.; Brown, D.E. Universal Representation Learning for Multivariate Time Series Using the Instance-Level and Cluster-Level Supervised Contrastive Learning. Data Min. Knowl. Discov. 2024, 38, 1493–1519. [Google Scholar] [CrossRef] [PubMed]
- Zhong, Y.; Huang, D.; Wang, C.-D. Deep Temporal Contrastive Clustering. Neural Process Lett. 2023, 55, 7869–7885. [Google Scholar] [CrossRef]
- Liu, Z.; Alavi, A.; Li, M.; Zhang, X. Self-Supervised Contrastive Learning for Medical Time Series: A Systematic Review. Sensors 2023, 23, 4221. [Google Scholar] [CrossRef]
- Yang, Z.; Li, H.; Tuo, X.; Li, L.; Wen, J. Unsupervised Clustering of Microseismic Signals Using a Contrastive Learning Model. IEEE Trans. Geosci. Remote Sens. 2023, 61, 5903212. [Google Scholar] [CrossRef]
- Liang, Z.; Liang, C.; Liang, Z.; Wang, H.; Zheng, B. TimeCSL: Unsupervised Contrastive Learning of General Shapelets for Explorable Time Series Analysis. Proc. VLDB Endow. 2024, 17, 4489–4492. [Google Scholar] [CrossRef]
- Alqahtani, A.; Ali, M.; Xie, X.; Jones, M.W. Deep Time-Series Clustering: A Review. Electronics 2021, 10, 3001. [Google Scholar] [CrossRef]
- Özgül, O.F.; Bardak, B.; Tan, M. A Convolutional Deep Clustering Framework for Gene Expression Time Series. IEEE/ACM Trans. Comput. Biol. Bioinform. 2021, 18, 2198–2207. [Google Scholar] [CrossRef]
- Kim, J.; Moon, N. A Deep Bidirectional Similarity Learning Model Using Dimensional Reduction for Multivariate Time Series Clustering. Multimed. Tools Appl. 2021, 80, 34269–34281. [Google Scholar] [CrossRef]
- Li, X.; Xi, W.; Lin, J. Randomnet: Clustering Time Series Using Untrained Deep Neural Networks. Data Min. Knowl. Discov. 2024, 38, 3473–3502. [Google Scholar] [CrossRef]
- He, D.; Tang, Z.; Chen, Q.; Han, Z.; Zhao, D.; Sun, F. A Two-Stage Deep Graph Clustering Method for Identifying the Evolutionary Patterns of the Time Series of Animation View Counts. Inf. Sci. 2023, 642, 119155. [Google Scholar] [CrossRef]
- Cui, J.; Li, Y.; Huang, H.; Wen, J. Dual Contrast-Driven Deep Multi-View Clustering. IEEE Trans. Image Process. 2024, 33, 4753–4764. [Google Scholar] [CrossRef]
- Yeh, C.-H.; Hong, C.-Y.; Hsu, Y.-C.; Liu, T.-L.; Chen, Y.; LeCun, Y. Decoupled Contrastive Learning. In European Conference on Computer Vision; Springer Nature: Cham, Switzerland, 2022; pp. 668–684. [Google Scholar]
- Yang, J.; Leskovec, J. Patterns of Temporal Variation in Online Media. In Proceedings of the Fourth ACM International Conference on Web Search and Data Mining, Hong Kong, China, 9–12 February 2011; Association for Computing Machinery: New York, NY, USA, 2011; pp. 177–186. [Google Scholar]
- Paparrizos, J.; Gravano, L. K-Shape: Efficient and Accurate Clustering of Time Series. SIGMOD Rec. 2016, 45, 69–76. [Google Scholar] [CrossRef]
- Li, X.; Lin, J.; Zhao, L. Linear Time Complexity Time Series Clustering with Symbolic Pattern Forest. In Proceedings of the 28th International Joint Conference on Artificial Intelligence, Macao, China, 10–16 August 2019; AAAI Press: Macao, China, 2019; pp. 2930–2936. [Google Scholar]
- Lei, Q.; Yi, J.; Vaculin, R.; Wu, L.; Dhillon, I.S. Similarity Preserving Representation Learning for Time Series Clustering. In Proceedings of the 28th International Joint Conference on Artificial Intelligence, Macao, China, 10–16 August 2019; AAAI Press: Macao, China, 2019; pp. 2845–2851. [Google Scholar]
- Petitjean, F.; Ketterlin, A.; Gançarski, P. A Global Averaging Method for Dynamic Time Warping, with Applications to Clustering. Pattern Recognit. 2011, 44, 678–693. [Google Scholar] [CrossRef]
- Guo, X.; Gao, L.; Liu, X.; Yin, J. Improved Deep Embedded Clustering with Local Structure Preservation. In Proceedings of the 26th International Joint Conference on Artificial Intelligence, Melbourne, Australia, 19–25 August 2017; AAAI Press: Melbourne, Australia, 2017; pp. 1753–1759. [Google Scholar]
- Madiraju, N.; Sadat, S.M.; Fisher, D.; Karimabadi, H. Deep Temporal Clustering: Fully Unsupervised Learning of Time-Domain Features. arXiv 2018, arXiv:1802.01059. [Google Scholar]
- Dempster, A.; Schmidt, D.F.; Webb, G.I. MiniRocket: A Very Fast (Almost) Deterministic Transform for Time Series Classification. In Proceedings of the 27th ACM SIGKDD Conference on Knowledge Discovery & Data Mining, Singapore, 14–18 August 2021; Association for Computing Machinery: New York, NY, USA, 2021; pp. 248–257. [Google Scholar]
Type | Name | Train | Test | Class | Length |
---|---|---|---|---|---|
ECG | ECG200 | 100 | 100 | 2 | 96 |
EOG | EOGHorizontalSignal | 362 | 362 | 12 | 1250 |
EPG | InsectEPGRegularTrain | 62 | 249 | 3 | 601 |
Image | Fish | 175 | 175 | 7 | 463 |
Image | Herring | 64 | 64 | 2 | 512 |
Image | ProximalPhalanxOutlineAgeGroup | 400 | 205 | 3 | 80 |
Motion | GunPointOldVersusYoung | 136 | 315 | 2 | 150 |
Sensor | Lightning7 | 70 | 73 | 7 | 319 |
Sensor | DodgerLoopWeekend | 20 | 138 | 2 | 288 |
Sensor | Plane | 105 | 105 | 7 | 144 |
Spectro | Coffee | 28 | 28 | 2 | 286 |
Spectro | Meat | 60 | 60 | 3 | 448 |
Parameters | Values | Parameters | Values |
---|---|---|---|
TCN channels | [32, 32, 32, 32] | Epoch of initialization | 200 |
TCN kernel_size | 2, 4, 6 | Epoch of clustering | 100 |
CNN kernel_size | 3 | 0.5 | |
CNN block_number | 3 | 0.5 | |
Activation function | Relu | Batch size | 32 |
Optimizer | Adam (lr = 0.0001) | {1, 0.1, 0.01, 0.001, 0.0001} | |
Number of clusters | {2, 3, 4, 5, 7, 10} | {1, 0.1, 0.01, 0.001, 0.0001} |
Type | Name | ACC | NMI | PUR | F_Score | Rand_Index |
---|---|---|---|---|---|---|
ECG | ECG200 | 0.510 | 0.352 | 0.795 | 0.689 | 0.672 |
EOG | EOGHorizontalSignal | 0.490 | 0.481 | 0.492 | 0.368 | 0.888 |
EPG | InsectEPGRegularTrain | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
Image | Fish | 0.571 | 0.415 | 0.586 | 0.416 | 0.831 |
Image | Herring | 0.547 | 0.004 | 0.602 | 0.510 | 0.501 |
Image | ProximalPhalanxOutlineAgeGroup | 0.797 | 0.545 | 0.797 | 0.736 | 0.804 |
Motion | GunPointOldVersusYoung | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
Sensor | Lightning7 | 0.511 | 0.510 | 0.588 | 0.426 | 0.820 |
Sensor | DodgerLoopWeekend | 0.981 | 0.870 | 0.981 | 0.968 | 0.963 |
Sensor | Plane | 0.929 | 0.901 | 0.929 | 0.875 | 0.965 |
Spectro | Coffee | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
Spectro | Meat | 1.000 | 1.000 | 1.000 | 1.000 | 1.000 |
Dataset | Average Loss Value | Standard Deviation |
---|---|---|
ECG200 | 6.33 | 1.64 × 10−8 |
EOGHorizontalSignal | 33.66 | 2.47 × 10−7 |
InsectEPGRegularTrain | 9.63 | 2.86 × 10−8 |
Fish | 10.22 | 2.17 × 10−7 |
Herring | 3.82 | 2.41 × 10−7 |
ProximalPhalanxOutlineAgeGroup | 14.63 | 1.87 × 10−7 |
GunPointOldVersusYoung | 7.86 | 3.44 × 10−7 |
Lightning7 | .397 | 3.56 × 10−8 |
DodgerLoopWeekend | 4.59 | 2.61 × 10−7 |
Plane | 6.21 | 1.94 × 10−7 |
Coffee | 1.80 | 4.18 × 10−8 |
Meat | 3.97 | 2.77 × 10−7 |
(a) | ||||||
Dataset | K-Means | K-Shape | KSC | SPF | SPI. | Ours |
ECG200 | 0.618 | 0.613 | 0.613 | 0.604 | 0.618 | 0.672 |
EOGHorizontalSignal | 0.857 | 0.877 | 0.422 | 0.869 | 0.866 | 0.888 |
InsectEPGRegularTrain | 0.639 | 0.709 | 0.523 | 0.718 | 0.767 | 1.000 |
Fish | 0.786 | 0.777 | 0.797 | 0.861 | 0.711 | 0.831 |
Herring | 0.500 | 0.504 | 0.499 | 0.504 | 0.506 | 0.501 |
ProximalPhalanxOutlineAgeGroup | 0.690 | 0.780 | 0.780 | 0.696 | 0.806 | 0.804 |
GunPointOldVersusYoung | 0.589 | 0.518 | 0.506 | 0.500 | 0.509 | 1.000 |
Lightning7 | 0.675 | 0.631 | 0.676 | 0.816 | 0.642 | 0.693 |
DodgerLoopWeekend | 0.790 | 0.794 | 0.555 | 0.809 | 0.796 | 0.820 |
Plane | 0.975 | 0.499 | 0.963 | 0.707 | 0.817 | 0.963 |
Coffee | 0.872 | 0.920 | 0.945 | 0.992 | 0.952 | 0.965 |
Meat | 0.704 | 0.877 | 0.525 | 0.989 | 0.717 | 0.894 |
(b) | ||||||
Dataset | kDBA | IDEC | DTC | MiniR. | Rand. | Ours |
ECG200 | 0.556 | 0.644 | 0.517 | 0.537 | 0.604 | 0.672 |
EOGHorizontalSignal | 0.797 | 0.082 | 0.855 | 0.569 | 0.874 | 0.888 |
InsectEPGRegularTrain | 0.648 | 0.596 | 0.613 | 0.753 | 1.000 | 1.000 |
Fish | 0.776 | 0.764 | 0.793 | 0.823 | 0.800 | 0.831 |
Herring | 0.499 | 0.504 | 0.489 | 0.502 | 0.508 | 0.501 |
ProximalPhalanxOutlineAgeGroup | 0.688 | 0.390 | 0.770 | 0.700 | 0.792 | 0.804 |
GunPointOldVersusYoung | 0.519 | 0.507 | 0.534 | 1.000 | 0.619 | 1.000 |
Lightning7 | 0.468 | 0.674 | 0.722 | 0.657 | 0.677 | 0.693 |
DodgerLoopWeekend | 0.796 | 0.789 | 0.805 | 0.812 | 0.814 | 0.820 |
Plane | 0.950 | 0.551 | 0.622 | 0.963 | 0.715 | 0.963 |
Coffee | 0.918 | 0.892 | 0.946 | 0.995 | 0.995 | 0.965 |
Meat | 0.888 | 0.671 | 0.725 | 0.750 | 0.983 | 0.894 |
(a) | ||||||||
Method | Coffee | Meat | Herring | Lightning7 | ||||
NMI | Rand Index | NMI | Rand Index | NMI | Rand Index | NMI | Rand Index | |
w/o CL | 0.031 | 0.501 | 0.515 | 0.708 | 0.005 | 0.502 | 0.504 | 0.825 |
w/o Residual | 0.023 | 0.501 | 0.939 | 0.978 | 0.007 | 0.500 | 0.515 | 0.825 |
w/o TCN | 0.036 | 0.507 | 0.487 | 0.702 | 0.009 | 0.500 | 0.540 | 0.833 |
w/o CNN-TCN | 0.600 | 0.893 | 0.883 | 0.957 | 0.009 | 0.500 | 0.509 | 0.823 |
UCL-TSC | 1.000 | 1.000 | 1.000 | 1.000 | 0.004 | 0.501 | 0.510 | 0.820 |
(b) | ||||||||
Method | DodgerLoop. | ECG200 | Plane | InsectEPG. | ||||
NMI | Rand Index | NMI | Rand Index | NMI | Rand Index | NMI | Rand Index | |
w/o CL | 0.815 | 0.95 | 0.129 | 0.618 | 0.902 | 0.950 | 0.679 | 0.768 |
w/o Residual | 0.815 | 0.950 | 0.140 | 0.623 | 0.912 | 0.952 | 0.703 | 0.800 |
w/o TCN | 0.815 | 0.950 | 0.121 | 0.613 | 0.929 | 0.965 | 1.000 | 1.000 |
w/o CNN-TCN | 0.870 | 0.963 | 0.352 | 0.684 | 0.894 | 0.962 | 1.000 | 1.000 |
UCL-TSC | 0.870 | 0.963 | 0.352 | 0.672 | 0.901 | 0.965 | 1.000 | 1.000 |
(c) | ||||||||
Method | Fish | GunPointOld. | Proximal. | EOGHori. | ||||
NMI | Rand Index | NMI | Rand Index | NMI | Rand Index | NMI | Rand Index | |
w/o CL | 0.328 | 0.795 | 0.188 | 0.624 | 0.535 | 0.796 | 0.498 | 0.865 |
w/o Residual | 0.384 | 0.821 | 0.403 | 0.683 | 0.521 | 0.796 | 0.446 | 0.875 |
w/o TCN | 0.412 | 0.838 | 0.379 | 0.654 | 0.520 | 0.797 | 0.500 | 0.890 |
w/o CNN-TCN | 0.451 | 0.839 | 0.151 | 0.578 | 0.556 | 0.804 | 0.457 | 0.887 |
UCL-TSC | 0.415 | 0.831 | 1.000 | 1.000 | 0.545 | 0.804 | 0.481 | 0.888 |
Disclaimer/Publisher’s Note: The statements, opinions and data contained in all publications are solely those of the individual author(s) and contributor(s) and not of MDPI and/or the editor(s). MDPI and/or the editor(s) disclaim responsibility for any injury to people or property resulting from any ideas, methods, instructions or products referred to in the content. |
© 2025 by the authors. Licensee MDPI, Basel, Switzerland. This article is an open access article distributed under the terms and conditions of the Creative Commons Attribution (CC BY) license (https://creativecommons.org/licenses/by/4.0/).
Share and Cite
Cao, B.; Xing, Q.; Yang, K.; Wu, X.; Li, L. Unsupervised Contrastive Learning for Time Series Data Clustering. Electronics 2025, 14, 1660. https://doi.org/10.3390/electronics14081660
Cao B, Xing Q, Yang K, Wu X, Li L. Unsupervised Contrastive Learning for Time Series Data Clustering. Electronics. 2025; 14(8):1660. https://doi.org/10.3390/electronics14081660
Chicago/Turabian StyleCao, Bo, Qinghua Xing, Ke Yang, Xuan Wu, and Longyue Li. 2025. "Unsupervised Contrastive Learning for Time Series Data Clustering" Electronics 14, no. 8: 1660. https://doi.org/10.3390/electronics14081660
APA StyleCao, B., Xing, Q., Yang, K., Wu, X., & Li, L. (2025). Unsupervised Contrastive Learning for Time Series Data Clustering. Electronics, 14(8), 1660. https://doi.org/10.3390/electronics14081660