DBSCAN 聚类

编程入门 行业动态 更新时间:2024-10-23 17:36:42
本文介绍了DBSCAN 聚类 - 将聚类结果导出到新列问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我在 Iris 数据集下使用 python 编写了一个代码 - 我使用的聚类技术是 DBSCAN.我需要将所需的结果取出到一个新列中.我有聚类的图形图表.需要取出更新后的新簇列的总数据集.

I have made a code using python under Iris Data set - the clustering technique i used is DBSCAN. I need to take out the desired outcome in to a new column. I have the graphical chart of the clustering. Needed to take out the total data set with updated new cluster column.

在 K-Means 中,我可以通过运行以下命令来做到这一点

In K-Means, I could do that by running the below

iris_frame['NEW_COLUMN'] = pd.Series(y, index=iris_frame.index)

在分层聚类中,我可以从下面的公式中取出所需的结果

In Hierarchical clustering i could take out the desired outcome from the below formula

from scipy.cluster.hierarchy import fcluster iris_CM=iris.copy() iris_CM['Hierarchical']=fcluster(dist_comp,3, criterion='maxclust')

有人知道如何使用 DBSCAN 吗?

Anyone know how to do it with DBSCAN?

推荐答案

您可以通过 labels_ 属性访问集群标签.根据文档

You can access the cluster labels by the labels_ attribute. According to the documentation

from sklearn.cluster import DBSCAN import numpy as np import pandas as pd X = np.array([[1, 2], [2, 2], [2, 3], [8, 7], [8, 8], [25, 80]]) df = pd.DataFrame(X) clustering = DBSCAN(eps=3, min_samples=2).fit(df) df["clusters"] = clustering.labels_

更多推荐

DBSCAN 聚类

本文发布于:2023-10-28 18:20:05,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1537407.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:DBSCAN   聚类

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!