/** * Initialize with the canopy centers of the Canopy clustering method * * @param data the training data * @throws Exception if a problem occurs */ protected void canopyInit(Instances data) throws Exception { if (m_canopyClusters == null) { m_canopyClusters = new Canopy(); m_canopyClusters.setNumClusters(m_NumClusters); m_canopyClusters.setSeed(getSeed()); m_canopyClusters.setT2(getCanopyT2()); m_canopyClusters.setT1(getCanopyT1()); m_canopyClusters .setMaxNumCandidateCanopiesToHoldInMemory(getCanopyMaxNumCanopiesToHoldInMemory()); m_canopyClusters.setPeriodicPruningRate(getCanopyPeriodicPruningRate()); m_canopyClusters.setMinimumCanopyDensity(getCanopyMinimumCanopyDensity()); m_canopyClusters.setDebug(getDebug()); m_canopyClusters.buildClusterer(data); } m_ClusterCentroids = m_canopyClusters.getCanopies(); }
private void assignCanopiesToCanopyCenters() { // assign canopies to each canopy center m_clusterCanopies = new ArrayList<long[]>(); for (int i = 0; i < m_canopies.size(); i++) { Instance inst = m_canopies.instance(i); try { long[] assignments = assignCanopies(inst); m_clusterCanopies.add(assignments); } catch (Exception ex) { ex.printStackTrace(); } } }
public static void main(String[] args) { runClusterer(new Canopy(), args); }
System.err.println("[CanopyMap] max canopy clusters: " + nC); try { m_canopy.setNumClusters(Integer.parseInt(nC)); } catch (Exception ex) { throw new DistributedWekaException(ex); .isEmpty(getMaxNumCandidateCanopiesToHoldInMemory())) { m_canopy .setMaxNumCandidateCanopiesToHoldInMemory(Integer .parseInt(environmentSubstitute(getMaxNumCandidateCanopiesToHoldInMemory()))); m_canopy.setPeriodicPruningRate(Integer .parseInt(environmentSubstitute(getPeriodicPruningRate()))); m_canopy.setMinimumCanopyDensity(Double .parseDouble(environmentSubstitute(getMinimumCanopyDensity()))); m_canopy.setT2(m_hT2); m_canopy.setT1(m_hT1); m_canopy.setMissingValuesReplacer((Filter) m_missingValuesReplacer); initInsts = ((Filter) m_finalFullPreprocess).getOutputFormat(); m_canopy.buildClusterer(initInsts); m_canopy.initializeDistanceFunction(dummyDistancePrimer);
setNumClusters(Integer.parseInt(temp)); setMaxNumCandidateCanopiesToHoldInMemory(Integer.parseInt(temp)); setPeriodicPruningRate(Integer.parseInt(temp)); setMinimumCanopyDensity(Double.parseDouble(temp)); setT2(Double.parseDouble(temp)); setT1(Double.parseDouble(temp)); setDontReplaceMissingValues(Utils.getFlag('M', options));
int finalNumCanopies) { Instances collectedCanopies = new Instances(canopies.get(0).getCanopies(), 0); Instances finalCanopies = new Instances(collectedCanopies, 0); Instances tempC = c.getCanopies(); Canopy finalC = new Canopy(); finalC.setCanopies(finalCanopies); finalC.setMissingValuesReplacer(missingValuesReplacer); finalC.m_distanceFunction = finalDistanceFunction; finalC.m_canopyCenters = finalCenters; finalC.m_t1 = aggregationT1; try { finalC.setNumClusters(finalNumCanopies); } catch (Exception e) { finalC.updateFinished();
channels.add(ColorClustering.Channel.fromLabel("Saturation")); ColorClustering colorClustering = new ColorClustering(image,14, channels); Canopy clusterer = new Canopy(); try { clusterer.setNumClusters(2); } catch (Exception e) { e.printStackTrace();
protected int clusterInstance(Instance inst, long[] instanceCanopies) { double minDist = Integer.MAX_VALUE; int bestCluster = 0; for (int i = 0; i < m_NumClusters; i++) { double dist; if (m_speedUpDistanceCompWithCanopies && instanceCanopies != null && instanceCanopies.length > 0) { try { if (!Canopy.nonEmptyCanopySetIntersection( m_centroidCanopyAssignments.get(i), instanceCanopies)) { // System.err.println("Skipping distance calc... " // + Canopy.printSingleAssignment(instanceCanopies)); continue; } } catch (Exception ex) { ex.printStackTrace(); } } dist = m_DistanceFunction.distance(inst, m_ClusterCentroids.instance(i), minDist); if (dist < minDist) { minDist = dist; bestCluster = i; } } return bestCluster; } }
setNumClusters(Integer.parseInt(temp)); setMaxNumCandidateCanopiesToHoldInMemory(Integer.parseInt(temp)); setPeriodicPruningRate(Integer.parseInt(temp)); setMinimumCanopyDensity(Double.parseDouble(temp)); setT2(Double.parseDouble(temp)); setT1(Double.parseDouble(temp)); setDontReplaceMissingValues(Utils.getFlag('M', options));
int finalNumCanopies) { Instances collectedCanopies = new Instances(canopies.get(0).getCanopies(), 0); Instances finalCanopies = new Instances(collectedCanopies, 0); Instances tempC = c.getCanopies(); Canopy finalC = new Canopy(); finalC.setCanopies(finalCanopies); finalC.setMissingValuesReplacer(missingValuesReplacer); finalC.m_distanceFunction = finalDistanceFunction; finalC.m_canopyCenters = finalCenters; finalC.m_t1 = aggregationT1; try { finalC.setNumClusters(finalNumCanopies); } catch (Exception e) { finalC.updateFinished();
public static void main(String[] args) { runClusterer(new Canopy(), args); }
protected int clusterInstance(Instance inst, long[] instanceCanopies) { double minDist = Integer.MAX_VALUE; int bestCluster = 0; for (int i = 0; i < m_NumClusters; i++) { double dist; if (m_speedUpDistanceCompWithCanopies && instanceCanopies != null && instanceCanopies.length > 0) { try { if (!Canopy.nonEmptyCanopySetIntersection( m_centroidCanopyAssignments.get(i), instanceCanopies)) { // System.err.println("Skipping distance calc... " // + Canopy.printSingleAssignment(instanceCanopies)); continue; } } catch (Exception ex) { ex.printStackTrace(); } } dist = m_DistanceFunction.distance(inst, m_ClusterCentroids.instance(i), minDist); if (dist < minDist) { minDist = dist; bestCluster = i; } } return bestCluster; } }
/** * Initialize with the canopy centers of the Canopy clustering method * * @param data the training data * @throws Exception if a problem occurs */ protected void canopyInit(Instances data) throws Exception { if (m_canopyClusters == null) { m_canopyClusters = new Canopy(); m_canopyClusters.setNumClusters(m_NumClusters); m_canopyClusters.setSeed(getSeed()); m_canopyClusters.setT2(getCanopyT2()); m_canopyClusters.setT1(getCanopyT1()); m_canopyClusters .setMaxNumCandidateCanopiesToHoldInMemory(getCanopyMaxNumCanopiesToHoldInMemory()); m_canopyClusters.setPeriodicPruningRate(getCanopyPeriodicPruningRate()); m_canopyClusters.setMinimumCanopyDensity(getCanopyMinimumCanopyDensity()); m_canopyClusters.setDebug(getDebug()); m_canopyClusters.buildClusterer(data); } m_ClusterCentroids = m_canopyClusters.getCanopies(); }
&& instanceCanopies.length > 0) { try { if (!Canopy.nonEmptyCanopySetIntersection( m_centroidCanopyAssignments.get(i), instanceCanopies)) { continue;
private void assignCanopiesToCanopyCenters() { // assign canopies to each canopy center m_clusterCanopies = new ArrayList<long[]>(); for (int i = 0; i < m_canopies.size(); i++) { Instance inst = m_canopies.instance(i); try { long[] assignments = assignCanopies(inst); m_clusterCanopies.add(assignments); } catch (Exception ex) { ex.printStackTrace(); } } }
m_canopyClusters = new Canopy(); m_canopyClusters.setNumClusters(m_NumClusters); m_canopyClusters.setSeed(getSeed()); m_canopyClusters.setT2(getCanopyT2()); m_canopyClusters.setT1(getCanopyT1()); m_canopyClusters .setMaxNumCandidateCanopiesToHoldInMemory(getCanopyMaxNumCanopiesToHoldInMemory()); m_canopyClusters.setPeriodicPruningRate(getCanopyPeriodicPruningRate()); m_canopyClusters.setMinimumCanopyDensity(getCanopyMinimumCanopyDensity()); m_canopyClusters.setDebug(getDebug()); m_canopyClusters.buildClusterer(initInstances); canopyInit(initInstances); m_initialStartPoints = new Instances(m_canopyClusters.getCanopies()); } else if (m_initializationMethod == FARTHEST_FIRST) { farthestFirstInit(initInstances); .assignCanopies(instances.instance(i))); for (int kk = 0; kk < m_ClusterCentroids.numInstances(); kk++) { m_centroidCanopyAssignments.add(m_canopyClusters .assignCanopies(m_ClusterCentroids.instance(kk)));
&& instanceCanopies.length > 0) { try { if (!Canopy.nonEmptyCanopySetIntersection( m_centroidCanopyAssignments.get(i), instanceCanopies)) { continue;
assignments = m_canopy.assignCanopies(toProcess); } catch (Exception e) { throw new DistributedWekaException(e);
m_canopyClusters = new Canopy(); m_canopyClusters.setNumClusters(m_NumClusters); m_canopyClusters.setSeed(getSeed()); m_canopyClusters.setT2(getCanopyT2()); m_canopyClusters.setT1(getCanopyT1()); m_canopyClusters .setMaxNumCandidateCanopiesToHoldInMemory(getCanopyMaxNumCanopiesToHoldInMemory()); m_canopyClusters.setPeriodicPruningRate(getCanopyPeriodicPruningRate()); m_canopyClusters.setMinimumCanopyDensity(getCanopyMinimumCanopyDensity()); m_canopyClusters.setDebug(getDebug()); m_canopyClusters.buildClusterer(initInstances); canopyInit(initInstances); m_initialStartPoints = new Instances(m_canopyClusters.getCanopies()); } else if (m_initializationMethod == FARTHEST_FIRST) { farthestFirstInit(initInstances); .assignCanopies(instances.instance(i))); for (int kk = 0; kk < m_ClusterCentroids.numInstances(); kk++) { m_centroidCanopyAssignments.add(m_canopyClusters .assignCanopies(m_ClusterCentroids.instance(kk)));
&& instanceCanopies.length > 0) { try { if (!Canopy.nonEmptyCanopySetIntersection( m_centroidCanopyAssignments.get(i), instanceCanopies)) { continue;