/** * @return list of keys of models sorted by the default metric for the model category, fetched from the DKV */ Key<Model>[] getModelKeys() { return ((Leaderboard)DKV.getGet(this._key)).models; }
private static Model[] modelsForModelKeys(Key<Model>[] modelKeys, Model[] models) { assert models.length >= modelKeys.length; int i = 0; for (Key<Model> modelKey : modelKeys) models[i++] = getGet(modelKey); return models; }
public Job job() { if (null == this.job) return null; return DKV.getGet(this.job._key); }
@Override protected void setupLocal() { _model = DKV.getGet(_modelKey); } @Override
private boolean isTerminated() { return _terminateKey != null && ((IcedInt)(DKV.getGet(_terminateKey)))._val==1; } private void terminate() {
@Override protected List<Model> getSubModels() { LinkedList<Model> subModels = new LinkedList<>(); if (model._output._metalearner != null) subModels.add(model._output._metalearner); for (int i = 0; i < model._parms._base_models.length; i++) if (model._parms._base_models[i] != null) { Model aModel = DKV.getGet(model._parms._base_models[i]); subModels.add(aModel); } return subModels; }
private Frame[] getEncodingMapFrames(Env env, Env.StackHelp stk, AstRoot asts[]) { String[] frameKeys = getArgAsStrings(env, stk, asts[2]); Frame[] framesWithEncodings = new Frame[frameKeys.length]; int i = 0; for(String key : frameKeys) { framesWithEncodings[i++] = DKV.getGet(key); } return framesWithEncodings; }
@SuppressWarnings("unused") // called through reflection by RequestServer /** Return an AutoML object by ID. */ public AutoMLV99 fetch(int version, AutoMLV99 autoMLV99) { AutoML autoML = DKV.getGet(autoMLV99.automl_id.name); return autoMLV99.fillFromImpl(autoML); }
@SuppressWarnings({"unused", "unchecked"}) public final FrameMatrix read_impl(AutoBuffer ab) { _frame_key = (Key<Frame>) Key.read_impl(null, ab); // install in DKV if not already there if (DKV.getGet(_frame_key) == null) toFrame(_frame_key); return this; }
public GLMRegularizationPathV3 extractRegularizationPath(int v, GLMRegularizationPathV3 args) { GLMModel model = DKV.getGet(args.model.key()); if(model == null) throw new IllegalArgumentException("missing source model " + args.model); return new GLMRegularizationPathV3().fillFromImpl(model.getRegularizationPath()); } // instead of adding a new endpoint, just put this stupid test functionality here
public UserFeedback(AutoML autoML) { this._key = make(idForRun(autoML._key)); this.autoML = autoML; UserFeedback old = DKV.getGet(this._key); if (null == old || null == feedbackEvents) { feedbackEvents = new UserFeedbackEvent[0]; DKV.put(this); } }
void buildModelOutput(Word2VecModelInfo modelInfo) { IcedHashMapGeneric<BufferedString, Integer> vocab = ((Vocabulary) DKV.getGet(modelInfo._vocabKey))._data; BufferedString[] words = new BufferedString[vocab.size()]; for (BufferedString str : vocab.keySet()) words[vocab.get(str)] = str; _output._vecSize = _parms._vec_size; _output._vecs = modelInfo._syn0; _output._words = words; _output._vocab = vocab; }
/** Get the expanded (interactions + offsets) dataset. Careful printing! Test only */ public DataInfoFrameV3 getDataInfoFrame(int version, DataInfoFrameV3 args) { Frame fr = DKV.getGet(args.frame.key()); if( null==fr ) throw new IllegalArgumentException("no frame found"); args.result = new KeyV3.FrameKeyV3(oneHot(fr, Model.InteractionSpec.allPairwise(args.interactions), args.use_all, args.standardize, args.interactions_only, true)._key); return args; }
/** * Helper to convert a Matrix into a Frame * * @param m Matrix * @param key Key for output Frame * @return Reference to Frame (which is also in DKV) */ private static Frame toFrame(Matrix m, Key<Frame> key) { H2O.submitTask(new ConvertMatrixToFrame(m, key)).join(); Frame f = DKV.getGet(key); assert f != null; return f; }
@Override protected Frame getPredictionsForBaseModel(Model model, Frame actualsFrame, boolean isTraining) { Frame fr; if (isTraining) { // for training, retrieve predictions from cv holdout predictions frame as all base models are required to get built with keep_cross_validation_frame=true if (null == model._output._cross_validation_holdout_predictions_frame_id) throw new H2OIllegalArgumentException("Failed to find the xval predictions frame id. . . Looks like keep_cross_validation_predictions wasn't set when building the models."); fr = DKV.getGet(model._output._cross_validation_holdout_predictions_frame_id); if (null == fr) throw new H2OIllegalArgumentException("Failed to find the xval predictions frame. . . Looks like keep_cross_validation_predictions wasn't set when building the models, or the frame was deleted."); } else { fr = buildPredictionsForBaseModel(model, actualsFrame); } return fr; }
private void putMeAsBestModel(Key bestModelKey) { DKV.put(bestModelKey, IcedUtils.deepCopy(this)); assert DKV.get(bestModelKey) != null; assert ((DeepWaterModel)DKV.getGet(bestModelKey)).compareTo(this) <= 0; }
@Override public void cv_computeAndSetOptimalParameters(ModelBuilder<M, P, O>[] cvModelBuilders) { if( _parms._stopping_rounds == 0 && _parms._max_runtime_secs == 0) return; // No exciting changes to stopping conditions // Extract stopping conditions from each CV model, and compute the best stopping answer _parms._stopping_rounds = 0; _parms._max_runtime_secs = 0; int sum = 0; for( int i=0; i<cvModelBuilders.length; ++i ) sum += ((SharedTreeModel.SharedTreeOutput)DKV.<Model>getGet(cvModelBuilders[i].dest())._output)._ntrees; _parms._ntrees = (int)((double)sum/cvModelBuilders.length); warn("_ntrees", "Setting optimal _ntrees to " + _parms._ntrees + " for cross-validation main model based on early stopping of cross-validation models."); warn("_stopping_rounds", "Disabling convergence-based early stopping for cross-validation main model."); warn("_max_runtime_secs", "Disabling maximum allowed runtime for cross-validation main model."); } }
private void putMeAsBestModel(Key bestModelKey) { DeepLearningModel bestModel = IcedUtils.deepCopy(this); DKV.put(bestModelKey, bestModel); if (model_info().get_params()._elastic_averaging) { DeepLearningModelInfo eamodel = DKV.getGet(model_info.elasticAverageModelInfoKey()); if (eamodel != null) DKV.put(bestModel.model_info().elasticAverageModelInfoKey(), eamodel); } assert (DKV.get(bestModelKey) != null); assert (bestModel.compareTo(this) <= 0); }
@BeforeClass public static void setup() { stall_till_cloudsize(1); _covtype = parse_test_file("smalldata/covtype/covtype.20k.data"); _covtype.replace(_covtype.numCols()-1,_covtype.lastVec().toCategoricalVec()).remove(); Key[] keys = new Key[]{Key.make("train"),Key.make("test")}; H2O.submitTask(new FrameSplitter(_covtype, new double[]{.8},keys,null)).join(); _train = DKV.getGet(keys[0]); _test = DKV.getGet(keys[1]); }