List of usage examples for org.apache.mahout.math.neighborhood UpdatableSearcher size
public abstract int size();
From source file:eu.stratosphere.library.clustering.DistributedOnePassKMeans.BallKMeans.java
License:Apache License
public BallKMeans(UpdatableSearcher searcher, int numClusters, int maxNumIterations, double trimFraction, boolean kMeansPlusPlusInit, boolean correctWeights, double testProbability, int numRuns) { Preconditions.checkArgument(searcher.size() == 0, "Searcher must be empty initially to populate with centroids"); Preconditions.checkArgument(numClusters > 0, "The requested number of clusters must be positive"); Preconditions.checkArgument(maxNumIterations > 0, "The maximum number of iterations must be positive"); Preconditions.checkArgument(trimFraction > 0, "The trim fraction must be positive"); Preconditions.checkArgument(testProbability >= 0 && testProbability < 1, "The testProbability must be in [0, 1)"); Preconditions.checkArgument(numRuns > 0, "There has to be at least one run"); this.centroids = searcher; this.numClusters = numClusters; this.maxNumIterations = maxNumIterations; this.trimFraction = trimFraction; this.kMeansPlusPlusInit = kMeansPlusPlusInit; this.correctWeights = correctWeights; this.testProbability = testProbability; this.splitTrainTest = testProbability > 0; this.numRuns = numRuns; this.random = RandomUtils.getRandom(); }
From source file:org.plista.kornakapi.core.training.StramingKMeansClusterer.java
License:Apache License
/** * retrain model//from www .j a v a 2s . c om */ public void cluster() { long start = System.currentTimeMillis(); List<Centroid> data = model.getData(); UpdatableSearcher centroids = clusterer.cluster(data); long estimateDuration = System.currentTimeMillis() - start; this.model.updateCentroids(centroids); if (log.isInfoEnabled()) { log.info("Model trained in {} ms, created [{}] Clusters", estimateDuration, centroids.size()); } }
From source file:org.plista.kornakapi.core.training.StramingKMeansClusterer.java
License:Apache License
/** * just stream new available data-points into old coordinate system *///from w w w .j a v a 2s .co m public void stream() { long start = System.currentTimeMillis(); List<Centroid> data = model.getNewData(); UpdatableSearcher centroids = clusterer.cluster(data); long estimateDuration = System.currentTimeMillis() - start; this.model.updateCentroids(centroids); if (log.isInfoEnabled()) { log.info("Model trained in {} ms, created [{}] Clusters", estimateDuration, centroids.size()); } }