Sitemap
Xiaomei Ge

Xiaomei Ge

Credit Rick Control Data Scientist in a startup financial company. Sharing machine learning, statistics, linear algebra and rick control modeling techniques

Clustering Analysis of Basel Climate Data

8 min readJan 28, 2026

--

The artical will be exploring the Basel climate data by Clustering experiments and critically comparing whether two Center-based Clustering algorithms, K-means and Gaussian Mixture Model (GMM), are appropriate to this climate data set for unsupervised clustering purpose.

Press enter or click to view image in full size
Seaside of Dumaguete, Philippines

This data set is published on https://www.meteoblue.com/ and is about climate in Basel, Switzerland containing two-seasons 1763 data points and 18 features over from 2010 to 2019 (the summer and the winter). The data setd doesn’t have target variable that clustering techniques are applied to classify different climate groups.

Pre-processing

The data set doesn’t have missing values and all the features are numeric variables.

Press enter or click to view image in full size
Basel data set

A. Temperature (Min, Max, Mean)

Statistical Summary: Temperature variables (Min, Max, Mean) show a clear bimodal distribution, indicating summer and winter seasonal regimes. Moreover, there are no outliers and annual temperature differences (max-min) across all three variables are moderate range (from 38 to 41°C). This indicates that no extreme events (extreme hot & cold) across 9 years. Moreover, the std of all temperature variables (Min, Max, Mean) range from 7–9.6°C. This means that temperature structure of winter and summer in Basel is stable and predictable from 2010 to 2019.

Press enter or click to view image in full size
The distributions of temperature

Pearson coefficient show that they are highly correlated (>0.95). So, only mean temperature is kept for clustering. Furthermore, since absolute temperature shows how hot or cold the atmosphere is, while diurnal temperature range (DTR) reveals moisture, cloud cover, and surface-energy processes; Anew feature, DTR, is created by calculating difference between temperature (max) and temperature (min).

B. Relative Humidity (Min, Max, Mean)

Statistical Summary: Maximum Relative Humidity (RH) usually occurs in the early morning or late at night, while minimum RH often occurs in the mid-afternoon. Temperature is the main driver of changes in RH. The variability of maximum RH (std:7.9%) in Basel is much lower than that of minimum RH (std:12.9%). This is because daytime weather conditions are more variable than nighttime, so maximum RH is not as strongly influenced by temperature and thus not as changeable as minimum RH. Additionally, minimum RH variable is quite discrete (from 19% to 93%), it suggests that minimum RH is also influenced by different seasons or years. RH (Mean) is highly correlated with both RH (Min) and RH (Max) (r > 0.8). Therefore, RH (Mean) is dropped and both RH (Min) and RH (Max) are kept.

Press enter or click to view image in full size

C. Sea Level Pressure (Min, Max, Mean)

Statistical Summary: Three Sea Level Pressure (SLP) variables show that they have same spread (std: all around 9). 50% data points are distributed from 1010 hPa to 1021 hPa (IQR), while, there are 10% extreme events at both low (976 hPa) and high (1050 hPa) SLP.

Feature Engineering: Since three SLP features are highly linear correlated with each other based on the Pearson correlation relationship (r >0.9 ), only mean SLP is used to modelling. While, SLP change (Max SLP — Min SLP) in a day uncovers the shifts in weather. Large changes in the SLP range usually occur in the winter, not the summer, across most of the mid-to-high latitudes of the Northern Hemisphere. Atmospheric circulation is generally much more vigorous and variable in the winter due to stronger north-south temperature and pressure gradients[2]. In this case, SLP range is added to my model.

D. Wind Guest and Wind Speed (Min, Max, Mean)

Correlation relationship between pairs of 6 variables are either moderate or strong (r ≈ 0.6–0.93). Additionally, maximum daily wind speed is primarily used to detect the intensity of severe weather conditions such as gales, storms, tropical cyclones (typhoons and hurricanes), and tornadoes. As a result, only maximum Wind Speed is kept.

E. Precipitation Total (mm), Snowfall Amount (cm), Sunshine Duration (min)

Statistical Summary: These three variables are zero-inflation variables. It can been see from histogram that there are large amount of 0 in the variables, especially snowfall amount (1652 zeros in the variables.)

Press enter or click to view image in full size
Distribution of zero-inflation variables

Total precipitation shows a strong right-skewed distribution, with most days recording minimal or no rainfall. Snowfall amount is even more skewed than precipitation, with both Q1 and Q3 equal to 0 cm, and an IQR of 0 cm. This suggests that snowfall is rare, occurring only on a small fraction of days. Sunshine duration is not heavily skewed and shows substantial variability across nine years of summer and winter data. Values range from 0 to about 962 minutes, with a median around 388 minutes.

F. Transformation and standardization

Get Xiaomei Ge’s stories in your inbox

Join Medium for free to get updates from this writer.

z-score and Box-Cox are the methods that used for transformation and standardization respectively. Since the center-based clustering algorithms are sensitive to the distance of data points, standardization is crucial in the Pre-processing stage. Otherwise, different scales of features would have different effects on distance calculations. For example temperature and SLP variables are on different scales.

Prior to standardize, some variables are transformed by the Box-Cox method to produce more normally distributed features, stabilizes variance and minimizes outliers. This improves clustering performance by making distance measures more reliable and preventing skewed variables from dominating the clustering process.

Press enter or click to view image in full size
Transformation and standardization

The plots display that variables’ distribution shows a more concentrated and more normal distribution after transformation.

Press enter or click to view image in full size
2 distributions of each feature before and after transformation and standardization

Clustering

K-means and GMM are both Center-based Clustering techniques and sensitive to outliers since they rely on mean or variance calculation (GMM replies on covariance matrix). K-means implicitly assumes shape of clusterings is spherical, similar variance in all directions and similar cluster sizes. While, GMM is more flexible than K-means and inherently can be applied on elliptical cluster shapes. GMM assumes data points come from a mixture of several Gaussian distributions.

A. K-means

To inspect whether assumptions of K-means are violated, I ran K-means on dataset; Eigenvalue ratios of each cluster’s covariance matrix are callculated . Large eigenvalue ratios or near-zero minimum eigenvalues indicate strong anisotropy or degeneracy, thereby showing that the K-means assumptions are violated.

Elbow and Silhouette Score methods were used to decide k value. The plots show that 2 is optimal clusters on this data set when ran K-means.

Press enter or click to view image in full size
Press enter or click to view image in full size
Elbow and Silhouette Score

The eigenvalue ratio (lambda_max/lambda_min) of a spherical cluster approximately equal to 1. Cluster 0 exhibited a nearly singular covariance matrix with an eigenvalue ratio on the order of 10¹⁵, indicating a degenerate, highly anisotropic structure. The other cluster also showed strong anisotropy with an eigenvalue ratio exceeding 17. These results clearly violate the spherical cluster assumption of K-means, suggesting that the climate data are not well modeled by K-means clustering.

eigenvalue ratio

B. Gaussian Mixture Model (GMM)

K-means perform poorly on the data set not only because of anisotropy of cluster shapes but also the clusters are not spherical. GMM is a model that can accommodate elliptical shape of clusters and different shapes of clusters, meaning different covariance matrixs.

BIC and AIC are used to decide optimal number of Gaussian components (clusters) by balancing model fit and complexity, preventing overfitting. BIC/AIC have dropped dramticlly when there are 3 clusters followed by gradually drop until 6th cluster. I trained a GMM model with K=6.

The figure shows that the six clusters from GMM are highly overlapping and inseparable. The low Silhouette Score (0.087) has confirmed this fact. This is because different climate regimes can share similar characteristics along certain dimensions. For example, while temperature may clearly distinguish summer and winter regimes, other variables such as sea-level pressure may remain similar and thus non-separable. In addtion, some meteorological variables (e.g., wind speed, DTR, and SLP) vary contiously, and therefore do not exhibit clear natural boundaries. The properties of this climate data set provide a further evidence that K-means is not appropriate for this type of data. The Silhouette Score in this case is not well suited for evaluating clustering quality.

Press enter or click to view image in full size

I will be evaluating clustering quality by inspecting each cluster is meaningful from meteorological perspective, specifically each cluster represent a stable weather regime.

The GMM clustering identifies six typical weather regimes in Basel. This reflects both seasonal and transitional climate characteristics. From boxplots, cluster 1 represents a typical summer fair-weather regime, with the highest mean temperature (21.22 °C), almost no precipitation (0.02 mm), no snowfall, and extremely long sunshine duration (722.81 min). Cluster 2 is a warm conditions (19.60 °C) as well but with higher precipitation (3.09 mm) and moderate sunshine (366.63 min).

Cluster 0 captures a cool and rainy regime, with lower temperature (8.73 °C), the highest precipitation (5.14 mm), no sunshine, and relatively strong winds (18.68 m/s), typical of transitional seasons. Cluster 3 represents a cold, dry, and stable regime, characterized by low temperature (4.01 °C), minimal precipitation (0.02 mm), high pressure (1023.17 hPa), and moderate sunshine (360.71 min).

Cluster 4 describes a cool and windy regime, with moderate precipitation (2.35 mm), strong winds (22.24 m/s), and limited sunshine (164.58 min). Finally, Cluster 5 clearly represents a cold winter regime, with the lowest temperature (1.45 °C), the only nonzero snowfall (1.08 cm), low sunshine (117.84 min), and the strongest winds (25.97 m/s).

Press enter or click to view image in full size
Six climate types by GMM clusters

--

--

Xiaomei Ge
Xiaomei Ge