本文整理汇总了Java中de.lmu.ifi.dbs.elki.database.ids.DBIDs.contains方法的典型用法代码示例。如果您正苦于以下问题:Java DBIDs.contains方法的具体用法?Java DBIDs.contains怎么用?Java DBIDs.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类de.lmu.ifi.dbs.elki.database.ids.DBIDs
的用法示例。
在下文中一共展示了DBIDs.contains方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeM_current
import de.lmu.ifi.dbs.elki.database.ids.DBIDs; //导入方法依赖的package包/类
/**
* Computes the set of medoids in current iteration.
*
* @param m the medoids
* @param m_best the best set of medoids found so far
* @param m_bad the bad medoids
* @param random random number generator
* @return m_current, the set of medoids in current iteration
*/
private ArrayDBIDs computeM_current(DBIDs m, DBIDs m_best, DBIDs m_bad, Random random) {
ArrayModifiableDBIDs m_list = DBIDUtil.newArray(m);
m_list.removeDBIDs(m_best);
DBIDArrayMIter it = m_list.iter();
ArrayModifiableDBIDs m_current = DBIDUtil.newArray();
for(DBIDIter iter = m_best.iter(); iter.valid(); iter.advance()) {
if(m_bad.contains(iter)) {
int currentSize = m_current.size();
while(m_current.size() == currentSize) {
m_current.add(it.seek(random.nextInt(m_list.size())));
it.remove();
}
}
else {
m_current.add(iter);
}
}
return m_current;
}
示例2: 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);
}
示例3: applyPrescaling
import de.lmu.ifi.dbs.elki.database.ids.DBIDs; //导入方法依赖的package包/类
/**
* Prescale each vector (except when in {@code skip}) with the given scaling
* function.
*
* @param scaling Scaling function
* @param relation Relation to read
* @param skip DBIDs to pass unmodified
* @return New relation
*/
public static Relation<NumberVector> applyPrescaling(ScalingFunction scaling, Relation<NumberVector> relation, DBIDs skip) {
if(scaling == null) {
return relation;
}
NumberVector.Factory<NumberVector> factory = RelationUtil.getNumberVectorFactory(relation);
DBIDs ids = relation.getDBIDs();
WritableDataStore<NumberVector> contents = DataStoreUtil.makeStorage(ids, DataStoreFactory.HINT_HOT, NumberVector.class);
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
NumberVector v = relation.get(iter);
double[] raw = v.toArray();
if(!skip.contains(iter)) {
applyScaling(raw, scaling);
}
contents.put(iter, factory.newNumberVector(raw, ArrayLikeUtil.DOUBLEARRAYADAPTER));
}
return new MaterializedRelation<>(relation.getDataTypeInformation(), ids, "rescaled", contents);
}
示例4: retainAll
import de.lmu.ifi.dbs.elki.database.ids.DBIDs; //导入方法依赖的package包/类
@Override
public boolean retainAll(DBIDs set) {
boolean modified = false;
for(DBIDMIter it = iter(); it.valid(); it.advance()) {
if(!set.contains(it)) {
it.remove();
modified = true;
}
}
return modified;
}
示例5: order
import de.lmu.ifi.dbs.elki.database.ids.DBIDs; //导入方法依赖的package包/类
/**
* Use the cluster order to sort the given collection ids.
*
* Implementation of the {@link OrderingResult} interface.
*/
@Override
public ArrayModifiableDBIDs order(DBIDs ids) {
ArrayModifiableDBIDs res = DBIDUtil.newArray(ids.size());
for(DBIDIter it = this.ids.iter(); it.valid(); it.advance()) {
if(ids.contains(it)) {
res.add(it);
}
}
return res;
}
示例6: 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);
}
示例7: buildHullsRecursively
import de.lmu.ifi.dbs.elki.database.ids.DBIDs; //导入方法依赖的package包/类
/**
* Recursively step through the clusters to build the hulls.
*
* @param clu Current cluster
* @param hier Clustering hierarchy
* @param hulls Hull map
*/
private DoubleObjPair<Polygon> buildHullsRecursively(Cluster<Model> clu, Hierarchy<Cluster<Model>> hier, Map<Object, DoubleObjPair<Polygon>> hulls) {
final Model model = clu.getModel();
final DBIDs ids = clu.getIDs();
boolean coremodel = false;
DBIDs cids = null;
if(model instanceof CoreObjectsModel) {
cids = ((CoreObjectsModel) model).getCoreObjects();
coremodel = cids.size() > 0;
}
GrahamScanConvexHull2D hull = new GrahamScanConvexHull2D();
GrahamScanConvexHull2D hull2 = coremodel ? new GrahamScanConvexHull2D() : null;
for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) {
final double[] projv = proj.fastProjectDataToRenderSpace(rel.get(iter));
if(projv[0] != projv[0] || projv[1] != projv[1]) {
continue; // NaN!
}
hull.add(projv);
if(coremodel && cids.contains(iter)) {
hull2.add(projv);
}
}
double weight = ids.size(), cweight = coremodel ? cids.size() : 0.0;
if(hier != null && hulls != null) {
final int numc = hier.numChildren(clu);
if(numc > 0) {
for(It<Cluster<Model>> iter = hier.iterChildren(clu); iter.valid(); iter.advance()) {
final Cluster<Model> iclu = iter.get();
DoubleObjPair<Polygon> poly = hulls.get(iclu);
if(poly == null) {
poly = buildHullsRecursively(iclu, hier, hulls);
}
// Add inner convex hull to outer convex hull.
for(ArrayListIter<double[]> vi = poly.second.iter(); vi.valid(); vi.advance()) {
hull.add(vi.get());
}
// For a core model, include the inner core, too.
if(coremodel) {
DoubleObjPair<Polygon> ipoly = hulls.get(iclu.getModel());
if(ipoly != null) {
for(ArrayListIter<double[]> vi = ipoly.second.iter(); vi.valid(); vi.advance()) {
hull2.add(vi.get());
}
cweight += ipoly.first / numc;
}
}
weight += poly.first / numc;
}
}
}
DoubleObjPair<Polygon> pair = new DoubleObjPair<>(weight, hull.getHull());
hulls.put(clu, pair);
if(coremodel) {
hulls.put(model, new DoubleObjPair<>(cweight, hull2.getHull()));
}
return pair;
}