Search in sources :

Example 1 with CreateInteractions

use of water.fvec.CreateInteractions in project h2o-2 by h2oai.

the class Interaction method serve.

@Override
public Response serve() {
    try {
        source.read_lock(self());
        //      if (max_factors < 1) throw new IllegalArgumentException("max_factors must be >1.");
        if (factors.length == 0)
            throw new IllegalArgumentException("factors must be non-empty.");
        if (pairwise && factors.length < 3)
            Log.info("Ignoring the pairwise option, requires 3 or more factors.");
        for (int v : factors) {
            if (!source.vecs()[v].isEnum()) {
                throw new IllegalArgumentException("Column " + source.names()[v] + " is not a factor.");
            }
        }
        if (destination_key == null) {
            String target = source._key.toString() + ".interaction.";
            target += "C" + factors[0];
            for (int i = 1; i < factors.length; ++i) {
                target += "_C" + factors[i];
            }
            destination_key = Key.make(target);
        }
        Timer time = new Timer();
        final createInteractions in = new createInteractions(this);
        H2O.submitTask(in);
        in.join();
        _time = time.time();
        Log.info(report());
        return Response.done(this);
    } catch (Throwable t) {
        return Response.error(t);
    } finally {
        source.unlock(self());
    }
}
Also used : water.fvec.createInteractions(water.fvec.createInteractions) RString(water.util.RString)

Example 2 with CreateInteractions

use of water.fvec.CreateInteractions in project h2o-3 by h2oai.

the class Interaction method execImpl.

public Job<Frame> execImpl(Key<Frame> dest) {
    _job = new Job(dest == null ? Key.make() : dest, Frame.class.getName(), "CreateFrame");
    Frame source_frame = DKV.getGet(_source_frame);
    assert (source_frame != null);
    if (_factor_columns == null || _factor_columns.length == 0)
        throw new IllegalArgumentException("factor_columns must be specified.");
    if (_pairwise && _factor_columns.length < 3)
        Log.info("Ignoring the pairwise option, requires 3 or more factors.");
    _factors = new int[_factor_columns.length];
    int count = 0;
    for (String v : _factor_columns) {
        int idx = source_frame.find(v);
        if (idx >= 0) {
            if (!source_frame.vecs()[idx].isCategorical()) {
                throw new IllegalArgumentException("Column " + v + " is not categorical.");
            }
            _factors[count++] = idx;
        } else {
            throw new IllegalArgumentException("Column " + v + " not found.");
        }
    }
    CreateInteractions in = new CreateInteractions(this);
    return _job.start(in, in.work());
}
Also used : Frame(water.fvec.Frame) CreateInteractions(water.fvec.CreateInteractions) Job(water.Job) PrettyPrint(water.util.PrettyPrint)

Aggregations

Job (water.Job)1 CreateInteractions (water.fvec.CreateInteractions)1 Frame (water.fvec.Frame)1 water.fvec.createInteractions (water.fvec.createInteractions)1 PrettyPrint (water.util.PrettyPrint)1 RString (water.util.RString)1