How would you group/cluster these three areas in arrays in python?

后端 未结 5 904
挽巷
挽巷 2021-02-01 07:42

So you have an array

1
2
3
60
70
80
100
220
230
250

For a better understanding:

\"

5条回答
  •  半阙折子戏
    2021-02-01 08:01

    You could use nearest neighbor clustering. For a point to belong to one of the clusters, its nearest neighbor must also belong to the cluster. With the case you've shown, you'd just need to iterate along the x-axis and compare the differences to the adjacent points. When the difference to the previous point is greater than the difference to the next point, it indicates the start of a new cluster.

提交回复
热议问题