Package water.fvec

Examples of water.fvec.Frame$DeepSlice


    FindPojo f = new FindPojo();
    // Peel out the Frame from the Key
    Value val = DKV.get(key);
    if( val == null ) throw new IllegalArgumentException("Key not found");
    if( !val.isFrame() ) throw new IllegalArgumentException("Not a Frame");
    Frame fr = val.get();

    // Peel out an optional column; restrict to this column
    if( column != null ) {
      Vec vec = fr.vec(column);
      if( vec==null ) throw new IllegalArgumentException("Column "+column+" not found in frame "+key);
      fr = new Frame(new String[]{column}, new Vec[]{vec});
    }

    f._fr = fr;
    f._row = row;
    f._val = match;
View Full Code Here


        }
      }).keys();

    f.frames = new Frame[frameKeys.length];
    for (int i = 0; i < frameKeys.length; i++) {
      Frame frame = getFromDKV(frameKeys[i]);
      f.frames[i] = frame;
    }
    return this.schema(version).fillFromImpl(f);
  }
View Full Code Here

    return (Frame)ice;
  }

  /** Return a single column from the frame. */
  protected Schema column(int version, Frames f) { // TODO: should return a Vec schema
    Frame frame = getFromDKV(f.key);

    // TODO: We really want to return a different schema here!
    Vec vec = frame.vec(f.column);
    if (null == vec)
      throw new IllegalArgumentException("Did not find column: " + f.column + " in frame: " + f.key.toString());

    Vec[] vecs = { vec };
    String[] names = { f.column };
    Frame new_frame = new Frame(names, vecs);
    f.frames = new Frame[1];
    f.frames[0] = new_frame;
    return this.schema(version).fillFromImpl(f);
  }
View Full Code Here

    f.frames[0] = new_frame;
    return this.schema(version).fillFromImpl(f);
  }

  protected FramesBase columnSummary(int version, Frames frames) {
    Frame frame = getFromDKV(frames.key);
    Vec vec = frame.vec(frames.column);
    if (null == vec)
      throw new IllegalArgumentException("Did not find column: " + frames.column + " in frame: " + frames.key.toString());

    // Compute second pass of rollups: the histograms.  Side-effects the Vec.
    // TODO: side effects, ugh.
    RollupStats.computeHisto(vec);

    // Cons up our result
    frames.frames = new Frame[1];
    frames.frames[0] = new Frame(new String[] {frames.column }, new Vec[] { vec });
    return schema(version).fillFromImpl(frames);
  }
View Full Code Here

    return schema(version).fillFromImpl(frames);
  }

  /** Return a single frame. */
  protected Schema fetch(int version, Frames f) {
    Frame frame = getFromDKV(f.key);
    f.frames = new Frame[1];
    f.frames[0] = frame;
    return this.schema(version).fillFromImpl(f);
  }
View Full Code Here

    return this.schema(version).fillFromImpl(f);
  }

  // Remove an unlocked frame.  Fails if frame is in-use
  protected void delete(int version, Frames frames) {
    Frame frame = getFromDKV(frames.key);
    frame.delete();             // lock & remove
  }
View Full Code Here

   *         one column with predicted values.
   */
  public final Frame score(Frame fr, boolean adapt) {
    int ridx = fr.find(_output.responseName());
    if (ridx != -1) { // drop the response for scoring!
      fr = new Frame(fr);
      fr.remove(ridx);
    }
    // Adapt the Frame layout - returns adapted frame and frame containing only
    // newly created vectors
    Frame[] adaptFrms = adapt ? adapt(fr,false) : null;
    // Adapted frame containing all columns - mix of original vectors from fr
    // and newly created vectors serving as adaptors
    Frame adaptFrm = adapt ? adaptFrms[0] : fr;
    // Contains only newly created vectors. The frame eases deletion of these vectors.
    Frame onlyAdaptFrm = adapt ? adaptFrms[1] : null;
    // Invoke scoring
    Frame output = scoreImpl(adaptFrm);
    // Be nice to DKV and delete vectors which i created :-)
    if (adapt) onlyAdaptFrm.delete();
    return output;
  }
View Full Code Here

   *  It returns a <b>two element array</b> containing an adapted frame and a
   *  frame which contains only vectors which where adapted (the purpose of the
   *  second frame is to delete all adapted vectors with deletion of the
   *  frame). */
  public Frame[] adapt( final Frame fr, boolean exact) {
    Frame vfr = new Frame(fr); // To avoid modification of original frame fr
    int ridx = vfr.find(_output._names[_output._names.length-1]);
    if(ridx != -1 && ridx != vfr._names.length-1){ // Unify frame - put response to the end
      String n = vfr._names[ridx];
      vfr.add(n,vfr.remove(ridx));
    }
    int n = ridx == -1?_output._names.length-1:_output._names.length;
    String [] names = Arrays.copyOf(_output._names, n);
    Frame  [] subVfr;
    // replace missing columns with NaNs (or 0s for DeepLearning with sparse data)
    // subVfr = vfr.subframe(names, (this instanceof DeepLearningModel && ((DeepLearningModel)this).get_params().sparse) ? 0 : Double.NaN);
    subVfr = vfr.subframe(names, Double.NaN);
    vfr = subVfr[0]; // extract only subframe but keep the rest for delete later
    Vec[] frvecs = vfr.vecs();
    boolean[] toEnum = new boolean[frvecs.length];
    if(!exact) for(int i = 0; i < n;++i)
      if(_output._domains[i] != null && !frvecs[i].isEnum()) {// if model expects domain but input frame does not have domain => switch vector to enum
        frvecs[i] = frvecs[i].toEnum();
        toEnum[i] = true;
      }
    int[][][] map = adapt(names,vfr.domains(),exact);
    assert map.length == names.length; // Be sure that adapt call above do not skip any column
    ArrayList<Vec> avecs = new ArrayList<>(); // adapted vectors
    ArrayList<String> anames = new ArrayList<>(); // names for adapted vector

    for( int c=0; c<map.length; c++ ) // Iterate over columns
      if(map[c] != null) { // Column needs adaptation
        Vec adaptedVec;
        if (toEnum[c]) { // Vector was flipped to column already, compose transformation
          adaptedVec = TransfVec.compose((TransfVec) frvecs[c], map[c], vfr.domains()[c], false);
        } else adaptedVec = frvecs[c].makeTransf(map[c], vfr.domains()[c]);
        avecs.add(frvecs[c] = adaptedVec);
        anames.add(names[c]); // Collect right names
      } else if (toEnum[c]) { // Vector was transformed to enum domain, but does not need adaptation we need to record it
        avecs.add(frvecs[c]);
        anames.add(names[c]);
      }
    // Fill trash bin by vectors which need to be deleted later by the caller.
    Frame vecTrash = new Frame(anames.toArray(new String[anames.size()]), avecs.toArray(new Vec[avecs.size()]));
//    if (subVfr[1]!=null) vecTrash.add(subVfr[1], true);
    return new Frame[] { new Frame(names,frvecs), vecTrash };
  }
View Full Code Here

      actual_domain = va.factors();
      if (max_k > predict.numCols()-1) {
        Log.warn("Reducing Hitratio Top-K value to maximum value allowed: " + String.format("%,d", predict.numCols() - 1));
        max_k = predict.numCols() - 1;
      }
      final Frame actual_predict = new Frame(predict.names().clone(), predict.vecs().clone());
      actual_predict.replace(0, va); // place actual labels in first column
      hit_ratios = new HitRatioTask(max_k, seed).doAll(actual_predict).hit_ratios();
    } finally {       // Delete adaptation vectors
      if (va!=null) DKV.remove(va._key);
    }
  }
View Full Code Here

    public KeyInfo(Key k, Value v){
      _key = k;
      _type = v.type();
      if(v.isFrame()) {
        Frame f = v.get();
        _rawData = (f.vecs().length == 1 && (f.anyVec() instanceof ByteVec));
      } else _rawData = false;
      _sz = v._max;
      _backEnd = v.backend();
    }
View Full Code Here

TOP

Related Classes of water.fvec.Frame$DeepSlice

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.