/** * Construct the assigner using the given cluster data and * distance function. * * @param data the cluster data * @param comparison the distance function */ public ExactShortAssigner(short[][] data, ShortFVComparator comparison) { nn = new ShortNearestNeighboursExact(data, comparison); }
@Override public ShortNearestNeighboursExact create(short[][] data) { return new ShortNearestNeighboursExact(data, distance); } }
@Override public ShortNearestNeighboursExact create(short[][] data) { return new ShortNearestNeighboursExact(data, distance); } }
/** * Construct the assigner using the given cluster data and * distance function. The assigner will operate in exact mode, * using a {@link ShortNearestNeighboursExact}. * * @param data the cluster data * @param comparison the distance function * @param numNeighbours the number of nearest neighbours to select. */ public ShortKNNAssigner(short[][] data, ShortFVComparison comparison, int numNeighbours) { this.numNeighbours = numNeighbours; nn = new ShortNearestNeighboursExact(data, comparison); }
/** * Construct the assigner using the given cluster data and * distance function. * * @param provider the cluster data provider * @param comparison the distance function */ public ExactShortAssigner(CentroidsProvider<short[]> provider, ShortFVComparator comparison) { nn = new ShortNearestNeighboursExact(provider.getCentroids(), comparison); }
/** * Construct the assigner using the given cluster data and * distance function. The assigner will operate in exact mode, * using a {@link ShortNearestNeighboursExact}. * * @param provider the cluster data provider * @param comparison the distance function * @param numNeighbours the number of nearest neighbours to select. */ public ShortKNNAssigner(CentroidsProvider<short[]> provider, ShortFVComparison comparison, int numNeighbours) { this.numNeighbours = numNeighbours; nn = new ShortNearestNeighboursExact(provider.getCentroids(), comparison); }
/** * 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. 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); } }