I have temperature measurements from weather stations in a mountainous region and I want to obtain a vertical profile from these data at any given time.

In a simple case one can just plot all values in a temperature vs height chart and apply a linear/polynomial/fancy regression to obtain a curve and therefore an estimate of the lapse rate dT/dz.

In some cases, though, the weather changes abruptly and temperature will differ widely between, say, the eastern and western parts of the region. In such case the cloud of values in the above-mentioned plot will be quite messy and a regression won't be of help - R^2 will be quite low.

I was thinking of using a clustering algorithm in these cases, to split values into two groups (e.g. west and east), each having its own vertical profile, which would then (ideally) be suitable for applying regression. The algorithm could use information about each value's geographical position (lat-lon), which is hidden in the temp vs height plot, to figure out to which group each value belongs.

Can I achieve something like this using k-means? Any suggestion is welcome.


1 Answer 1


here is my 2 cents: k-means is an unsupervised method and therefore it's best suited if you wanted to explore the optimal number of clusters the temperature can be split, this could be useful to see that maybe there is more regions other than east or west were the temperature is different like north and south and you could use a silhouette score or elbow curve to find the optimal number of clusters.

But, what you describe here is a supervised classification problem where you already have the labels(east and west) and want to separate the temperature accordingly, depending on the type of data I would recommend a classification algorithm such as k-nearest neighbors

you could use k-means with a fixed number of clusters, in this case 2, but it would not be as effective as a supervised algorithm

  • $\begingroup$ Actually, I don't have labels already. Depending on the weather situation, the percentage of stations belonging to either cluster could vary widely (from 50-50% to even 10-90%, I can imagine) and the two clusters could be centered anywhere in the region (W-E, S-N, NE-rest etc.). But I would like to keep the number of cluster fixed at 2 to avoid overcomplicating. So basically I'd like to use an algorithm which uses a certain threshold to decide whether the stations can be sorted into two separate clusters (i.e. vertical profiles) and if so, outputs these clusters. $\endgroup$
    – enrymather
    Nov 12, 2020 at 16:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.