/** * Construct the assigner using the given cluster data and * distance function. The assigner will operate in exact mode, * using a {@link FloatNearestNeighboursExact}. * * @param data the cluster data * @param comparison the distance function * @param numNeighbours the number of nearest neighbours to select. */ public FloatKNNAssigner(float[][] data, FloatFVComparison comparison, int numNeighbours) { this.numNeighbours = numNeighbours; nn = new FloatNearestNeighboursExact(data, comparison); }
@Override public FloatNearestNeighboursExact create(float[][] data) { return new FloatNearestNeighboursExact(data, distance); } }
/** * Construct the assigner using the given cluster data and * distance function. * * @param data the cluster data * @param comparison the distance function */ public ExactFloatAssigner(float[][] data, FloatFVComparator comparison) { nn = new FloatNearestNeighboursExact(data, comparison); }
@Override public FloatNearestNeighboursExact create(float[][] data) { return new FloatNearestNeighboursExact(data, distance); } }
/** * Construct the assigner using the given cluster data and * distance function. * * @param provider the cluster data provider * @param comparison the distance function */ public ExactFloatAssigner(CentroidsProvider<float[]> provider, FloatFVComparator comparison) { nn = new FloatNearestNeighboursExact(provider.getCentroids(), comparison); }
/** * Construct the assigner using the given cluster data and * distance function. The assigner will operate in exact mode, * using a {@link FloatNearestNeighboursExact}. * * @param provider the cluster data provider * @param comparison the distance function * @param numNeighbours the number of nearest neighbours to select. */ public FloatKNNAssigner(CentroidsProvider<float[]> provider, FloatFVComparison comparison, int numNeighbours) { this.numNeighbours = numNeighbours; nn = new FloatNearestNeighboursExact(provider.getCentroids(), comparison); }
/** * Construct the assigner using the given cluster data. The assigner * is backed by either a {@link FloatNearestNeighboursExact} or * {@link FloatNearestNeighboursKDTree}, depending on whether the exact * parameter is true or false. If the parameter is true, then the * resultant {@link FloatNearestNeighboursExact} 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 FloatKNNAssigner(float[][] data, boolean exact, int numNeighbours) { this.numNeighbours = numNeighbours; if (exact) { nn = new FloatNearestNeighboursExact(data); } else { nn = new FloatNearestNeighboursKDTree(data, FloatNearestNeighboursKDTree.DEFAULT_NTREES, FloatNearestNeighboursKDTree.DEFAULT_NCHECKS); } }
/** * Construct the assigner using the given cluster data. The assigner * is backed by either a {@link FloatNearestNeighboursExact} or * {@link FloatNearestNeighboursKDTree}, depending on whether the exact * parameter is true or false. If the parameter is true, then the * resultant {@link FloatNearestNeighboursExact} 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 FloatKNNAssigner(CentroidsProvider<float[]> provider, boolean exact, int numNeighbours) { this.numNeighbours = numNeighbours; if (exact) { nn = new FloatNearestNeighboursExact(provider.getCentroids()); } else { if (provider instanceof FloatNearestNeighboursProvider) { FloatNearestNeighbours internal = ((FloatNearestNeighboursProvider)provider).getNearestNeighbours(); if (internal != null && internal instanceof FloatNearestNeighboursKDTree) { nn = (FloatNearestNeighboursKDTree) internal; return; } } nn = new FloatNearestNeighboursKDTree(provider.getCentroids(), FloatNearestNeighboursKDTree.DEFAULT_NTREES, FloatNearestNeighboursKDTree.DEFAULT_NCHECKS); } }