public Clustering < Model > run ( Relation < ? > relation ) { HashMap < String , DBIDs > labelMap = multiple ? multipleAssignment ( relation ) : singleAssignment ( relation ) ; ModifiableDBIDs noiseids = DBIDUtil . newArray ( ) ; Clustering < Model > result = new Clustering <> ( "By Label Clustering" , "bylabel-clustering" ) ; for ( Entry < String , DBIDs > entry : labelMap . entrySet ( ) ) { DBIDs ids = entry . getValue ( ) ; if ( ids . size ( ) <= 1 ) { noiseids . addDBIDs ( ids ) ; continue ; } // Build a cluster Cluster < Model > c = new Cluster < Model > ( entry . getKey ( ) , ids , ClusterModel . CLUSTER ) ; if ( noisepattern != null && noisepattern . matcher ( entry . getKey ( ) ) . find ( ) ) { c . setNoise ( true ) ; } result . addToplevelCluster ( c ) ; } // Collected noise IDs. if ( noiseids . size ( ) > 0 ) { Cluster < Model > c = new Cluster < Model > ( "Noise" , noiseids , ClusterModel . CLUSTER ) ; c . setNoise ( true ) ; result . addToplevelCluster ( c ) ; } return result ; }
Run the actual clustering algorithm .