use of water.MRTask in project h2o-3 by h2oai.
the class TransformWrappedVecTest method testInversion.
@Test
public void testInversion() {
Vec v = null;
try {
v = Vec.makeZero(1 << 20);
AstFunction ast = (AstFunction) Rapids.parse("{ x . (- 1 x) }");
Vec iv = new TransformWrappedVec(v, ast);
new MRTask() {
@Override
public void map(Chunk c) {
for (int i = 0; i < c._len; ++i) if (c.atd(i) != 1)
throw new RuntimeException("moo");
}
}.doAll(iv);
iv.remove();
} finally {
if (null != v)
v.remove();
}
}
use of water.MRTask in project h2o-3 by h2oai.
the class VecDataInputStreamTest method makeRandomByteVec.
private static Vec makeRandomByteVec(Vec blueprint) {
final Vec v0 = new Vec(blueprint.group().addVec(), blueprint._rowLayout, null, Vec.T_NUM);
final int nchunks = v0.nChunks();
new MRTask() {
@Override
protected void setupLocal() {
for (int i = 0; i < nchunks; i++) {
Key k = v0.chunkKey(i);
if (k.home()) {
int len = (int) (v0.espc()[i + 1] - v0.espc()[i]);
byte[] bytes = new byte[len];
new Random(i).nextBytes(bytes);
DKV.put(k, new C1NChunk(bytes), _fs);
}
}
}
}.doAllNodes();
DKV.put(v0._key, v0);
return v0;
}
use of water.MRTask in project h2o-3 by h2oai.
the class DataInfoTestAdapt method checkFrame.
private void checkFrame(final Frame checkMe, final Frame gold) {
Vec[] vecs = new Vec[checkMe.numCols() + gold.numCols()];
new MRTask() {
@Override
public void map(Chunk[] cs) {
int off = checkMe.numCols();
for (int i = 0; i < off; ++i) {
for (int r = 0; r < cs[0]._len; ++r) {
double check = cs[i].atd(r);
double gold = cs[i + off].atd(r);
if (Math.abs(check - gold) > 1e-12)
throw new RuntimeException("bonk");
}
}
}
}.doAll(vecs);
}
use of water.MRTask in project h2o-3 by h2oai.
the class ModelMetricsRegression method computeHuberDelta.
public static double computeHuberDelta(Vec actual, Vec preds, Vec weight, double huberAlpha) {
Vec absdiff = new MRTask() {
@Override
public void map(Chunk[] cs, NewChunk[] nc) {
for (int i = 0; i < cs[0].len(); ++i) nc[0].addNum(Math.abs(cs[0].atd(i) - cs[1].atd(i)));
}
}.doAll(1, (byte) 3, new Frame(new String[] { "preds", "actual" }, new Vec[] { preds, actual })).outputFrame().anyVec();
// make a deep copy of the model's current distribution state (huber delta)
//compute huber delta based on huber alpha quantile on absolute prediction error
double hd = MathUtils.computeWeightedQuantile(weight, absdiff, huberAlpha);
absdiff.remove();
return hd;
}
use of water.MRTask in project h2o-3 by h2oai.
the class UnfoldingFrame method makeVecs.
protected List<Vec> makeVecs() throws IOException {
Vec[] vecs = new Vec[width];
for (int j = 0; j < width; j++) {
vecs[j] = buildZeroVec();
}
MRTask task = new MRTask() {
@Override
public void map(Chunk[] cs) {
// TODO(vlad): find a solution for empty
int size = cs[0].len();
long start = cs[0].start();
for (int r = 0; r < size; r++) {
long i = r + start;
List<X> values = function.apply(i);
for (int j = 0; j < cs.length; j++) {
DataChunk<X> tc = factory.apply(cs[j]);
tc.set(r, j < values.size() ? values.get(j) : null);
}
}
}
};
MRTask mrTask = task.doAll(vecs);
return Arrays.asList(mrTask._fr.vecs());
}
Aggregations