本文整理了Java中de.lmu.ifi.dbs.elki.algorithm.clustering.kmeans.KMeans.run()
方法的一些代码示例,展示了KMeans.run()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KMeans.run()
方法的具体详情如下:
包路径:de.lmu.ifi.dbs.elki.algorithm.clustering.kmeans.KMeans
类名称:KMeans
方法名:run
[英]Run the clustering algorithm.
[中]运行聚类算法。
代码示例来源:origin: elki-project/elki
LOG.statistics(new StringStatistic(KEY + ".initialization", initializer.toString()));
splitInitializer.setInitialMeans(initializer.chooseInitialMeans(database, relation, k_min, getDistanceFunction()));
Clustering<M> clustering = innerKMeans.run(database, relation);
clustering = innerKMeans.run(database, relation);
clusters.clear();
clusters.addAll(clustering.getAllClusters());
代码示例来源:origin: de.lmu.ifi.dbs.elki/elki-clustering
LOG.statistics(new StringStatistic(KEY + ".initialization", initializer.toString()));
splitInitializer.setInitialMeans(initializer.chooseInitialMeans(database, relation, k_min, getDistanceFunction()));
Clustering<M> clustering = innerKMeans.run(database, relation);
clustering = innerKMeans.run(database, relation);
clusters.clear();
clusters.addAll(clustering.getAllClusters());
代码示例来源:origin: de.lmu.ifi.dbs.elki/elki
Clustering<M> clustering = innerKMeans.run(database, relation);
clustering = innerKMeans.run(database, relation);
clusters.clear();
clusters.addAll(clustering.getAllClusters());
代码示例来源:origin: elki-project/elki
Clustering<M> innerResult = innerkMeans.run(proxyDB);
代码示例来源:origin: de.lmu.ifi.dbs.elki/elki-clustering
Clustering<M> innerResult = innerkMeans.run(proxyDB);
代码示例来源:origin: de.lmu.ifi.dbs.elki/elki
@Override
public <T extends V, O extends NumberVector> List<O> chooseInitialMeans(Database database, Relation<T> relation, int k, NumberVectorDistanceFunction<? super T> distanceFunction, NumberVector.Factory<O> factory) {
final DBIDs sample = DBIDUtil.randomSample(relation.getDBIDs(), rate, rnd);
// Ugly cast, sorry
@SuppressWarnings("unchecked")
Relation<V> rel = (Relation<V>) relation;
// FIXME: This does not necessarily hold. Check and fail!
if(!distanceFunction.getInputTypeRestriction().isAssignableFromType(TypeUtil.NUMBER_VECTOR_FIELD)) {
LoggingUtil.warning("Initializing k-means with k-means using specialized distance functions MAY fail, if the initialization method does require a distance defined on arbitrary number vectors.");
}
@SuppressWarnings("unchecked")
NumberVectorDistanceFunction<? super V> pdf = (NumberVectorDistanceFunction<? super V>) distanceFunction;
ProxyView<V> proxyv = new ProxyView<>(sample, rel);
ProxyDatabase proxydb = new ProxyDatabase(sample, proxyv);
innerkMeans.setK(k);
innerkMeans.setDistanceFunction(pdf);
Clustering<?> clusters = innerkMeans.run(proxydb, proxyv);
List<O> means = new ArrayList<>();
for(Cluster<?> cluster : clusters.getAllClusters()) {
means.add(factory.newNumberVector(ModelUtil.getPrototype(cluster.getModel(), relation)));
}
return means;
}
代码示例来源:origin: elki-project/elki
@Override
public Clustering<M> run(Database database, Relation<V> relation) {
if(!(innerkMeans.getDistanceFunction() instanceof PrimitiveDistanceFunction)) {
throw new AbortException("K-Means results can only be evaluated for primitive distance functions, got: " + innerkMeans.getDistanceFunction().getClass());
}
@SuppressWarnings("unchecked")
final NumberVectorDistanceFunction<? super NumberVector> df = (NumberVectorDistanceFunction<? super NumberVector>) innerkMeans.getDistanceFunction();
Clustering<M> bestResult = null;
double bestCost = Double.NaN;
FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("K-means iterations", trials, LOG) : null;
for(int i = 0; i < trials; i++) {
Clustering<M> currentCandidate = innerkMeans.run(database, relation);
double currentCost = qualityMeasure.quality(currentCandidate, df, relation);
LOG.verbose("Cost of candidate " + i + ": " + currentCost);
if(qualityMeasure.isBetter(currentCost, bestCost)) {
bestResult = currentCandidate;
bestCost = currentCost;
}
LOG.incrementProcessed(prog);
}
LOG.ensureCompleted(prog);
return bestResult;
}
代码示例来源:origin: de.lmu.ifi.dbs.elki/elki-clustering
@Override
public Clustering<M> run(Database database, Relation<V> relation) {
if(!(innerkMeans.getDistanceFunction() instanceof PrimitiveDistanceFunction)) {
throw new AbortException("K-Means results can only be evaluated for primitive distance functions, got: " + innerkMeans.getDistanceFunction().getClass());
}
@SuppressWarnings("unchecked")
final NumberVectorDistanceFunction<? super NumberVector> df = (NumberVectorDistanceFunction<? super NumberVector>) innerkMeans.getDistanceFunction();
Clustering<M> bestResult = null;
double bestCost = Double.NaN;
FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("K-means iterations", trials, LOG) : null;
for(int i = 0; i < trials; i++) {
Clustering<M> currentCandidate = innerkMeans.run(database, relation);
double currentCost = qualityMeasure.quality(currentCandidate, df, relation);
LOG.verbose("Cost of candidate " + i + ": " + currentCost);
if(qualityMeasure.isBetter(currentCost, bestCost)) {
bestResult = currentCandidate;
bestCost = currentCost;
}
LOG.incrementProcessed(prog);
}
LOG.ensureCompleted(prog);
return bestResult;
}
代码示例来源:origin: de.lmu.ifi.dbs.elki/elki
Clustering<M> innerResult = innerkMeans.run(proxyDB);
代码示例来源:origin: elki-project/elki
@Override
public double[][] chooseInitialMeans(Database database, Relation<? extends NumberVector> relation, int k, NumberVectorDistanceFunction<?> distanceFunction) {
if(relation.size() < k) {
throw new IllegalArgumentException("Cannot choose k=" + k + " means from N=" + relation.size() + " < k objects.");
}
final DBIDs sample = DBIDUtil.randomSample(relation.getDBIDs(), rate, rnd);
if(sample.size() < k) {
throw new IllegalArgumentException("Sampling rate=" + rate + " from N=" + relation.size() + " yields only " + sample.size() + " < k objects.");
}
// Ugly cast, sorry
@SuppressWarnings("unchecked")
Relation<V> rel = (Relation<V>) relation;
// FIXME: This does not necessarily hold. Check and fail!
if(!distanceFunction.getInputTypeRestriction().isAssignableFromType(TypeUtil.NUMBER_VECTOR_FIELD)) {
LoggingUtil.warning("Initializing k-means with k-means using specialized distance functions MAY fail, if the initialization method does require a distance defined on arbitrary number vectors.");
}
@SuppressWarnings("unchecked")
NumberVectorDistanceFunction<? super V> pdf = (NumberVectorDistanceFunction<? super V>) distanceFunction;
ProxyView<V> proxyv = new ProxyView<>(sample, rel);
ProxyDatabase proxydb = new ProxyDatabase(sample, proxyv);
innerkMeans.setK(k);
innerkMeans.setDistanceFunction(pdf);
Clustering<?> clusters = innerkMeans.run(proxydb, proxyv);
double[][] means = new double[clusters.getAllClusters().size()][];
int i = 0;
for(Cluster<?> cluster : clusters.getAllClusters()) {
means[i++] = ModelUtil.getPrototype(cluster.getModel(), relation).toArray();
}
return means;
}
代码示例来源:origin: de.lmu.ifi.dbs.elki/elki
@Override
public Clustering<M> run(Database database, Relation<V> relation) {
if(!(innerkMeans.getDistanceFunction() instanceof PrimitiveDistanceFunction)) {
throw new AbortException("K-Means results can only be evaluated for primitive distance functions, got: " + innerkMeans.getDistanceFunction().getClass());
}
@SuppressWarnings("unchecked")
final NumberVectorDistanceFunction<? super NumberVector> df = (NumberVectorDistanceFunction<? super NumberVector>) innerkMeans.getDistanceFunction();
Clustering<M> bestResult = null;
double bestCost = Double.NaN;
FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("K-means iterations", trials, LOG) : null;
for(int i = 0; i < trials; i++) {
Clustering<M> currentCandidate = innerkMeans.run(database, relation);
double currentCost = qualityMeasure.quality(currentCandidate, df, relation);
if(LOG.isVerbose()) {
LOG.verbose("Cost of candidate " + i + ": " + currentCost);
}
if(qualityMeasure.isBetter(currentCost, bestCost)) {
bestResult = currentCandidate;
bestCost = currentCost;
}
LOG.incrementProcessed(prog);
}
LOG.ensureCompleted(prog);
return bestResult;
}
代码示例来源:origin: de.lmu.ifi.dbs.elki/elki-clustering
@Override
public double[][] chooseInitialMeans(Database database, Relation<? extends NumberVector> relation, int k, NumberVectorDistanceFunction<?> distanceFunction) {
if(relation.size() < k) {
throw new IllegalArgumentException("Cannot choose k=" + k + " means from N=" + relation.size() + " < k objects.");
}
final DBIDs sample = DBIDUtil.randomSample(relation.getDBIDs(), rate, rnd);
if(sample.size() < k) {
throw new IllegalArgumentException("Sampling rate=" + rate + " from N=" + relation.size() + " yields only " + sample.size() + " < k objects.");
}
// Ugly cast, sorry
@SuppressWarnings("unchecked")
Relation<V> rel = (Relation<V>) relation;
// FIXME: This does not necessarily hold. Check and fail!
if(!distanceFunction.getInputTypeRestriction().isAssignableFromType(TypeUtil.NUMBER_VECTOR_FIELD)) {
LoggingUtil.warning("Initializing k-means with k-means using specialized distance functions MAY fail, if the initialization method does require a distance defined on arbitrary number vectors.");
}
@SuppressWarnings("unchecked")
NumberVectorDistanceFunction<? super V> pdf = (NumberVectorDistanceFunction<? super V>) distanceFunction;
ProxyView<V> proxyv = new ProxyView<>(sample, rel);
ProxyDatabase proxydb = new ProxyDatabase(sample, proxyv);
innerkMeans.setK(k);
innerkMeans.setDistanceFunction(pdf);
Clustering<?> clusters = innerkMeans.run(proxydb, proxyv);
double[][] means = new double[clusters.getAllClusters().size()][];
int i = 0;
for(Cluster<?> cluster : clusters.getAllClusters()) {
means[i++] = ModelUtil.getPrototype(cluster.getModel(), relation).toArray();
}
return means;
}
代码示例来源:origin: elki-project/elki
Clustering<M> childClustering = innerKMeans.run(proxyDB);
代码示例来源:origin: de.lmu.ifi.dbs.elki/elki-clustering
Clustering<M> childClustering = innerKMeans.run(proxyDB);
代码示例来源:origin: de.lmu.ifi.dbs.elki/elki
Clustering<M> childClustering = innerKMeans.run(proxyDB);
代码示例来源:origin: elki-project/elki
Clustering<?> c = clusterer.run(database, relation);
代码示例来源:origin: de.lmu.ifi.dbs.elki/elki
Clustering<?> c = clusterer.run(database, relation);
内容来源于网络,如有侵权,请联系作者删除!