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