Package water.fvec

Examples of water.fvec.Frame$CSVStream


   * @param s Scalar value represented as a double.
   * @param op Element-wise operator encoded as a String.
   * @return new DRM containing A (element-wise) B.
   */
  public static H2ODrm exec(H2ODrm drmA, final double s, final String op) {
    Frame A = drmA.frame;
    Vec keys = drmA.keys;
    int AewScalar_cols = A.numCols();

    // AewScalar is written into ncs[] with an MRTask on A, and therefore will
    // be similarly partitioned as A.
    Frame AewScalar = new MRTask() {
        private double opfn(String op, double a, double b) {
          if (a == 0.0 && b == 0.0) {
            return 0.0;
          }
          if (op.equals("+")) {
View Full Code Here


   * @param drmA DRM representing matrix A.
   * @param drmB DRM representing matrix B.
   * @return new DRM containing columns of A and B adjacent.
   */
  public static H2ODrm exec(H2ODrm drmA, H2ODrm drmB) {
    Frame fra = drmA.frame;
    Vec keysa = drmA.keys;
    Frame frb = drmB.frame;
    Vec keysb = drmB.keys;

    // If A and B are similarly partitioned, ..
    if (fra.anyVec().group() == frb.anyVec().group()) {
      // .. then, do a light weight zip()
      return zip(fra, keysa, frb, keysb);
    } else {
      // .. else, do a heavy weight join() which involves moving data over the wire
      return join(fra, keysa, frb, keysb);
View Full Code Here

    // and B's
    for (Vec vfrb : frb.vecs()) {
      vecs[d++] = vfrb;
    }
    // and create a new Frame with the combined list of column Vecs
    Frame fr = new Frame(vecs);
    /* Finally, inherit A's string labels into the result */
    return new H2ODrm(fr, keysa);
  }
View Full Code Here

        }
      }
    }.doAll(bvecs);

    // now that bvecs[] is compatible, just zip'em'up
    return zip(fra, keysa, new Frame(bvecs), null);
  }
View Full Code Here

   * @param min Hint of minimum number of partitions to parallelize, if not -1.
   * @param exact Hint of exact number of partitions to parallelize, if not -1.
   * @return new DRM holding the same data but parallelized according to new hints.
   */
  public static H2ODrm exec(H2ODrm drmA, int min, int exact) {
    final Frame frin = drmA.frame;
    final Vec vin = drmA.keys;

    // First create a new empty Frame with the required partitioning
    Frame frout = H2OHelper.emptyFrame(frin.numRows(), frin.numCols(), min, exact);
    Vec vout = null;

    if (vin != null) {
      // If String keyed, then run an MRTask on the new frame, and also
      // creat yet another 1-column newer frame for the re-orged String keys.
View Full Code Here

   *
   * @param drmA DRM representing matrix A.
   * @return new DRM containing A'.
   */
  public static H2ODrm exec(H2ODrm drmA) {
    final Frame A = drmA.frame;
    // First create a new frame of the required dimensions, A.numCols() rows
    // and A.numRows() columns.
    Frame At = H2OHelper.emptyFrame(A.numCols(), (int) A.numRows(), -1, -1);

    // Execute MRTask on the new frame, and fill each cell (initially 0) by
    // pulling in the appropriate value from A.
    new MRTask() {
      public void map(Chunk chks[]) {
View Full Code Here

   *
   * @param drm DRM object to create Matrix from.
   * @return created Matrix.
   */
  public static Matrix matrixFromDrm(H2ODrm drm) {
    Frame frame = drm.frame;
    Vec labels = drm.keys;
    Matrix m;

    if (isSparse(frame)) {
      m = new SparseMatrix((int)frame.numRows(), frame.numCols());
    } else {
      m = new DenseMatrix((int)frame.numRows(), frame.numCols());
    }

    int c = 0;
    // Fill matrix, column at a time.
    for (Vec v : frame.vecs()) {
      for (int r = 0; r < frame.numRows(); r++) {
        double d = 0.0;
        if (!v.isNA(r) && ((d = v.at(r)) != 0.0)) {
          m.setQuick(r, c, d);
        }
      }
View Full Code Here

   * @param exactHint Hint for exact number of partitions in created DRM.
   * @return Created H2O backed DRM.
   */
  public static H2ODrm drmFromMatrix(Matrix m, int minHint, int exactHint) {
    // First create an empty (0-filled) frame of the required dimensions
    Frame frame = emptyFrame(m.rowSize(), m.columnSize(), minHint, exactHint);
    Vec labels = null;
    Vec.Writer writers[] = new Vec.Writer[m.columnSize()];
    Futures closer = new Futures();

    // "open" vectors for writing efficiently in bulk
    for (int i = 0; i < writers.length; i++) {
      writers[i] = frame.vecs()[i].open();
    }

    for (int r = 0; r < m.rowSize(); r++) {
      for (int c = 0; c < m.columnSize(); c++) {
        writers[c].set(r, m.getQuick(r, c));
      }
    }

    for (int c = 0; c < m.columnSize(); c++) {
      writers[c].close(closer);
    }

    // If string labeled matrix, create aux Vec
    Map<String,Integer> map = m.getRowLabelBindings();
    if (map != null) {
      // label vector must be similarly partitioned like the Frame
      labels = frame.anyVec().makeZero();
      Vec.Writer writer = labels.open();
      Map<Integer,String> rmap = reverseMap(map);

      for (long r = 0; r < m.rowSize(); r++) {
        writer.set(r, rmap.get(r));
View Full Code Here

    for (int i = 0; i < vecs.length; i++) {
      vecs[i] = Vec.makeCon(0, null, vg, espc);
    }

    return new Frame(vecs);
  }
View Full Code Here

   * @param drmA DRM representing matrix A.
   * @param x in-core Mahout Vector.
   * @return new DRM containing A'x.
   */
  public static H2ODrm exec(H2ODrm drmA, Vector x) {
    Frame A = drmA.frame;
    final H2OBCast<Vector> bx = new H2OBCast<Vector>(x);

    // A'x is computed into atx[] with an MRTask on A (with
    // x available as a Broadcast
    //
    // x.size() == A.numRows()
    // atx.length == chks.length == A.numCols()
    class MRTaskAtx extends MRTask<MRTaskAtx> {
      double atx[];
      public void map(Chunk chks[]) {
        int chunkSize = chks[0].len();
        Vector x = bx.value();
        long start = chks[0].start();

        atx = new double[chks.length];
        for (int r = 0; r < chunkSize; r++) {
          double d = x.getQuick((int)start + r);
          for (int c = 0; c < chks.length; c++) {
            atx[c] += (chks[c].at0(r) * d);
          }
        }
      }
      public void reduce(MRTaskAtx other) {
        ArrayUtils.add(atx, other.atx);
      }
    }

    // Take the result in .atx[], and convert into a Frame
    // using existing helper functions (creating a Matrix
    // along the way for the Helper)
    Vector v = new DenseVector(new MRTaskAtx().doAll(A).atx);
    Matrix m = new DenseMatrix(A.numCols(), 1);
    m.assignColumn(0, v);
    return H2OHelper.drmFromMatrix(m, -1, -1);
  }
View Full Code Here

TOP

Related Classes of water.fvec.Frame$CSVStream

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.