Package de.lmu.ifi.dbs.elki.data

Examples of de.lmu.ifi.dbs.elki.data.DoubleVector


    return TypeUtil.DOUBLE_VECTOR_FIELD;
  }

  @Override
  protected SimpleTypeInformation<? super DoubleVector> convertedType(SimpleTypeInformation<DoubleVector> in) {
    return new VectorFieldTypeInformation<DoubleVector>(DoubleVector.class, getDimensionality(), new DoubleVector(new double[getDimensionality()]));
  }
View Full Code Here


          throw new UnableToComplyException("Cluster dimensions do not agree.");
        }
      }
    }
    // Vector factory. TODO: make configurable
    final DoubleVector factory = new DoubleVector(new double[dim]);
    // Prepare result bundle
    MultipleObjectsBundle bundle = new MultipleObjectsBundle();
    VectorFieldTypeInformation<DoubleVector> type = new VectorFieldTypeInformation<DoubleVector>(DoubleVector.class, dim, factory);
    bundle.appendColumn(type, new ArrayList<Object>());
    bundle.appendColumn(TypeUtil.CLASSLABEL, new ArrayList<Object>());
    bundle.appendColumn(TypeUtil.MODEL, new ArrayList<Model>());

    // generate clusters
    for(GeneratorInterface curclus : generators) {
      ClassLabel l = new SimpleClassLabel(curclus.getName());
      Model model = curclus.makeModel();
      int kept = 0;
      while(kept < curclus.getSize()) {
        // generate the "missing" number of points
        List<Vector> newp = curclus.generate(curclus.getSize() - kept);
        if(curclus instanceof GeneratorInterfaceDynamic) {
          GeneratorInterfaceDynamic cursclus = (GeneratorInterfaceDynamic) curclus;
          for(Vector p : newp) {
            boolean keep = true;
            if(testAgainstModel) {
              double max = 0.0;
              double is = 0.0;
              for(GeneratorInterface other : generators) {
                double d = other.getDensity(p) * other.getSize();
                if(other == curclus) {
                  is = d;
                }
                else if(d > max) {
                  max = d;
                }
              }
              // Only keep the point if the largest density was the cluster it
              // was generated for
              if(is < max) {
                keep = false;
              }
            }
            if(keep) {
              DoubleVector dv = new DoubleVector(p);
              bundle.appendSimple(dv, l, model);
              ++kept;
            }
            else {
              cursclus.incrementDiscarded();
View Full Code Here

    // also test partial queries, forward only
    testKNNQueries(rep, lin_knn_query, preproc_knn_query, k / 2);

    // insert new objects
    List<DoubleVector> insertions = new ArrayList<DoubleVector>();
    DoubleVector o = DatabaseUtil.assumeVectorField(rep).getFactory();
    Random random = new Random(seed);
    for(int i = 0; i < updatesize; i++) {
      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));
View Full Code Here

    return TypeUtil.DOUBLE_VECTOR_FIELD;
  }

  @Override
  protected SimpleTypeInformation<? super DoubleVector> convertedType(SimpleTypeInformation<DoubleVector> in) {
    return new VectorFieldTypeInformation<DoubleVector>(DoubleVector.class, k, new DoubleVector(new double[k]));
  }
View Full Code Here

   *
   * @see de.lmu.ifi.dbs.elki.datasource.parser.NumberVectorLabelParser#createDBObject(java.util.List)
   */
  @Override
  public DoubleVector createDBObject(List<Double> attributes) {
    return new DoubleVector(attributes);
  }
View Full Code Here

    return new DoubleVector(attributes);
  }

  @Override
  protected VectorFieldTypeInformation<DoubleVector> getTypeInformation(int dimensionality) {
    return new VectorFieldTypeInformation<DoubleVector>(DoubleVector.class, dimensionality, new DoubleVector(new double[dimensionality]));
  }
View Full Code Here

  private static final Logging logger = Logging.getLogger(RandomDoubleVectorDatabaseConnection.class);

 
  @Override
  public MultipleObjectsBundle loadData() {
    VectorFieldTypeInformation<DoubleVector> type = new VectorFieldTypeInformation(DoubleVector.class, dim, new DoubleVector(new double[dim]));
    List<DoubleVector> vectors = new ArrayList<DoubleVector>(size);

    // Setup random generator
    final Random rand;
    if(seed == null) {
      rand = new Random();
    }
    else {
      rand = new Random(seed);
    }

    // Produce random vectors
    DoubleVector factory = new DoubleVector(new double[dim]);
    for(int i = 0; i < size; i++) {
      vectors.add(VectorUtil.randomVector(factory, rand));
    }

    return MultipleObjectsBundle.makeSimple(type, vectors);
View Full Code Here

            throw new AbortException("Expected word token, got: " + tokenizer.toString());
          }
          cur[k] = tokenizer.nval;
          nextToken(tokenizer);
        }
        data[out] = new DoubleVector(cur);
      }
      else if(etyp[out] == TypeUtil.LABELLIST) {
        // Build a label list out of successive labels
        LabelList ll = new LabelList();
        for(int k = 0; k < dimsize[out]; k++) {
View Full Code Here

        // Collect labels:
        for(int i = 0; i < dimsize[out]; i++) {
          labels[i] = names.get(out + i);
        }
        if(!sparse) {
          VectorFieldTypeInformation<DoubleVector> type = new VectorFieldTypeInformation<DoubleVector>(DoubleVector.class, dimsize[out], labels, new DoubleVector(new double[dimsize[out]]));
          bundle.appendColumn(type, new ArrayList<DoubleVector>());
        }
        else {
          Map<Integer, Float> empty = Collections.emptyMap();
          VectorFieldTypeInformation<SparseFloatVector> type = new VectorFieldTypeInformation<SparseFloatVector>(SparseFloatVector.class, dimsize[out], labels, new SparseFloatVector(empty, dimsize[out]));
View Full Code Here

    else {
      rand = new Random(seed);
    }

    // Produce random vectors
    DoubleVector factory = new DoubleVector(new double[dim]);
    for(int i = 0; i < size; i++) {
      vectors.add(VectorUtil.randomVector(factory, rand));
    }

    return MultipleObjectsBundle.makeSimple(type, vectors);
View Full Code Here

TOP

Related Classes of de.lmu.ifi.dbs.elki.data.DoubleVector

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.