我有一个76列的数据框。第一列包含日期值,其他75列为75个不同钻孔的地下水位。我想根据趋势对钻孔进行聚类(遵循相同模式的钻孔被分组在一起)。如何在python中实现这一点
这是我的数据帧的一个示例
df = pd.DataFrame({
'Date': [1980, 1985, 1990, 1995, 2000],
'borehole1': [53, 43, 33, 22, 18],
'borehole2': [50, 40, 30, 50, 40],
'borehole3': [22, 32, 42, 32, 13],
'borehole4': [60, 65, 82, 72, 60],
'borehole5': [80, 70, 60, 80, 70],
'borehole6': [43, 33, 22, 18, 13]
})
df.plot()
因此,在本例中,我将有3个集群:
K-Means算法非常适合这一点!下面是一个示例。只需将X和y指向特定的数据集,并将“K”设置为3(在本例中已经为您完成)
有关更多信息,请参阅此链接
https://scikit-learn.org/stable/auto_examples/datasets/plot_iris_dataset.html
相关问题 更多 >
编程相关推荐