【发布时间】:2019-12-26 19:05:42
【问题描述】:
我想为聚类结果绘制树状图。现在我正在使用 ELKI 0.7.5 中的 ElkiBuilder 进行集群。
在最好的情况下,我想直接绘制树状图。
如果这不可能,我想从聚类中提取信息(距离),以使用另一个库创建树状图(例如,使用 newick 格式)
因此我的问题:
是否可以使用 ELKI 创建树状图?
是否可以访问在聚类期间计算的距离? (两个聚类合并时使用的距离)
现在我正在使用以下代码进行聚类:
public Clustering<?> createClustering() {
double[][] distanceMatrix = new double[][]{
{0.0, 1.0, 3.0},
{1.0, 0.0, 4.0},
{3.0, 4.0, 0.0}
};
int noOfClusters = 2;
// Adapter to load data from an existing array.
DatabaseConnection dbc = new ArrayAdapterDatabaseConnection(distanceMatrix);
// Create a database (which may contain multiple relations!)
Database db = new StaticArrayDatabase(dbc, null);
// Load the data into the database (do NOT forget to initialize...)
db.initialize();
Clustering<?> clustering = new ELKIBuilder<>(CutDendrogramByNumberOfClusters.class) //
.with(CutDendrogramByNumberOfClusters.Parameterizer.MINCLUSTERS_ID, noOfClusters) //
.with(AbstractAlgorithm.ALGORITHM_ID, AnderbergHierarchicalClustering.class) //
.with(AGNES.Parameterizer.LINKAGE_ID, WardLinkage.class)
.build().run(db);
return clustering;
}
【问题讨论】:
-
ELKI 的 UI 可以显示树状图。显然,这需要合并距离。所以它当然是可能的。也许您只需要多探索一下图书馆?
CutDendrogram...类可能使用树状图,但通过切割返回平面分区,所以也许这不是您想要使用的类?
标签: java hierarchical-clustering dendrogram elki