Using K-Means Clustering in Python with Periodic Boundary Conditions
Open Access
Abstract
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.Keywords
Funding Information
- University of Lodz (IDUB B2111501000004.07)
This publication has 40 references indexed in Scilit:
- Time Series Clustering Algorithm for Two-Modes Cyclic BiosignalsCommunications in Computer and Information Science, 2013
- Unsupervised clustering of multivariate circular dataStatistics in Medicine, 2012
- Data clustering: 50 years beyond K-meansPattern Recognition Letters, 2010
- K-MEANS CLUSTERING FOR PROBLEMS WITH PERIODIC ATTRIBUTESInternational Journal of Pattern Recognition and Artificial Intelligence, 2009
- On the Equivalence of Cohen’s Kappa and the Hubert-Arabie Adjusted Rand IndexJournal of Classification, 2008
- Comparing partitionsJournal of Classification, 1985
- A Method for Comparing Two Hierarchical ClusteringsJournal of the American Statistical Association, 1983
- Algorithm AS 136: A K-Means Clustering AlgorithmJournal of the Royal Statistical Society Series C: Applied Statistics, 1979
- A Fuzzy Relative of the ISODATA Process and Its Use in Detecting Compact Well-Separated ClustersJournal of Cybernetics, 1973
- Objective Criteria for the Evaluation of Clustering MethodsJournal of the American Statistical Association, 1971