private KMeansConfiguration<IntNearestNeighbours, int[]> confInt(int ndims) { NearestNeighboursFactory<? extends IntNearestNeighbours, int[]> assigner; final ExecutorService pool = Executors.newFixedThreadPool(jj, new DaemonThreadFactory()); if (E) { assigner = new IntNearestNeighboursExact.Factory(); } else { assigner = new IntNearestNeighboursKDTree.Factory(NT, NC); } final KMeansConfiguration<IntNearestNeighbours, int[]> conf = new KMeansConfiguration<IntNearestNeighbours, int[]>( K, assigner, I, B, pool); return conf; }
@Override public SpatialClusters<?> create(byte[][] data) { if (this.precision == Precision.BYTE) { final KMeansConfiguration<ByteNearestNeighbours, byte[]> kmc = new KMeansConfiguration<ByteNearestNeighbours, byte[]>(); if (exactMode) { kmc.setNearestNeighbourFactory(new ByteNearestNeighboursExact.Factory()); } else { kmc.setNearestNeighbourFactory(new ByteNearestNeighboursKDTree.Factory()); } final HierarchicalByteKMeans tree = new HierarchicalByteKMeans(kmc, data[0].length, K, depth); System.err.printf("Building vocabulary tree\n"); return tree.cluster(data); } else { final KMeansConfiguration<IntNearestNeighbours, int[]> kmc = new KMeansConfiguration<IntNearestNeighbours, int[]>(); if (exactMode) { kmc.setNearestNeighbourFactory(new IntNearestNeighboursExact.Factory()); } else { kmc.setNearestNeighbourFactory(new IntNearestNeighboursKDTree.Factory()); } final HierarchicalIntKMeans tree = new HierarchicalIntKMeans(kmc, data[0].length, K, depth); System.err.printf("Building vocabulary tree\n"); return tree.cluster(ByteArrayConverter.byteToInt(data)); } }
/** * Convenience method to quickly create an approximate {@link IntKMeans} * using an ensemble of KD-Trees to perform nearest-neighbour lookup. All * parameters other than the number of clusters are set * at their defaults, but can be manipulated through the configuration * returned by {@link #getConfiguration()}. * <p> * Euclidean distance is used to measure the distance between points. * * @param K * the number of clusters * @return a {@link IntKMeans} instance configured for approximate k-means * using an ensemble of KD-Trees */ public static IntKMeans createKDTreeEnsemble(int K) { final KMeansConfiguration<IntNearestNeighbours, int[]> conf = new KMeansConfiguration<IntNearestNeighbours, int[]>(K, new IntNearestNeighboursKDTree.Factory()); return new IntKMeans(conf); }
private KMeansConfiguration<IntNearestNeighbours, int[]> confInt(int ndims) { NearestNeighboursFactory<? extends IntNearestNeighbours, int[]> assigner; final ExecutorService pool = Executors.newFixedThreadPool(jj, new DaemonThreadFactory()); if (E) { assigner = new IntNearestNeighboursExact.Factory(); } else { assigner = new IntNearestNeighboursKDTree.Factory(NT, NC); } final KMeansConfiguration<IntNearestNeighbours, int[]> conf = new KMeansConfiguration<IntNearestNeighbours, int[]>( K, assigner, I, B, pool); return conf; }