assigner = new KDTreeIntEuclideanAssigner((IntCentroidsResult) tree); else assigner = tree.defaultHardAssigner();
public static List<QuantizerJob> getJobs(ClusterQuantiserOptions cqo) throws IOException { final List<QuantizerJob> jobs = new ArrayList<QuantizerJob>( cqo.getConcurrency()); final int size = cqo.getInputFiles().size() / cqo.getConcurrency(); final SpatialClusters<?> clusters = IOUtils.read(new File(cqo.getTreeFile()), cqo.getClusterClass()); HardAssigner<?, ?, ?> assigner; if (!cqo.exactQuant) { assigner = clusters.defaultHardAssigner(); } else { if (clusters instanceof ByteCentroidsResult) assigner = new KDTreeByteEuclideanAssigner((ByteCentroidsResult) clusters); else assigner = new KDTreeIntEuclideanAssigner((IntCentroidsResult) clusters); } QuantizerJob.count = 0; QuantizerJob.total = cqo.getInputFiles().size(); for (int i = 0; i < cqo.getConcurrency() - 1; i++) { final QuantizerJob job = new QuantizerJob(cqo, cqo.getInputFiles().subList(i * size, (i + 1) * size), clusters, assigner); jobs.add(job); } // add remaining final QuantizerJob job = new QuantizerJob(cqo, cqo.getInputFiles().subList((cqo.getConcurrency() - 1) * size, cqo.getInputFiles().size()), clusters, assigner); jobs.add(job); return jobs; }
protected SpectralIndexedClusters eigenspaceCluster(IndependentPair<double[], double[][]> lowestCols) { final SpatialClusterer<? extends SpatialClusters<double[]>, double[]> clusterer = conf.internal.apply(lowestCols); // Cluster the rows with the internal spatial clusterer final SpatialClusters<double[]> cluster = clusterer.cluster(lowestCols.getSecondObject()); // if the clusters contain the cluster indexes of the training examples // use those if (cluster instanceof IndexClusters) { final IndexClusters clusters = new IndexClusters(((IndexClusters) cluster).clusters()); // logger.debug(clusters); return new SpectralIndexedClusters(clusters, lowestCols); } // Otherwise attempt to assign values to clusters final int[] clustered = cluster.defaultHardAssigner().assign(lowestCols.getSecondObject()); // done! return new SpectralIndexedClusters(new IndexClusters(clustered), lowestCols); }