@Override public boolean isEmpty() { return inner.isEmpty(); }
/** * Loglikelihood anomalous objects. Uniform distribution. * * @param anomalousObjs * @return loglikelihood for anomalous objects */ private double loglikelihoodAnomalous(DBIDs anomalousObjs) { return anomalousObjs.isEmpty() ? 0 : anomalousObjs.size() * -FastMath.log(anomalousObjs.size()); }
/** * Loglikelihood anomalous objects. Uniform distribution. * * @param anomalousObjs * @return loglikelihood for anomalous objects */ private double loglikelihoodAnomalous(DBIDs anomalousObjs) { return anomalousObjs.isEmpty() ? 0 : anomalousObjs.size() * -FastMath.log(anomalousObjs.size()); }
/** * Format a DBID as string. * * @param ids DBIDs * @return String representation */ public static String toString(DBIDs ids) { final DBIDFactory factory = DBIDFactory.FACTORY; if(ids instanceof DBID) { return factory.toString((DBID) ids); } if(ids.isEmpty()) { return ""; } DBIDIter iter = ids.iter(); StringBuilder buf = new StringBuilder(ids.size() * 6) // .append(factory.toString(iter)); while(iter.advance().valid()) { buf.append(',').append(factory.toString(iter)); } return buf.toString(); }
/** * Format a DBID as string. * * @param ids DBIDs * @return String representation */ public static String toString(DBIDs ids) { final DBIDFactory factory = DBIDFactory.FACTORY; if(ids instanceof DBID) { return factory.toString((DBID) ids); } if(ids.isEmpty()) { return ""; } DBIDIter iter = ids.iter(); StringBuilder buf = new StringBuilder(ids.size() * 6) // .append(factory.toString(iter)); while(iter.advance().valid()) { buf.append(',').append(factory.toString(iter)); } return buf.toString(); }
/** * Build a standard k-means result, with known cluster variance sums. * * @return Clustering result */ protected Clustering<KMeansModel> buildResult() { Clustering<KMeansModel> result = new Clustering<>("k-Means Clustering", "kmeans-clustering"); for(int i = 0; i < clusters.size(); i++) { DBIDs ids = clusters.get(i); if(ids.isEmpty()) { getLogger().warning("K-Means produced an empty cluster - bad initialization?"); } result.addToplevelCluster(new Cluster<>(ids, new KMeansModel(means[i], varsum[i]))); } return result; }
/** * Build a standard k-means result, with known cluster variance sums. * * @return Clustering result */ protected Clustering<KMeansModel> buildResult() { Clustering<KMeansModel> result = new Clustering<>("k-Means Clustering", "kmeans-clustering"); for(int i = 0; i < clusters.size(); i++) { DBIDs ids = clusters.get(i); if(ids.isEmpty()) { getLogger().warning("K-Means produced an empty cluster - bad initialization?"); } result.addToplevelCluster(new Cluster<>(ids, new KMeansModel(means[i], varsum[i]))); } return result; }
/** * Computes the loglikelihood of all normal objects. Gaussian model * * @param objids Object IDs for 'normal' objects. * @param database Database * @return loglikelihood for normal objects */ private double loglikelihoodNormal(DBIDs objids, Relation<V> database) { if(objids.isEmpty()) { return 0; } CovarianceMatrix builder = CovarianceMatrix.make(database, objids); Vector mean = builder.getMeanVector(); Matrix covarianceMatrix = builder.destroyToSampleMatrix(); // test singulaere matrix Matrix covInv = covarianceMatrix.cheatToAvoidSingularity(SINGULARITY_CHEAT).inverse(); double covarianceDet = covarianceMatrix.det(); double fakt = 1.0 / Math.sqrt(MathUtil.powi(MathUtil.TWOPI, RelationUtil.dimensionality(database)) * covarianceDet); // for each object compute probability and sum double prob = 0; for(DBIDIter iter = objids.iter(); iter.valid(); iter.advance()) { Vector x = database.get(iter).getColumnVector().minusEquals(mean); double mDist = x.transposeTimesTimes(covInv, x); prob += Math.log(fakt * Math.exp(-mDist / 2.0)); } return prob; }
/** * 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(); }
/** * 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()) { 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(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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(); }