private ShortKMeans newShortKMeans(int K) { KMeansConfiguration<ShortNearestNeighbours, short[]> newConf = conf.clone(); newConf.setK(K); return new ShortKMeans(newConf); } }
/** * Convenience method to quickly create an exact {@link ShortKMeans}. All * parameters other than the number of clusters are set * at their defaults, but can be manipulated through the configuration * returned by {@link #getConfiguration()}. * <p> * Euclidean distance is used to measure the distance between points. * * @param K * the number of clusters * @return a {@link ShortKMeans} instance configured for exact k-means */ public static ShortKMeans createExact(int K) { final KMeansConfiguration<ShortNearestNeighbours, short[]> conf = new KMeansConfiguration<ShortNearestNeighbours, short[]>(K, new ShortNearestNeighboursExact.Factory()); return new ShortKMeans(conf); }
/** * Convenience method to quickly create an approximate {@link ShortKMeans} * using an ensemble of KD-Trees to perform nearest-neighbour lookup. All * parameters other than the number of clusters are set * at their defaults, but can be manipulated through the configuration * returned by {@link #getConfiguration()}. * <p> * Euclidean distance is used to measure the distance between points. * * @param K * the number of clusters * @return a {@link ShortKMeans} instance configured for approximate k-means * using an ensemble of KD-Trees */ public static ShortKMeans createKDTreeEnsemble(int K) { final KMeansConfiguration<ShortNearestNeighbours, short[]> conf = new KMeansConfiguration<ShortNearestNeighbours, short[]>(K, new ShortNearestNeighboursKDTree.Factory()); return new ShortKMeans(conf); }
/** * Convenience method to quickly create an exact {@link ShortKMeans}. All * parameters other than the number of clusters and number * of iterations are set at their defaults, but can be manipulated through * the configuration returned by {@link #getConfiguration()}. * <p> * Euclidean distance is used to measure the distance between points. * * @param K * the number of clusters * @param niters * maximum number of iterations * @return a {@link ShortKMeans} instance configured for exact k-means */ public static ShortKMeans createExact(int K, int niters) { final KMeansConfiguration<ShortNearestNeighbours, short[]> conf = new KMeansConfiguration<ShortNearestNeighbours, short[]>(K, new ShortNearestNeighboursExact.Factory(), niters); return new ShortKMeans(conf); }