本文整理汇总了Java中de.lmu.ifi.dbs.elki.database.ids.DBIDs.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java DBIDs.isEmpty方法的具体用法?Java DBIDs.isEmpty怎么用?Java DBIDs.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.lmu.ifi.dbs.elki.database.ids.DBIDs
的用法示例。
在下文中一共展示了DBIDs.isEmpty方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: insertAll
import de.lmu.ifi.dbs.elki.database.ids.DBIDs; //导入方法依赖的package包/类
/**
* Inserts the specified objects into this index. If a bulk load mode is
* implemented, the objects are inserted in one bulk.
*
* @param ids the objects to be inserted
*/
@Override
public final void insertAll(DBIDs ids) {
if(ids.isEmpty() || (ids.size() == 1)) {
return;
}
// Make an example leaf
if(canBulkLoad()) {
List<SpatialEntry> leafs = new ArrayList<>(ids.size());
for (DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
leafs.add(createNewLeafEntry(DBIDUtil.deref(iter)));
}
bulkLoad(leafs);
}
else {
for (DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
insert(iter);
}
}
doExtraIntegrityChecks();
}
示例2: insertAll
import de.lmu.ifi.dbs.elki.database.ids.DBIDs; //导入方法依赖的package包/类
/**
* Inserts the specified objects into this index. If a bulk load mode is
* implemented, the objects are inserted in one bulk.
*
* @param ids the objects to be inserted
*/
@Override
public final void insertAll(DBIDs ids) {
if(ids.isEmpty() || (ids.size() == 1)) {
return;
}
// Make an example leaf
if(canBulkLoad()) {
List<RdKNNEntry> leafs = new ArrayList<>(ids.size());
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
leafs.add(createNewLeafEntry(DBIDUtil.deref(iter)));
}
bulkLoad(leafs);
}
else {
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
insert(iter);
}
}
doExtraIntegrityChecks();
}
示例3: insertAll
import de.lmu.ifi.dbs.elki.database.ids.DBIDs; //导入方法依赖的package包/类
/**
* Inserts the specified objects into this index. If a bulk load mode is
* implemented, the objects are inserted in one bulk.
*
* @param ids the objects to be inserted
*/
@Override
public void insertAll(DBIDs ids) {
if(ids.isEmpty() || (ids.size() == 1)) {
return;
}
// Make an example leaf
if(canBulkLoad()) {
List<SpatialEntry> leafs = new ArrayList<>(ids.size());
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
leafs.add(createNewLeafEntry(iter));
}
bulkLoad(leafs);
}
else {
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
insert(DBIDUtil.deref(iter));
}
}
doExtraIntegrityChecks();
}
示例4: insertAll
import de.lmu.ifi.dbs.elki.database.ids.DBIDs; //导入方法依赖的package包/类
/**
* Inserts the specified objects into this index. If a bulk load mode is
* implemented, the objects are inserted in one bulk.
*
* @param ids the objects to be inserted
*/
@Override
public final void insertAll(DBIDs ids) {
if(ids.isEmpty() || (ids.size() == 1)) {
return;
}
// Make an example leaf
if(canBulkLoad()) {
List<DeLiCluEntry> leafs = new ArrayList<>(ids.size());
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
leafs.add(createNewLeafEntry(DBIDUtil.deref(iter)));
}
bulkLoad(leafs);
}
else {
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
insert(iter);
}
}
doExtraIntegrityChecks();
}
示例5: makeCluster
import de.lmu.ifi.dbs.elki.database.ids.DBIDs; //导入方法依赖的package包/类
/**
* Make the cluster for the given object
*
* @param lead Leading object
* @param depth Linkage depth
* @param members Member objects
* @return Cluster
*/
protected Cluster<DendrogramModel> makeCluster(DBIDRef lead, double depth, DBIDs members) {
final String name;
if(members == null || (members.size() == 1 && members.contains(lead))) {
name = "obj_" + DBIDUtil.toString(lead);
}
else if(members.size() == 0) {
name = "mrg_" + DBIDUtil.toString(lead) + "_" + depth;
}
else if(depth < Double.POSITIVE_INFINITY) {
name = "clu_" + DBIDUtil.toString(lead) + "_" + depth;
}
else {
// Complete data set only?
name = "top_" + DBIDUtil.toString(lead);
}
DendrogramModel model;
if(members != null && !members.isEmpty() && pointerresult instanceof PointerPrototypeHierarchyRepresentationResult) {
model = new PrototypeDendrogramModel(depth, ((PointerPrototypeHierarchyRepresentationResult) pointerresult).findPrototype(members));
}
else {
model = new DendrogramModel(depth);
}
return new Cluster<>(name, members, model);
}
示例6: insertAll
import de.lmu.ifi.dbs.elki.database.ids.DBIDs; //导入方法依赖的package包/类
/**
* Inserts the specified objects into this index. If a bulk load mode is
* implemented, the objects are inserted in one bulk.
*
* @param objects the objects to be inserted
*/
@Override
public final void insertAll(DBIDs ids) {
if(ids.isEmpty() || (ids.size() == 1)) {
return;
}
// Make an example leaf
if(canBulkLoad()) {
List<SpatialEntry> leafs = new ArrayList<>(ids.size());
for(DBIDIter id = ids.iter(); id.valid(); id.advance()) {
leafs.add(createNewLeafEntry(id));
}
bulkLoad(leafs);
}
else {
for(DBIDIter id = ids.iter(); id.valid(); id.advance()) {
insert(id);
}
}
doExtraIntegrityChecks();
}
示例7: loglikelihoodNormal
import de.lmu.ifi.dbs.elki.database.ids.DBIDs; //导入方法依赖的package包/类
/**
* Computes the loglikelihood of all normal objects. Gaussian model
*
* @param objids Object IDs for 'normal' objects.
* @param relation Database
* @return loglikelihood for normal objects
*/
private double loglikelihoodNormal(DBIDs objids, Relation<V> relation) {
if(objids.isEmpty()) {
return 0;
}
CovarianceMatrix builder = CovarianceMatrix.make(relation, objids);
double[] mean = builder.getMeanVector();
double[][] covarianceMatrix = builder.destroyToSampleMatrix();
// test singulaere matrix
double[][] covInv = inverse(covarianceMatrix);
double covarianceDet = new LUDecomposition(covarianceMatrix).det();
double fakt = 1.0 / FastMath.sqrt(MathUtil.powi(MathUtil.TWOPI, RelationUtil.dimensionality(relation)) * covarianceDet);
// for each object compute probability and sum
double prob = 0;
for(DBIDIter iter = objids.iter(); iter.valid(); iter.advance()) {
double[] x = minusEquals(relation.get(iter).toArray(), mean);
double mDist = transposeTimesTimes(x, covInv, x);
prob += FastMath.log(fakt * FastMath.exp(-mDist * .5));
}
return prob;
}
示例8: makeCluster
import de.lmu.ifi.dbs.elki.database.ids.DBIDs; //导入方法依赖的package包/类
/**
* Make the cluster for the given object
*
* @param lead Leading object
* @param depth Linkage depth
* @param members Member objects
* @return Cluster
*/
protected Cluster<DendrogramModel> makeCluster(DBIDRef lead, double depth, DBIDs members) {
final String name;
if(members == null || members.size() == 1 && members.contains(lead)) {
name = "obj_" + DBIDUtil.toString(lead);
if (members == null) {
ArrayModifiableDBIDs m = DBIDUtil.newArray(1);
m.add(lead);
members = m;
}
}
else if(members.size() == 0) {
name = "mrg_" + DBIDUtil.toString(lead) + "_" + depth;
}
else if(depth < Double.POSITIVE_INFINITY) {
name = "clu_" + DBIDUtil.toString(lead) + "_" + depth;
}
else {
// Complete data set only?
name = "top_" + DBIDUtil.toString(lead);
}
DendrogramModel model;
if(members != null && !members.isEmpty() && pointerresult instanceof PointerPrototypeHierarchyRepresentationResult) {
model = new PrototypeDendrogramModel(depth, ((PointerPrototypeHierarchyRepresentationResult) pointerresult).findPrototype(members));
}
else {
model = new DendrogramModel(depth);
}
return new Cluster<>(name, members, model);
}
示例9: run
import de.lmu.ifi.dbs.elki.database.ids.DBIDs; //导入方法依赖的package包/类
/**
* Run the clustering.
*
* @param database the Database
* @param relation the Relation
* @return Clustering result
*/
public Clustering<?> run(final Database database, final Relation<DiscreteUncertainObject> relation) {
if(relation.size() <= 0) {
return new Clustering<>("Uk-Means Clustering", "ukmeans-clustering");
}
// Choose initial means randomly
DBIDs sampleids = DBIDUtil.randomSample(relation.getDBIDs(), k, rnd);
List<double[]> means = new ArrayList<>(k);
for(DBIDIter iter = sampleids.iter(); iter.valid(); iter.advance()) {
means.add(ArrayLikeUtil.toPrimitiveDoubleArray(relation.get(iter).getCenterOfMass()));
}
// Setup cluster assignment store
List<ModifiableDBIDs> clusters = new ArrayList<>();
for(int i = 0; i < k; i++) {
clusters.add(DBIDUtil.newHashSet((int) (relation.size() * 2. / k)));
}
WritableIntegerDataStore assignment = DataStoreUtil.makeIntegerStorage(relation.getDBIDs(), DataStoreFactory.HINT_TEMP | DataStoreFactory.HINT_HOT, -1);
double[] varsum = new double[k];
IndefiniteProgress prog = LOG.isVerbose() ? new IndefiniteProgress("UK-Means iteration", LOG) : null;
DoubleStatistic varstat = LOG.isStatistics() ? new DoubleStatistic(this.getClass().getName() + ".variance-sum") : null;
int iteration = 0;
for(; maxiter <= 0 || iteration < maxiter; iteration++) {
LOG.incrementProcessed(prog);
boolean changed = assignToNearestCluster(relation, means, clusters, assignment, varsum);
logVarstat(varstat, varsum);
// Stop if no cluster assignment changed.
if(!changed) {
break;
}
// Recompute means.
means = means(clusters, means, relation);
}
LOG.setCompleted(prog);
if(LOG.isStatistics()) {
LOG.statistics(new LongStatistic(KEY + ".iterations", iteration));
}
// Wrap result
Clustering<KMeansModel> result = new Clustering<>("Uk-Means Clustering", "ukmeans-clustering");
for(int i = 0; i < clusters.size(); i++) {
DBIDs ids = clusters.get(i);
if(ids.isEmpty()) {
continue;
}
result.addToplevelCluster(new Cluster<>(ids, new KMeansModel(means.get(i), varsum[i])));
}
return result;
}