/** * Construct the assigner using the given cluster data. * * @param data the cluster data */ public KDTreeShortEuclideanAssigner(short[][] data) { nn = new ShortNearestNeighboursKDTree(data, ShortNearestNeighboursKDTree.DEFAULT_NTREES, ShortNearestNeighboursKDTree.DEFAULT_NCHECKS); }
@Override public ShortNearestNeighboursKDTree create(short[][] data) { return new ShortNearestNeighboursKDTree(data, ntrees, nchecks); } }
@Override public ShortNearestNeighboursKDTree create(short[][] data) { return new ShortNearestNeighboursKDTree(data, ntrees, nchecks); } }
/** * Construct the assigner using the given cluster data. The assigner * is backed by either a {@link ShortNearestNeighboursExact} or * {@link ShortNearestNeighboursKDTree}, depending on whether the exact * parameter is true or false. If the parameter is true, then the * resultant {@link ShortNearestNeighboursExact} will use Euclidean * distance. * * @param data the cluster data * @param exact if true, then use exact mode; false implies approximate mode. * @param numNeighbours the number of nearest neighbours to select. */ public ShortKNNAssigner(short[][] data, boolean exact, int numNeighbours) { this.numNeighbours = numNeighbours; if (exact) { nn = new ShortNearestNeighboursExact(data); } else { nn = new ShortNearestNeighboursKDTree(data, ShortNearestNeighboursKDTree.DEFAULT_NTREES, ShortNearestNeighboursKDTree.DEFAULT_NCHECKS); } }
/** * Construct the assigner using the given cluster data. * * @param provider the cluster data provider */ public KDTreeShortEuclideanAssigner(CentroidsProvider<short[]> provider) { if (provider instanceof ShortNearestNeighboursProvider) { ShortNearestNeighbours internal = ((ShortNearestNeighboursProvider)provider).getNearestNeighbours(); if (internal != null && internal instanceof ShortNearestNeighboursKDTree) { nn = (ShortNearestNeighboursKDTree) internal; return; } } nn = new ShortNearestNeighboursKDTree(provider.getCentroids(), ShortNearestNeighboursKDTree.DEFAULT_NTREES, ShortNearestNeighboursKDTree.DEFAULT_NCHECKS); }
/** * Construct the assigner using the given cluster data. The assigner * is backed by either a {@link ShortNearestNeighboursExact} or * {@link ShortNearestNeighboursKDTree}, depending on whether the exact * parameter is true or false. If the parameter is true, then the * resultant {@link ShortNearestNeighboursExact} will use Euclidean * distance. * * @param provider the cluster data provider * @param exact if true, then use exact mode; false implies approximate mode. * @param numNeighbours the number of nearest neighbours to select. */ public ShortKNNAssigner(CentroidsProvider<short[]> provider, boolean exact, int numNeighbours) { this.numNeighbours = numNeighbours; if (exact) { nn = new ShortNearestNeighboursExact(provider.getCentroids()); } else { if (provider instanceof ShortNearestNeighboursProvider) { ShortNearestNeighbours internal = ((ShortNearestNeighboursProvider)provider).getNearestNeighbours(); if (internal != null && internal instanceof ShortNearestNeighboursKDTree) { nn = (ShortNearestNeighboursKDTree) internal; return; } } nn = new ShortNearestNeighboursKDTree(provider.getCentroids(), ShortNearestNeighboursKDTree.DEFAULT_NTREES, ShortNearestNeighboursKDTree.DEFAULT_NCHECKS); } }