@Override public SpatialClusters<?> create(List<SampleBatch> batches) throws Exception { System.err.println("Constructing a FASTKMEANS cluster"); SpatialClusterer<?, ?> c = null; System.err.println("Constructing a fastkmeans worker: "); if (this.precision == Precision.BYTE) { final SampleBatchByteDataSource ds = new SampleBatchByteDataSource(batches); ds.setSeed(seed); c = new ByteKMeans(confByte(ds.numDimensions())); ((ByteKMeans) c).seed(seed); clusterInitOp.setClusterInit((ByteKMeans) c); return ((ByteKMeans) c).cluster(ds); } else { final SampleBatchIntDataSource ds = new SampleBatchIntDataSource(batches); ds.setSeed(seed); c = new IntKMeans(confInt(ds.numDimensions())); ((IntKMeans) c).seed(seed); return ((IntKMeans) c).cluster(ds); } }
@Override public SpatialClusters<?> create(byte[][] data) throws Exception { SpatialClusterer<?, ?> c = null; if (this.precision == Precision.BYTE) { c = new ByteKMeans(confByte(data[0].length)); ((ByteKMeans) c).seed(seed); if (clusterInitOp == null) clusterInitOp = clusterInit.getOptions(); clusterInitOp.setClusterInit((ByteKMeans) c); return ((ByteKMeans) c).cluster(data); } else { c = new IntKMeans(confInt(data[0].length)); ((IntKMeans) c).seed(seed); return ((IntKMeans) c).cluster(ByteArrayConverter.byteToInt(data)); } }