本文整理了Java中water.fvec.Frame.<init>()
方法的一些代码示例,展示了Frame.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Frame.<init>()
方法的具体详情如下:
包路径:water.fvec.Frame
类名称:Frame
方法名:<init>
暂无
代码示例来源:origin: h2oai/h2o-2
/**
* Create a new frame based on given column data.
* @param names name of frame columns
* @param vecs columns data represented by individual data
* @return a new frame composed of given vectors.
*/
public static Frame frame(String[] names, Vec[] vecs) { return new Frame(names, vecs); }
/**
代码示例来源:origin: h2oai/h2o-2
/** Create a subframe from given interval of columns.
*
* @param startIdx index of first column (inclusive)
* @param endIdx index of the last column (exclusive)
* @return a new frame containing specified interval of columns
*/
public Frame subframe(int startIdx, int endIdx) {
Frame result = new Frame(Arrays.copyOfRange(_names,startIdx,endIdx),Arrays.copyOfRange(vecs(),startIdx,endIdx));
return result;
}
代码示例来源:origin: h2oai/h2o-3
@Override public Frame scoreReconstruction(Frame frame, Key<Frame> destination_key, boolean reverse_transform) {
Frame adaptedFr = new Frame(frame);
adaptTestForTrain(adaptedFr, true, false);
return reconstruct(frame, adaptedFr, destination_key, true, reverse_transform);
}
代码示例来源:origin: h2oai/h2o-3
private Frame generateFrameOfZeros(int rowCount, int colCount) {
Vec tempVec = Vec.makeZero(rowCount);
return(new Frame(tempVec.makeZeros(colCount))); // return a frame of zeros with size rowCount by colCount
}
代码示例来源: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-3
@Override
public Frame scoreLeafNodeAssignment(Frame frame, LeafNodeAssignmentType type, Key<Frame> destination_key) {
Frame adaptFrm = new Frame(frame);
adaptTestForTrain(adaptFrm, true, false);
final String[] names = makeAllTreeColumnNames();
AssignLeafNodeTaskBase task = AssignLeafNodeTaskBase.make(_output, type);
return task.execute(adaptFrm, names, destination_key);
}
代码示例来源:origin: h2oai/h2o-3
@Override
protected Frame makeValidWorkspace() {
// FIXME: this is not efficient, we need a sparse volatile chunks
Vec[] tmp = _valid.anyVec().makeVolatileDoubles(numClassTrees());
String[] tmpNames = new String[tmp.length];
for (int i = 0; i < tmpNames.length; i++)
tmpNames[i] = "__P_" + i;
return new Frame(tmpNames, tmp);
}
代码示例来源:origin: h2oai/h2o-3
ModelMetrics scoreAndMakeModelMetrics(SharedTreeModel model, Frame fr, Frame adaptedFr, boolean buildTreeOneNode) {
Frame input = _preds != null ? new Frame(adaptedFr).add(_preds) : adaptedFr;
return doAll(input, buildTreeOneNode)
.makeModelMetrics(model, fr, adaptedFr, _preds);
}
代码示例来源:origin: h2oai/h2o-3
public ModelMetrics doScoreMetricsOneFrame(Frame frame, Job job) {
Frame pred = this.predictScoreImpl(frame, new Frame(frame), null, job, true, CFuncRef.from(_parms._custom_metric_func));
pred.remove();
return ModelMetrics.getFromDKV(this, frame);
}
代码示例来源: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-3
@Override
public Frame scoreStagedPredictions(Frame frame, Key<Frame> destination_key) {
Frame adaptFrm = new Frame(frame);
adaptTestForTrain(adaptFrm, true, false);
final String[] names = makeAllTreeColumnNames();
final int outputcols = names.length;
return new StagedPredictionsTask(this)
.doAll(outputcols, Vec.T_NUM, adaptFrm)
.outputFrame(destination_key, names, null);
}
代码示例来源:origin: h2oai/h2o-3
static Frame discretizeTime(double[] time, Vec startVec, Vec stopVec) {
final boolean hasStartColumn = startVec != null;
final Frame f = new Frame();
if (hasStartColumn)
f.add("__startCol", startVec);
f.add("__stopCol", stopVec);
return new DiscretizeTimeTask(time, startVec != null).doAll(hasStartColumn ? 2 : 1, Vec.T_NUM, f).outputFrame();
}
代码示例来源:origin: h2oai/h2o-3
private static Frame fullFrame(CoxPH coxPH, Frame adaptFr, Frame train) {
if (! coxPH._parms.isStratified())
return adaptFr;
Frame ff = new Frame();
for (String col : coxPH._parms._stratify_by)
if (adaptFr.vec(col) == null)
ff.add(col, train.vec(col));
ff.add(adaptFr);
return ff;
}
代码示例来源:origin: h2oai/h2o-3
/**
* @return frame without rows with NAs in `columnIndex` column
*/
static Frame filterOutNAsInColumn(Frame fr, int columnIndex) {
Frame noNaPredicateFrame = new IsNotNaTask().doAll(1, Vec.T_NUM, new Frame(fr.vec(columnIndex))).outputFrame();
return selectByPredicate(fr, noNaPredicateFrame);
}
代码示例来源:origin: h2oai/h2o-3
private static Frame filterByValueBase(Frame fr, int columnIndex, double value, boolean isInverted) {
Frame predicateFrame = new FilterByValueTask(value, isInverted).doAll(1, Vec.T_NUM, new Frame(fr.vec(columnIndex))).outputFrame();
return selectByPredicate(fr, predicateFrame);
}
代码示例来源: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
void tos_into_slot( int idx, String id ) {
subRef(_ary[idx], _key[idx]);
subRef(_fcn[idx]);
Frame fr = _ary[_sp-1];
_ary[idx] = fr==null ? null : addRef(new Frame(fr));
_d [idx] = _d [_sp-1] ;
_fcn[idx] = addRef(_fcn[_sp-1]);
_str[idx] = _str[_sp-1] ;
_key[idx] = fr!=null ? id : null;
assert _ary[0]== null || check_refcnt(_ary[0].anyVec());
}
代码示例来源:origin: h2oai/h2o-3
public static void runBigScore(GLMModel model,
Frame fr, boolean computeMetrics,
boolean makePrediction, Job j) {
String[] names = model.makeScoringNames();
String[][] domains = model.makeScoringDomains(fr, computeMetrics, names);
Frame adaptedFrame = new Frame(fr);
model.adaptTestForTrain(adaptedFrame, true, computeMetrics);
Scope.track(adaptedFrame);
model
.makeBigScoreTask(domains, names, adaptedFrame, computeMetrics, makePrediction, j, null)
.doAll(adaptedFrame);
}
代码示例来源: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
代码示例来源:origin: h2oai/h2o-3
@Test
public void test_toTwoDimTable_with_empty_models_and_without_sort_metric() {
Leaderboard lb = null;
UserFeedback ufb = new UserFeedback(new AutoML());
try {
lb = Leaderboard.getOrMakeLeaderboard("dummy_lb_no_sort_metric", ufb, new Frame(), null);
TwoDimTable table = lb.toTwoDimTable();
Assert.assertNotNull("empty leaderboard should also produce a TwoDimTable", table);
Assert.assertEquals("no models in this leaderboard", table.getTableDescription());
} finally {
if (lb != null) lb.deleteWithChildren();
ufb.delete();
}
}
内容来源于网络,如有侵权,请联系作者删除!