예제 #1
0
    GridSearch(Key gkey, MP params, Map<String, Object[]> hyperSearch) {
      super(
          Key.<Grid>make("GridSearch_" + modelName() + Key.rand()),
          gkey,
          modelName() + " Grid Search");
      _params = params;
      _hyperSearch = hyper2doubles(hyperSearch);

      // Count of models in this search
      int work = 1;
      for (double hparms[] : _hyperSearch) work *= hparms.length;
      _total_models = work;

      // Check all parameter combos for validity
      double[] hypers = new double[_hyperSearch.length];
      // FIXME: this expect finite space!
      for (int[] hidx = new int[_hyperSearch.length]; hidx != null; hidx = nextModel(hidx)) {
        ModelBuilder mb = getBuilder(params, hypers(hidx, hypers));
        if (mb.error_count() > 0) throw new IllegalArgumentException(mb.validationErrors());
      }
    }