Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cluster center mean of DBSCAN in R?

Using dbscan in package fpc I am able to get an output of:

dbscan Pts=322 MinPts=20 eps=0.005
        0   1
seed    0 233
border 87   2
total  87 235

but I need to find the cluster center (mean of cluster with most seeds). Can anyone show me how to proceed with this?

like image 509
Florie Avatar asked Dec 28 '22 11:12

Florie


2 Answers

You need to understand that as DBSCAN looks for arbitrarily shaped clusters, the mean can be well outside of the cluster. Looking at means of DBSCAN clusters therefore is not really sensible.

like image 50
Has QUIT--Anony-Mousse Avatar answered Dec 30 '22 00:12

Has QUIT--Anony-Mousse


Just index back into the original data using the cluster ID of your choice. Then you can easily do whatever further processing you want to the subset. Here is an example:

library(fpc)

n = 100
set.seed(12345)
data = matrix(rnorm(n*3), nrow=n)
data.ds = dbscan(data, 0.5)
> data.ds
dbscan Pts=100 MinPts=5 eps=0.5
        0 1 2 3
seed    0 1 3 1
border 83 4 4 4
total  83 5 7 5
> colMeans(data[data.ds$cluster==0, ])
[1]  0.28521404 -0.02804152 -0.06836167
like image 45
John Colby Avatar answered Dec 30 '22 01:12

John Colby