Package de.lmu.ifi.dbs.elki.database.ids

Examples of de.lmu.ifi.dbs.elki.database.ids.DBIDs


      OutlierScalingFunction oscaling = (OutlierScalingFunction) scaling;
      oscaling.prepare(or);
    }

    ModifiableDBIDs ids = DBIDUtil.newHashSet(or.getScores().getDBIDs());
    DBIDs outlierIds = DatabaseUtil.getObjectsByLabelMatch(database, positiveClassName);
    // first value for outliers, second for each object
    final AggregatingHistogram<DoubleDoublePair, DoubleDoublePair> hist;
    // If we have useful (finite) min/max, use these for binning.
    double min = scaling.getMin();
    double max = scaling.getMax();
    if(Double.isInfinite(min) || Double.isNaN(min) || Double.isInfinite(max) || Double.isNaN(max)) {
      hist = FlexiHistogram.DoubleSumDoubleSumHistogram(bins);
    }
    else {
      hist = AggregatingHistogram.DoubleSumDoubleSumHistogram(bins, min, max);
    }
    // first fill histogram only with values of outliers
    DoubleDoublePair positive, negative;
    if(!splitfreq) {
      positive = new DoubleDoublePair(0., 1. / ids.size());
      negative = new DoubleDoublePair(1. / ids.size(), 0.);
    }
    else {
      positive = new DoubleDoublePair(0., 1. / outlierIds.size());
      negative = new DoubleDoublePair(1. / (ids.size() - outlierIds.size()), 0.);
    }
    ids.removeDBIDs(outlierIds);
    // fill histogram with values of each object
    for(DBID id : ids) {
      double result = or.getScores().get(id);
View Full Code Here


      // logger.warning("No results found for "+JudgeOutlierScores.class.getSimpleName());
      return;
    }

    ModifiableDBIDs ids = DBIDUtil.newHashSet(ors.iterator().next().getScores().getDBIDs());
    DBIDs outlierIds = DatabaseUtil.getObjectsByLabelMatch(db, positiveClassName);
    ids.removeDBIDs(outlierIds);

    for(OutlierResult or : ors) {
      db.getHierarchy().add(or, computeScore(ids, outlierIds, or));
    }
View Full Code Here

      for(int i1 = 0; it1.hasNext(); i1++) {
        final Cluster<?> c1 = it1.next();
        if(c1.isNoise()) {
          noise1.set(i1);
        }
        final DBIDs ids = DBIDUtil.ensureSet(c1.getIDs());
        contingency[i1][size2 + 1] = c1.size();
        contingency[size1][size2 + 1] += c1.size();

        final Iterator<? extends Cluster<?>> it2 = cs2.iterator();
        for(int i2 = 0; it2.hasNext(); i2++) {
          final Cluster<?> c2 = it2.next();
          int count = 0;
          for(DBID id : c2.getIDs()) {
            if(ids.contains(id)) {
              count++;
            }
          }
          contingency[i1][i2] = count;
          contingency[i1][size2] += count;
View Full Code Here

   * @return the RkNNs of the specified ids, i.e. the kNNs which have been
   *         updated
   */
  private ArrayDBIDs updateKNNsAndRkNNs(DBIDs ids) {
    ArrayModifiableDBIDs rkNN_ids = DBIDUtil.newArray();
    DBIDs oldids = DBIDUtil.difference(relation.getDBIDs(), ids);
    for(DBID id1 : oldids) {
      KNNResult<D> kNNs = storage.get(id1);
      D knnDist = kNNs.getKNNDistance();
      // look for new kNNs
      KNNHeap<D> heap = null;
View Full Code Here

    this.centroid = centroid;
    this.nf = nf;

    // determine standard deviation
    double variance = 0;
    DBIDs ids = db.getDBIDs();
    for (DBID id : ids) {
      double distance = distance(db.get(id).getColumnVector());
      variance += distance * distance;
    }
    standardDeviation = Math.sqrt(variance / ids.size());
  }
View Full Code Here

      DoubleVector obj = VectorUtil.randomVector(o, random);
      insertions.add(obj);
    }
    System.out.println("Insert " + insertions);
    System.out.println();
    DBIDs deletions = db.insert(MultipleObjectsBundle.makeSimple(rep.getDataTypeInformation(), insertions));

    // test queries
    testKNNQueries(rep, lin_knn_query, preproc_knn_query, k);
    testRKNNQueries(rep, lin_rknn_query, preproc_rknn_query, k);
View Full Code Here

      return intersection;
    }

    @Override
    public DoubleDistance similarity(DBID id1, DBID id2) {
      DBIDs neighbors1 = index.getNearestNeighborSet(id1);
      DBIDs neighbors2 = index.getNearestNeighborSet(id2);
      int intersection = countSharedNeighbors(neighbors1, neighbors2);
      return new DoubleDistance((double) intersection / index.getNumberOfNeighbors());
    }
View Full Code Here

    int i = 0;
    for(DBID id : ids) {
      KNNHeap<D> kNN = new KNNHeap<D>(k, distanceQuery.infiniteDistance());

      long rseed = i * 0x7FFFFFFFFFFFFFE7L + iseed;
      DBIDs rsamp = DBIDUtil.randomSample(ids, samplesize, rseed);
      for(DBID oid : rsamp) {
        D dist = distanceQuery.distance(id, oid);
        kNN.add(new GenericDistanceResultPair<D>(dist, oid));
      }

View Full Code Here

   * @return the RkNNs of the specified ids, i.e. the kNNs which have been
   *         updated
   */
  private ArrayDBIDs updateKNNsAfterInsertion(DBIDs ids) {
    ArrayModifiableDBIDs rkNN_ids = DBIDUtil.newArray();
    DBIDs oldids = DBIDUtil.difference(relation.getDBIDs(), ids);
    for(DBID id1 : oldids) {
      KNNResult<D> kNNs = storage.get(id1);
      D knnDist = kNNs.get(kNNs.size() - 1).getDistance();
      // look for new kNNs
      KNNHeap<D> heap = null;
View Full Code Here

      candidates.remove(firstid);
      for(int i = 0; i < 5000; i++) {
        // Build the improved ensemble:
        final double[] randomensemble = new double[dim];
        {
          DBIDs random = DBIDUtil.randomSample(candidates, ensemble.size(), i);
          for(DBID id : random) {
            assert (!firstid.equals(id));
            // logger.verbose("Using: "+labels.get(id));
            final NumberVector<?, ?> vec = relation.get(id);
            for(int d = 0; d < dim; d++) {
View Full Code Here

TOP

Related Classes of de.lmu.ifi.dbs.elki.database.ids.DBIDs

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.