{"status":"ok","message-type":"work","message-version":"1.0.0","message":{"indexed":{"date-parts":[[2026,2,8]],"date-time":"2026-02-08T16:20:45Z","timestamp":1770567645619,"version":"3.49.0"},"reference-count":46,"publisher":"MDPI AG","issue":"6","license":[{"start":{"date-parts":[[2022,6,14]],"date-time":"2022-06-14T00:00:00Z","timestamp":1655164800000},"content-version":"vor","delay-in-days":0,"URL":"https:\/\/creativecommons.org\/licenses\/by\/4.0\/"}],"funder":[{"name":"University of Lodz","award":["IDUB B2111501000004.07"],"award-info":[{"award-number":["IDUB B2111501000004.07"]}]}],"content-domain":{"domain":[],"crossmark-restriction":false},"short-container-title":["Symmetry"],"abstract":"<jats:p>Periodic boundary conditions are natural in many scientific problems, and often lead to particular symmetries. Working with datasets that express periodicity properties requires special approaches when analyzing these phenomena. Periodic boundary conditions often help to solve or describe the problem in a much simpler way. The angular rotational symmetry is an example of periodic boundary conditions. This symmetry implies angular momentum conservation. On the other hand, clustering is one of the first and most basic methods used in data analysis. It is often a starting point when new data are acquired and understood. K-means clustering is one of the most commonly used clustering methods. It can be applied to many different situations with reasonably good results. Unfortunately, the original k-means approach does not cope well with the periodic properties of the data. For example, the original k-means algorithm treats a zero angle as very far from an angle that is 359 degrees. Periodic boundary conditions often change the classical distance measure and introduce an error in k-means clustering. In the paper, we discuss the problem of periodicity in the dataset and present a periodic k-means algorithm that modifies the original approach. Considering that many data scientists prefer on-the-shelf solutions, such as libraries available in Python, we present how easily they can incorporate periodicity into existing k-means implementation in the PyClustering library. It allows anyone to integrate periodic conditions without significant additional costs. The paper evaluates the described method using three different datasets: the artificial dataset, wind direction measurement, and the New York taxi service dataset. The proposed periodic k-means provides better results when the dataset manifests some periodic properties.<\/jats:p>","DOI":"10.3390\/sym14061237","type":"journal-article","created":{"date-parts":[[2022,6,15]],"date-time":"2022-06-15T01:39:54Z","timestamp":1655257194000},"page":"1237","update-policy":"https:\/\/doi.org\/10.3390\/mdpi_crossmark_policy","source":"Crossref","is-referenced-by-count":10,"title":["Using K-Means Clustering in Python with Periodic Boundary Conditions"],"prefix":"10.3390","volume":"14","author":[{"ORCID":"https:\/\/orcid.org\/0000-0002-1860-8853","authenticated-orcid":false,"given":"Alicja","family":"Miniak-G\u00f3recka","sequence":"first","affiliation":[{"name":"Faculty of Physics and Applied Informatics, University of Lodz, Pomorska 149\/153, 90-236 Lodz, Poland"}],"role":[{"role":"author","vocabulary":"crossref"}]},{"ORCID":"https:\/\/orcid.org\/0000-0002-2883-0773","authenticated-orcid":false,"given":"Krzysztof","family":"Podlaski","sequence":"additional","affiliation":[{"name":"Faculty of Physics and Applied Informatics, University of Lodz, Pomorska 149\/153, 90-236 Lodz, Poland"}],"role":[{"role":"author","vocabulary":"crossref"}]},{"ORCID":"https:\/\/orcid.org\/0000-0002-3981-6037","authenticated-orcid":false,"given":"Tomasz","family":"Gwizda\u0142\u0142a","sequence":"additional","affiliation":[{"name":"Faculty of Physics and Applied Informatics, University of Lodz, Pomorska 149\/153, 90-236 Lodz, Poland"}],"role":[{"role":"author","vocabulary":"crossref"}]}],"member":"1968","published-online":{"date-parts":[[2022,6,14]]},"reference":[{"key":"ref_1","doi-asserted-by":"crossref","first-page":"100","DOI":"10.2307\/2346830","article-title":"Algorithm AS 136: A K-Means Clustering Algorithm","volume":"28","author":"Hartigan","year":"1979","journal-title":"Appl. Stat."},{"key":"ref_2","unstructured":"Ester, M., Kriegel, H.P., Sander, J., and Xu, X. (1996, January 2\u20134). A density-based algorithm for discovering clusters in large spatial databases with noise. Proceedings of the Second International Conference on Knowledge Discovery and Data Mining (KDD-96), Portland, OR, USA."},{"key":"ref_3","doi-asserted-by":"crossref","first-page":"1","DOI":"10.1111\/j.2517-6161.1977.tb01600.x","article-title":"Maximum Likelihood from Incomplete Data Via the EM Algorithm","volume":"39","author":"Dempster","year":"1977","journal-title":"J. R. Stat. Soc. Ser. B"},{"key":"ref_4","unstructured":"Agrawal, R., and Srikant, R. (1995, January 6\u201310). Mining sequential patterns. Proceedings of the Proceedings of the Eleventh International Conference on Data Engineering, Taipei, Taiwan."},{"key":"ref_5","doi-asserted-by":"crossref","first-page":"453","DOI":"10.1109\/TKDE.2007.1002","article-title":"Discovery of Periodic Patterns in Spatiotemporal Sequences","volume":"19","author":"Cao","year":"2007","journal-title":"IEEE Trans. Knowl. Data Eng."},{"key":"ref_6","doi-asserted-by":"crossref","unstructured":"Chan, S., and Leong, K. (2010, January 10\u201313). An application of Cyclic Signature (CS) clustering for spatial-temporal pattern analysis to support public safety work. Proceedings of the 2010 IEEE International Conference on Systems, Man and Cybernetics, Istanbul, Turkey.","DOI":"10.1109\/ICSMC.2010.5641797"},{"key":"ref_7","doi-asserted-by":"crossref","first-page":"1","DOI":"10.1016\/j.eswa.2017.09.040","article-title":"Hierarchical trajectory clustering for spatio-temporal periodic pattern mining","volume":"92","author":"Zhang","year":"2018","journal-title":"Expert Syst. Appl."},{"key":"ref_8","doi-asserted-by":"crossref","first-page":"463","DOI":"10.1016\/j.bspc.2016.09.017","article-title":"Muscle activation patterns during gait: A hierarchical clustering analysis","volume":"31","author":"Rosati","year":"2017","journal-title":"Biomed. Signal Process. Control."},{"key":"ref_9","doi-asserted-by":"crossref","unstructured":"Agostini, V., Rosati, S., Castagneri, C., Balestra, G., and Knaflitz, M. (2017, January 22\u201325). Clustering analysis of EMG cyclic patterns: A validation study across multiple locomotion pathologies. Proceedings of the 2017 IEEE International Instrumentation and Measurement Technology Conference (I2MTC), Torino, Italy.","DOI":"10.1109\/I2MTC.2017.7969746"},{"key":"ref_10","doi-asserted-by":"crossref","first-page":"89","DOI":"10.1002\/sam.11341","article-title":"Clustering complex time-series databases by using periodic components","volume":"10","author":"Giordano","year":"2017","journal-title":"Stat. Anal. Data Min. ASA Data Sci."},{"key":"ref_11","doi-asserted-by":"crossref","first-page":"1669","DOI":"10.1016\/j.cpc.2014.03.008","article-title":"Clustering of periodic multichannel timeseries data with application to plasma fluctuations","volume":"185","author":"Haskey","year":"2014","journal-title":"Comput. Phys. Commun."},{"key":"ref_12","doi-asserted-by":"crossref","first-page":"333","DOI":"10.1134\/S1995080220030075","article-title":"Quasi-Periodic Time Series Clustering for Human Activity Recognition","volume":"41","author":"Grabovoy","year":"2020","journal-title":"Lobachevskii J. Math."},{"key":"ref_13","doi-asserted-by":"crossref","unstructured":"Nunes, N., Ara\u00fajo, T., and Gamboa, H. (2013). Time Series Clustering Algorithm for Two-Modes Cyclic Biosignals. Biomedical Engineering Systems and Technologies, Springer.","DOI":"10.1007\/978-3-642-29752-6_17"},{"key":"ref_14","doi-asserted-by":"crossref","first-page":"1376","DOI":"10.1002\/sim.5589","article-title":"Unsupervised clustering of multivariate circular data","volume":"32","author":"Abraham","year":"2012","journal-title":"Stat. Med."},{"key":"ref_15","doi-asserted-by":"crossref","first-page":"298","DOI":"10.1016\/j.jsv.2018.08.002","article-title":"A fuzzy clustering method for periodic data, applied for processing turbomachinery beamforming maps","volume":"434","author":"Vad","year":"2018","journal-title":"J. Sound Vib."},{"key":"ref_16","doi-asserted-by":"crossref","unstructured":"Kume, A., and Walker, S.G. (2021). The utility of clusters and a Hungarian clustering algorithm. PLoS ONE, 16.","DOI":"10.1371\/journal.pone.0255174"},{"key":"ref_17","first-page":"2509","article-title":"Communication-efficient k-Means for Edge-based Machine Learning","volume":"33","author":"Lu","year":"2022","journal-title":"IEEE Trans. Parallel Distrib. Syst."},{"key":"ref_18","doi-asserted-by":"crossref","unstructured":"Fang, C., and Liu, H. (2021). Research and Application of Improved Clustering Algorithm in Retail Customer Classification. Symmetry, 13.","DOI":"10.3390\/sym13101789"},{"key":"ref_19","doi-asserted-by":"crossref","first-page":"95","DOI":"10.1016\/j.patcog.2019.04.014","article-title":"How much can k-means be improved by using better initialization and repeats?","volume":"93","author":"Sieranoja","year":"2019","journal-title":"Pattern Recognit."},{"key":"ref_20","doi-asserted-by":"crossref","unstructured":"Kaufman, L., and Rousseeuw, P.J. (1990). Partitioning Around Medoids (Program PAM). Finding Groups in Data: An Introduction to Cluster Analysis, John Wiley & Sons, Inc.","DOI":"10.1002\/9780470316801"},{"key":"ref_21","doi-asserted-by":"crossref","first-page":"32","DOI":"10.1080\/01969727308546046","article-title":"A Fuzzy Relative of the ISODATA Process and Its Use in Detecting Compact Well-Separated Clusters","volume":"3","author":"Dunn","year":"1973","journal-title":"J. Cybern."},{"key":"ref_22","doi-asserted-by":"crossref","unstructured":"Hany, O., and Abu-Elkheir, M. (2022). Detecting Vulnerabilities in Source Code Using Machine Learning. Lecture Notes in Networks and Systems, Springer.","DOI":"10.1007\/978-3-030-95918-0_4"},{"key":"ref_23","doi-asserted-by":"crossref","first-page":"103553","DOI":"10.1016\/j.bspc.2022.103553","article-title":"Deep integrated pipeline of segmentation guided classification of breast cancer from ultrasound images","volume":"75","author":"Inan","year":"2022","journal-title":"Biomed. Signal Process. Control."},{"key":"ref_24","doi-asserted-by":"crossref","first-page":"106968","DOI":"10.1016\/j.optlaseng.2022.106968","article-title":"Otsu-Kmeans gravity-based multi-spots center extraction method for microlens array imaging system","volume":"152","author":"Chen","year":"2022","journal-title":"Opt. Lasers Eng."},{"key":"ref_25","doi-asserted-by":"crossref","unstructured":"Balsor, J.L., Arbabi, K., Singh, D., Kwan, R., Zaslavsky, J., Jeyanesan, E., and Murphy, K.M. (2022). Corrigendum: A Practical Guide to Sparse k-Means Clustering for Studying Molecular Development of the Human Brain. Front. Neurosci., 16.","DOI":"10.3389\/fnins.2022.907479"},{"key":"ref_26","doi-asserted-by":"crossref","unstructured":"Zhao, M., Wang, Y., Wang, X., Chang, J., Zhou, Y., and Liu, T. (2022). Modeling and Simulation of Large-Scale Wind Power Base Output Considering the Clustering Characteristics and Correlation of Wind Farms. Front. Energy Res., 10.","DOI":"10.3389\/fenrg.2022.810082"},{"key":"ref_27","doi-asserted-by":"crossref","first-page":"1565","DOI":"10.1364\/OL.454715","article-title":"Low-complexity absolute-term based nonlinear equalizer with weight sharing for C-band 85-GBaud OOK transmission over a 100-km SSMF","volume":"47","author":"Wu","year":"2022","journal-title":"Opt. Lett."},{"key":"ref_28","unstructured":"Bora, M.D.J., and Gupta, D.A.K. (2014). Effect of Different Distance Measures on the Performance of K-Means Algorithm: An Experimental Study in Matlab. arXiv."},{"key":"ref_29","doi-asserted-by":"crossref","first-page":"651","DOI":"10.1016\/j.patrec.2009.09.011","article-title":"Data clustering: 50 years beyond K-means","volume":"31","author":"Jain","year":"2010","journal-title":"Pattern Recognit. Lett."},{"key":"ref_30","doi-asserted-by":"crossref","first-page":"1856","DOI":"10.1109\/TPAMI.2005.230","article-title":"A modified k-means algorithm for circular invariant clustering","volume":"27","author":"Charalampidis","year":"2005","journal-title":"IEEE Trans. Pattern Anal. Mach."},{"key":"ref_31","doi-asserted-by":"crossref","first-page":"721","DOI":"10.1142\/S0218001409007338","article-title":"K-means Clustering for Problems with Periodic Attributes","volume":"23","author":"Vejmelka","year":"2009","journal-title":"Int. J. Pattern Recognit. Artif."},{"key":"ref_32","doi-asserted-by":"crossref","unstructured":"Harb, H., Makhoul, A., Laiymani, D., Jaber, A., and Tawil, R. (2014, January 8\u201310). K-means based clustering approach for data aggregation in periodic sensor networks. Proceedings of the 2014 IEEE 10th International Conference on Wireless and Mobile Computing, Networking and Communications (WiMob), Larnaca, Cyprus.","DOI":"10.1109\/WiMOB.2014.6962207"},{"key":"ref_33","doi-asserted-by":"crossref","first-page":"e6096","DOI":"10.1002\/cpe.6096","article-title":"K-ear: Extracting data access periodic characteristics for energy-aware data clustering and storing in cloud storage systems","volume":"33","author":"You","year":"2021","journal-title":"Concurr. Comput. Pract. Exp."},{"key":"ref_34","doi-asserted-by":"crossref","first-page":"65","DOI":"10.7307\/ptt.v32i1.3154","article-title":"Short-term Traffic Flow Prediction Using Artificial Intelligence with Periodic Clustering and Elected Set","volume":"32","year":"2020","journal-title":"Promet-Traffic Transp."},{"key":"ref_35","doi-asserted-by":"crossref","unstructured":"Wang, G., Qin, W., and Wang, Y. (2021). Cyclic Weighted k-means Method with Application to Time-of-Day Interval Partition. Sustainability, 13.","DOI":"10.3390\/su13094796"},{"key":"ref_36","doi-asserted-by":"crossref","first-page":"1230","DOI":"10.21105\/joss.01230","article-title":"PyClustering: Data Mining Library","volume":"4","author":"Novikov","year":"2019","journal-title":"J. Open Source Softw."},{"key":"ref_37","unstructured":"Arthur, D., and Vassilvitskii, S. (2007, January 7\u20139). k-means++: The advantages of careful seeding. Proceedings of the Eighteenth Annual ACM-SIAM Symposium on Discrete Algorithms, SODA 2007, New Orleans, LA, USA."},{"key":"ref_38","first-page":"2825","article-title":"Scikit-learn: Machine Learning in Python","volume":"12","author":"Pedregosa","year":"2011","journal-title":"J. Mach. Learn. Res."},{"key":"ref_39","unstructured":"Podlaski, K. (2022, May 25). Periodic K-Means Exemplary Implementation. Available online: https:\/\/github.com\/kpodlaski\/periodic-kmeans."},{"key":"ref_40","doi-asserted-by":"crossref","first-page":"846","DOI":"10.1080\/01621459.1971.10482356","article-title":"Objective criteria for the evaluation of clustering methods","volume":"66","author":"Rand","year":"1971","journal-title":"J. Am. Stat. Assoc."},{"key":"ref_41","doi-asserted-by":"crossref","first-page":"553","DOI":"10.1080\/01621459.1983.10478008","article-title":"A method for comparing two hierarchical clusterings","volume":"78","author":"Fowlkes","year":"1983","journal-title":"J. Am. Stat. Assoc."},{"key":"ref_42","doi-asserted-by":"crossref","first-page":"193","DOI":"10.1007\/BF01908075","article-title":"Comparing partitions","volume":"2","author":"Hubert","year":"1985","journal-title":"J. Classif."},{"key":"ref_43","doi-asserted-by":"crossref","first-page":"177","DOI":"10.1007\/s00357-008-9023-7","article-title":"On the equivalence of Cohen\u2019s kappa and the Hubert-Arabie adjusted Rand index","volume":"25","author":"Warrens","year":"2008","journal-title":"J. Classif."},{"key":"ref_44","doi-asserted-by":"crossref","first-page":"306","DOI":"10.1016\/j.agrformet.2016.08.023","article-title":"Methane and carbon dioxide fluxes of a temperate mire in Central Europe","volume":"232","author":"Fortuniak","year":"2017","journal-title":"Agric. For. Meteorol."},{"key":"ref_45","doi-asserted-by":"crossref","unstructured":"Podlaski, K., Durka, M., Gwizda\u0142\u0142a, T., Miniak-G\u00f3recka, A., Fortuniak, K., and Pawlak, W. (2021). LSTM Processing of Experimental Time Series with Varied Quality. Computational Science\u2014ICCS 2021, Springer.","DOI":"10.1007\/978-3-030-77980-1_44"},{"key":"ref_46","unstructured":"(2022, May 16). NYC Taxi and Limousine Commission (TLC), Available online: http:\/\/www.nyc.gov\/html\/tlc\/html\/about\/trip_record_data.shtml."}],"container-title":["Symmetry"],"original-title":[],"language":"en","link":[{"URL":"https:\/\/www.mdpi.com\/2073-8994\/14\/6\/1237\/pdf","content-type":"unspecified","content-version":"vor","intended-application":"similarity-checking"}],"deposited":{"date-parts":[[2025,10,10]],"date-time":"2025-10-10T23:31:07Z","timestamp":1760139067000},"score":1,"resource":{"primary":{"URL":"https:\/\/www.mdpi.com\/2073-8994\/14\/6\/1237"}},"subtitle":[],"short-title":[],"issued":{"date-parts":[[2022,6,14]]},"references-count":46,"journal-issue":{"issue":"6","published-online":{"date-parts":[[2022,6]]}},"alternative-id":["sym14061237"],"URL":"https:\/\/doi.org\/10.3390\/sym14061237","relation":{},"ISSN":["2073-8994"],"issn-type":[{"value":"2073-8994","type":"electronic"}],"subject":[],"published":{"date-parts":[[2022,6,14]]}}}