use of water.rapids.vals.ValNums in project h2o-3 by h2oai.
the class AstFilterNaCols method apply.
@Override
public ValNums apply(Env env, Env.StackHelp stk, AstRoot[] asts) {
Frame fr = stk.track(asts[1].exec(env)).getFrame();
double frac = asts[2].exec(env).getNum();
double nrow = fr.numRows() * frac;
Vec[] vecs = fr.vecs();
ArrayList<Double> idxs = new ArrayList<>();
for (double i = 0; i < fr.numCols(); i++) if (vecs[(int) i].naCnt() < nrow)
idxs.add(i);
double[] include_cols = new double[idxs.size()];
int i = 0;
for (double d : idxs) include_cols[i++] = d;
return new ValNums(include_cols);
}
use of water.rapids.vals.ValNums in project h2o-3 by h2oai.
the class AstNaCnt method apply.
// (naCnt fr)
@Override
public ValNums apply(Env env, Env.StackHelp stk, AstRoot[] asts) {
Frame fr = stk.track(asts[1].exec(env)).getFrame();
double[] ds = new double[fr.numCols()];
for (int i = 0; i < fr.numCols(); ++i) ds[i] = fr.vec(i).naCnt();
return new ValNums(ds);
}
use of water.rapids.vals.ValNums in project h2o-3 by h2oai.
the class AstSdev method apply.
@Override
public ValNums apply(Env env, Env.StackHelp stk, AstRoot[] asts) {
Frame fr = stk.track(asts[1].exec(env)).getFrame();
boolean narm = asts[2].exec(env).getNum() == 1;
double[] ds = new double[fr.numCols()];
Vec[] vecs = fr.vecs();
for (int i = 0; i < fr.numCols(); i++) ds[i] = (!vecs[i].isNumeric() || vecs[i].length() == 0 || (!narm && vecs[i].naCnt() > 0)) ? Double.NaN : vecs[i].sigma();
return new ValNums(ds);
}
use of water.rapids.vals.ValNums in project h2o-3 by h2oai.
the class AstIsFactor method apply.
@Override
public ValNums apply(Env env, Env.StackHelp stk, AstRoot[] asts) {
Frame fr = stk.track(asts[1].exec(env)).getFrame();
if (fr.numCols() == 1)
return new ValNums(new double[] { fr.anyVec().isCategorical() ? 1 : 0 });
double[] ds = new double[fr.numCols()];
for (int i = 0; i < fr.numCols(); i++) ds[i] = fr.vec(i).isCategorical() ? 1 : 0;
return new ValNums(ds);
}
use of water.rapids.vals.ValNums in project h2o-3 by h2oai.
the class AstSkewness method apply.
// (skewness ary na.rm)
@Override
public ValNums apply(Env env, Env.StackHelp stk, AstRoot[] asts) {
Frame fr = stk.track(asts[1].exec(env)).getFrame();
boolean narm = asts[2].exec(env).getNum() == 1;
double[] ds = new double[fr.numCols()];
Vec[] vecs = fr.vecs();
for (int i = 0; i < fr.numCols(); i++) ds[i] = (!vecs[i].isNumeric() || vecs[i].length() == 0 || (!narm && vecs[i].naCnt() > 0)) ? Double.NaN : skewness(vecs[i]);
return new ValNums(ds);
}
Aggregations