Search code examples
dbscanelki

ELKI DBSCAN RESULT structure


I am not able to get points which are in each cluster returned by elki dbscan.

ArrayList<Clustering<?>> cs = ResultUtil.filterResults(result,
                Clustering.class);
        for (Clustering<?> c : cs) {
            int i = 0;
            System.out.println("clusters: " + c.getAllClusters().size());
            for (de.lmu.ifi.dbs.elki.data.Cluster<?> cluster : c
                    .getAllClusters()) {
                System.out.println("\nclusters : " + cluster.getNameAutomatic()
                        + " , IsNoise:" + cluster.isNoise() + ", Size:"
                        + cluster.size());

Output is:

clusters: 4

clusters : Cluster , IsNoise:false, Size:240

clusters : Cluster , IsNoise:false, Size:374

clusters : Cluster , IsNoise:false, Size:4901

clusters : Noise , IsNoise:true, Size:211

I have gone through this Running DBSCAN in ELKI!. Still I am not able to get around to see the points in a cluster. I want to store it in an Array. What is the structure of cluster stored by elki?? I am stuck !!


Solution

  • Use cluster.getDBIDs() to get the cluster members.

    To get the raw data, retrieve the objects from the original Relation you analyzed.

    for (DBIDIter iter = cluster.getIDs().iter(); iter.valid(); iter.advance()) {
        DoubleVector obj = relation.get(iter);
    

    Note that ELKI allows abstract analysis of data - e.g. when using a distance matrix. In such cases, you may not have a DoubleVector relation, but only object IDs. This is why cluster do not consist of vectors. They consists of a DBIDs collection, and in some cases of a cluster model such as a centroid vector.