Search in sources :

Example 1 with ValNums

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);
}
Also used : Frame(water.fvec.Frame) Vec(water.fvec.Vec) ArrayList(java.util.ArrayList) ValNums(water.rapids.vals.ValNums)

Example 2 with ValNums

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);
}
Also used : Frame(water.fvec.Frame) ValNums(water.rapids.vals.ValNums)

Example 3 with ValNums

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);
}
Also used : Frame(water.fvec.Frame) Vec(water.fvec.Vec) ValNums(water.rapids.vals.ValNums)

Example 4 with ValNums

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);
}
Also used : Frame(water.fvec.Frame) ValNums(water.rapids.vals.ValNums)

Example 5 with ValNums

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);
}
Also used : Frame(water.fvec.Frame) Vec(water.fvec.Vec) ValNums(water.rapids.vals.ValNums)

Aggregations

Frame (water.fvec.Frame)10 ValNums (water.rapids.vals.ValNums)10 Vec (water.fvec.Vec)6 QuantileModel (hex.quantile.QuantileModel)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 Set (java.util.Set)1 MRTask (water.MRTask)1 Chunk (water.fvec.Chunk)1 AstFrame (water.rapids.ast.AstFrame)1 AstRoot (water.rapids.ast.AstRoot)1 AstNum (water.rapids.ast.params.AstNum)1 AstNumList (water.rapids.ast.params.AstNumList)1 AstStr (water.rapids.ast.params.AstStr)1 AstStrList (water.rapids.ast.params.AstStrList)1 AstGroup (water.rapids.ast.prims.mungers.AstGroup)1 AstMean (water.rapids.ast.prims.reducers.AstMean)1 AstMedian (water.rapids.ast.prims.reducers.AstMedian)1 ValFrame (water.rapids.vals.ValFrame)1 IcedDouble (water.util.IcedDouble)1