本文整理了Java中water.fvec.Frame.vecs()
方法的一些代码示例,展示了Frame.vecs()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Frame.vecs()
方法的具体详情如下:
包路径:water.fvec.Frame
类名称:Frame
方法名:vecs
暂无
代码示例来源:origin: h2oai/h2o-2
protected final Vec[] selectVecs(Frame frame) {
Vec[] vecs = new Vec[cols.length];
for( int i = 0; i < cols.length; i++ )
vecs[i] = frame.vecs()[cols[i]];
return vecs;
}
代码示例来源:origin: h2oai/h2o-2
/** Returns the vector by given index.
* <p>The call is direct equivalent to call <code>vecs()[i]</code> and
* it does not do any array bounds checking.</p>
* @param idx idx of column
* @return this frame idx-th vector, never returns <code>null</code>
*/
public Vec vec(int idx) {
Vec[] vecs = vecs();
return vecs[idx];
}
/** Returns a subframe of this frame containing only vectors with desired names.
代码示例来源:origin: h2oai/h2o-2
/** Time status for every Vec */
public byte[] times() {
byte bs[] = new byte[vecs().length];
for( int i=0; i<vecs().length; i++ )
bs[i] = vecs()[i]._time;
return bs;
}
代码示例来源:origin: h2oai/h2o-2
private String[][] domains(int [] cols){
Vec [] vecs = vecs();
String [][] res = new String[cols.length][];
for(int i = 0; i < cols.length; ++i)
res[i] = vecs[cols[i]]._domain;
return res;
}
代码示例来源:origin: h2oai/h2o-2
public void swap( int lo, int hi ) {
assert 0 <= lo && lo < _keys.length;
assert 0 <= hi && hi < _keys.length;
if( lo==hi ) return;
Vec vecs[] = vecs();
Vec v = vecs [lo]; vecs [lo] = vecs [hi]; vecs [hi] = v;
Key k = _keys[lo]; _keys [lo] = _keys [hi]; _keys [hi] = k;
String n=_names[lo]; _names[lo] = _names[hi]; _names[hi] = n;
}
代码示例来源:origin: h2oai/h2o-2
/** Returns the first readable vector. */
public Vec anyVec() {
Vec c0 = _col0; // single read
if( c0 != null ) return c0;
for( Vec v : vecs() )
if( v.readable() )
return (_col0 = v);
return null;
}
/* Returns the only Vector, or tosses IAE */
代码示例来源:origin: h2oai/h2o-2
@Override void apply(Env env, int argcnt, ASTApply apply) {
Frame fr = env.peekAry();
if (fr.vecs().length > 1)
throw new IllegalArgumentException("sd does not apply to multiple cols.");
if (fr.vecs()[0].isEnum())
throw new IllegalArgumentException("sd only applies to numeric vector.");
double sig = fr.vecs()[0].sigma();
env.pop();
env.poppush(sig);
}
}
代码示例来源:origin: h2oai/h2o-2
DRFTree( Frame fr, int ncols, char nbins, char nclass, int min_rows, int mtrys, long seed ) {
super(fr._names, ncols, nbins, nclass, min_rows, seed);
_mtrys = mtrys;
_rand = createRNG(seed);
_seeds = new long[fr.vecs()[0].nChunks()];
for( int i=0; i<_seeds.length; i++ )
_seeds[i] = _rand.nextLong();
}
// Return a deterministic chunk-local RNG. Can be kinda expensive.
代码示例来源:origin: h2oai/h2o-2
protected final Frame selectFrame(Frame frame) {
Vec[] vecs = new Vec[cols.length];
String[] names = new String[cols.length];
for( int i = 0; i < cols.length; i++ ) {
vecs[i] = frame.vecs()[cols[i]];
names[i] = frame.names()[cols[i]];
}
return new Frame(names, vecs);
}
}
代码示例来源:origin: h2oai/h2o-2
public Futures closeAppendables(Futures fs) {
_col0 = null; // Reset cache
int len = vecs().length;
for( int i=0; i<len; i++ ) {
Vec v = _vecs[i];
if( v instanceof AppendableVec )
DKV.put(_keys[i],_vecs[i] = ((AppendableVec)v).close(fs),fs);
}
return fs;
}
代码示例来源:origin: h2oai/h2o-3
/** Number of columns with categoricals expanded.
* @return Number of columns with categoricals expanded into indicator columns */
public static int numColsExp(Frame fr, boolean useAllFactorLevels) {
final int uAFL = useAllFactorLevels ? 0 : 1;
int cols = 0;
for( Vec vec : fr.vecs() )
cols += (vec.isCategorical() && vec.domain() != null) ? vec.domain().length - uAFL : 1;
return cols;
}
代码示例来源:origin: h2oai/h2o-2
public Frame subRef( Frame fr, String key ) {
if( fr == null ) return null;
Futures fs = new Futures();
for( Vec vec : fr.vecs() ) subRef(vec,fs);
fs.blockForPending();
return null;
}
// Lower refcounts on all vecs captured in the inner environment
代码示例来源:origin: h2oai/h2o-3
@Override public Frame outputFrame(Key<Frame> key, String [] names, String [][] domains){
_predFrame = new Frame(key, names, _predFrame.vecs());
if (domains!=null)
_predFrame.vec(0).setDomain(domains[0]); //only the label is ever categorical
if (_predFrame._key!=null)
DKV.put(_predFrame);
return _predFrame;
}
@Override public void map(Chunk[] chks, NewChunk[] cpreds) { }
代码示例来源:origin: h2oai/h2o-2
private Frame setTest() {
if (validation == null) return null;
Frame test = null;
ArrayList<Integer> v_ignored_cols = new ArrayList<Integer>();
for (int ignored_col : ignored_cols) if (validation.find(source.names()[ignored_col]) != -1) v_ignored_cols.add(ignored_col);
int[] v_ignored = new int[v_ignored_cols.size()];
for (int i = 0; i < v_ignored.length; ++i) v_ignored[i] = v_ignored_cols.get(i);
if (validation != null) test = FrameTask.DataInfo.prepareFrame(validation, validation.vecs()[validation.find(source.names()[source.find(response)])], v_ignored, !regression, false, false);
if (test != null && test.lastVec().masterVec() != null) gtrash(test.lastVec());
return test;
}
private Frame setStrat(Frame train, Frame test, Vec resp) {
代码示例来源:origin: h2oai/h2o-2
public Vec replace(int col, Vec nv) {
if (col >= numCols())
throw new IllegalArgumentException("Trying to select column "+(col+1)+" but only "+numCols()+" present.");
Vec rv = vecs()[col];
assert rv.group().equals(nv.group());
_vecs[col] = nv;
_keys[col] = nv._key;
if( DKV.get(nv._key)==null ) // If not already in KV, put it there
DKV.put(nv._key, nv);
return rv;
}
代码示例来源:origin: h2oai/h2o-3
public DataInfo validDinfo(Frame valid) {
DataInfo res = new DataInfo(_adaptedFrame,null,1,_useAllFactorLevels,TransformType.NONE,TransformType.NONE,_skipMissing,_imputeMissing,!(_skipMissing || _imputeMissing),_weights,_offset,_fold);
res._interactions = _interactions;
res._interactionSpec = _interactionSpec;
if (_interactionSpec != null) {
valid = Model.makeInteractions(valid, true, _interactions, _useAllFactorLevels, _skipMissing, false).add(valid);
}
res._adaptedFrame = new Frame(_adaptedFrame.names(),valid.vecs(_adaptedFrame.names()));
res._valid = true;
return res;
}
代码示例来源:origin: h2oai/h2o-2
@Override
public void callback(GetNonZerosTsk gnz) {
new VecTsk(new Callback(), _progressKey, gnz._vals).asyncExec(Utils.append(_x.vecs(gnz._idxs), _z.vec(i)));
}
}).asyncExec(_y.vec(i));
代码示例来源:origin: h2oai/h2o-2
@Override void apply(Env env, int argcnt, ASTApply apply) {
String skey = env.key();
Frame fr = env.popAry();
if (fr.numCols() != 1) throw new IllegalArgumentException("trim works on a single column at a time.");
String[] doms = fr.anyVec().domain().clone();
for (int i = 0; i < doms.length; ++i) doms[i] = doms[i].trim();
Frame fr2 = new Frame(fr.names(), fr.vecs());
fr2.anyVec()._domain = doms;
env.subRef(fr, skey);
env.poppush(1, fr2, null);
}
}
代码示例来源:origin: h2oai/h2o-3
int prep(Frame fr) {
fr.remove("ID").remove(); // Remove not-predictive ID
int ci = fr.find("RACE"); // Change RACE to categorical
Scope.track(fr.replace(ci,fr.vecs()[ci].toCategoricalVec()));
return fr.find("CAPSULE"); // Prostate: predict on CAPSULE
}
}, false, DistributionFamily.bernoulli);
代码示例来源:origin: h2oai/h2o-3
private GLMScore makeScoringTask(Frame adaptFrm, boolean generatePredictions, Job j){
int responseId = adaptFrm.find(_output.responseName());
if(responseId > -1 && adaptFrm.vec(responseId).isBad()) { // remove inserted invalid response
adaptFrm = new Frame(adaptFrm.names(),adaptFrm.vecs());
adaptFrm.remove(responseId);
}
// Build up the names & domains.
final boolean computeMetrics = adaptFrm.vec(_output.responseName()) != null && !adaptFrm.vec(_output.responseName()).isBad();
String [] domain = _output.nclasses()<=1 ? null : !computeMetrics ? _output._domains[_output._domains.length-1] : adaptFrm.lastVec().domain();
// Score the dataset, building the class distribution & predictions
return new GLMScore(j, this, _output._dinfo.scoringInfo(_output._names,adaptFrm),domain,computeMetrics, generatePredictions);
}
/** Score an already adapted frame. Returns a new Frame with new result
内容来源于网络,如有侵权,请联系作者删除!