All Downloads are FREE. Search and download functionalities are using the official Maven repository.

ai.h2o.automl.leaderboard.TrainingTime Maven / Gradle / Ivy

There is a newer version: 3.46.0.6
Show newest version
package ai.h2o.automl.leaderboard;

import hex.Model;
import water.Iced;
import water.Key;
import water.util.Log;

/**
 * A cell providing the time needed to train the model.
 */
public class TrainingTime extends Iced implements LeaderboardCell {

    public static final LeaderboardColumn COLUMN = new LeaderboardColumn("training_time_ms", "long", "%s");

    private final Key _modelId;

    private Long _trainingTimeMillis;

    public TrainingTime(Model model) {
        _modelId = model._key;
        _trainingTimeMillis = model._output._run_time;
    }

    public TrainingTime(Key modelId) {
        _modelId = modelId;
    }

    @Override
    public LeaderboardColumn getColumn() {
        return COLUMN;
    }

    @Override
    public Key getModelId() {
        return _modelId;
    }

    @Override
    public Long getValue() {
        return _trainingTimeMillis;
    }

    @Override
    public void setValue(Long value) {
        _trainingTimeMillis = value;
    }

    @Override
    public boolean isNA() {
        return getValue() == null || getValue() < 0;
    }

    @Override
    public Long fetch() {
        if (getValue() == null) {
            try {
                setValue(_modelId.get()._output._run_time);
            } catch (Exception e) {
                Log.err("Could not retrieve training time for model "+_modelId, e);
                setValue(-1L);
            }
        }
        return getValue();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy