private List<List<Cluster<CorrelationModel>>> extractCorrelationClusters(Clustering<Model> dbscanResult, Relation<V> relation, int dimensionality, ERiCNeighborPredicate<V>.Instance npred) {
    // result
    List<List<Cluster<CorrelationModel>>> clusterMap = new ArrayList<>();
    for(int i = 0; i <= dimensionality; i++) {
      clusterMap.add(new ArrayList<Cluster<CorrelationModel>>());
    }

    // noise cluster containing all noise objects over all partitions
    Cluster<Model> noise = null;

    // iterate over correlation dimensions
    for(Cluster<Model> clus : dbscanResult.getAllClusters()) {
      DBIDs group = clus.getIDs();
      int dim = clus.isNoise() ? dimensionality : npred.dimensionality(clus.getIDs().iter());

      if(dim < dimensionality) {
        EigenPairFilter filter = new FirstNEigenPairFilter(dim);

        // get cluster list for this dimension.
        List<Cluster<CorrelationModel>> correlationClusters = clusterMap.get(dim);
        PCAResult epairs = settings.pca.processIds(group, relation);
        int numstrong = filter.filter(epairs.getEigenvalues());
        PCAFilteredResult pcares = new PCAFilteredResult(epairs.getEigenPairs(), numstrong, 1., 0.);

        double[] centroid = Centroid.make(relation, group).getArrayRef();
        Cluster<CorrelationModel> correlationCluster = new Cluster<>("[" + dim + "_" + correlationClusters.size() + "]", group, new CorrelationModel(pcares, centroid));
        correlationClusters.add(correlationCluster);
      }
      // partition containing noise
      else {
        if(noise == null) {
          noise = clus;
          continue;
        }
        ModifiableDBIDs merged = DBIDUtil.newHashSet(noise.getIDs());
        merged.addDBIDs(clus.getIDs());
        noise.setIDs(merged);
      }
    }

    if(noise != null && noise.size() > 0) {
      // get cluster list for this dimension.
      List<Cluster<CorrelationModel>> correlationClusters = clusterMap.get(dimensionality);
      EigenPairFilter filter = new FirstNEigenPairFilter(dimensionality);
      PCAResult epairs = settings.pca.processIds(noise.getIDs(), relation);
      int numstrong = filter.filter(epairs.getEigenvalues());
      PCAFilteredResult pcares = new PCAFilteredResult(epairs.getEigenPairs(), numstrong, 1., 0.);

      double[] centroid = Centroid.make(relation, noise.getIDs()).getArrayRef();
      Cluster<CorrelationModel> correlationCluster = new Cluster<>("[noise]", noise.getIDs(), new CorrelationModel(pcares, centroid));
      correlationClusters.add(correlationCluster);
    }

    // Delete dimensionalities not found.
    for(int i = dimensionality; i > 0; i--) {
      if(!clusterMap.get(i).isEmpty()) {
        break;
      }
      clusterMap.remove(i);
    }
    return clusterMap;
  }
private List < List < Cluster < CorrelationModel > > > extractCorrelationClusters ( Clustering < Model > dbscanResult , Relation < V > relation , int dimensionality , ERiCNeighborPredicate < V > . Instance npred ) { List < List < Cluster < CorrelationModel > > > clusterMap = new ArrayList < > ( ) ; for ( int i = 0 ; i <= dimensionality ; i ++ ) { clusterMap . add ( new ArrayList < Cluster < CorrelationModel > > ( ) ) ; } Cluster < Model > noise = null ; for ( Cluster < Model > clus : dbscanResult . getAllClusters ( ) ) { DBIDs group = clus . getIDs ( ) ; int dim = clus . isNoise ( ) ? dimensionality : npred . dimensionality ( clus . getIDs ( ) . iter ( ) ) ; if ( dim < dimensionality ) { EigenPairFilter filter = new FirstNEigenPairFilter ( dim ) ; List < Cluster < CorrelationModel > > correlationClusters = clusterMap . get ( dim ) ; PCAResult epairs = settings . pca . processIds ( group , relation ) ; int numstrong = filter . filter ( epairs . getEigenvalues ( ) ) ; PCAFilteredResult pcares = new PCAFilteredResult ( epairs . getEigenPairs ( ) , numstrong , 1. , 0. ) ; double [ ] centroid = Centroid . make ( relation , group ) . getArrayRef ( ) ; Cluster < CorrelationModel > correlationCluster = new Cluster < > ( "[" + dim + "_" + correlationClusters . size ( ) + "]" , group , new CorrelationModel ( pcares , centroid ) ) ; correlationClusters . add ( correlationCluster ) ; } else { if ( noise == null ) { noise = clus ; continue ; } ModifiableDBIDs merged = DBIDUtil . newHashSet ( noise . getIDs ( ) ) ; merged . addDBIDs ( clus . getIDs ( ) ) ; noise . setIDs ( merged ) ; } } if ( noise != null && noise . size ( ) > 0 ) { List < Cluster < CorrelationModel > > correlationClusters = clusterMap . get ( dimensionality ) ; EigenPairFilter filter = new FirstNEigenPairFilter ( dimensionality ) ; PCAResult epairs = settings . pca . processIds ( noise . getIDs ( ) , relation ) ; int numstrong = filter . filter ( epairs . getEigenvalues ( ) ) ; PCAFilteredResult pcares = new PCAFilteredResult ( epairs . getEigenPairs ( ) , numstrong , 1. , 0. ) ; double [ ] centroid = Centroid . make ( relation , noise . getIDs ( ) ) . getArrayRef ( ) ; Cluster < CorrelationModel > correlationCluster = new Cluster < > ( "[noise]" , noise . getIDs ( ) , new CorrelationModel ( pcares , centroid ) ) ; correlationClusters . add ( correlationCluster ) ; } for ( int i = dimensionality ; i > 0 ; i -- ) { if ( ! clusterMap . get ( i ) . isEmpty ( ) ) { break ; } clusterMap . remove ( i ) ; } return clusterMap ; }
Extracts the correlation clusters and noise from the copac result and
returns a mapping of correlation dimension to maps of clusters within this
correlation dimension. Each cluster is defined by the basis vectors
defining the subspace in which the cluster appears.

@param dbscanResult DBSCAN clustering to use
@param relation the database containing the objects
@param dimensionality the dimensionality of the feature space
@param npred ERiC predicate
@return a list of clusters for each dimensionality