當前位置: 首頁>>代碼示例>>Java>>正文


Java H2OIllegalArgumentException類代碼示例

本文整理匯總了Java中water.exceptions.H2OIllegalArgumentException的典型用法代碼示例。如果您正苦於以下問題:Java H2OIllegalArgumentException類的具體用法?Java H2OIllegalArgumentException怎麽用?Java H2OIllegalArgumentException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


H2OIllegalArgumentException類屬於water.exceptions包,在下文中一共展示了H2OIllegalArgumentException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: validateWithCheckpoint

import water.exceptions.H2OIllegalArgumentException; //導入依賴的package包/類
/** This method will take actual parameters and validate them with parameters of
 * requested checkpoint. In case of problem, it throws an API exception.
 *
 * @param checkpointParameters checkpoint parameters
 */
public void validateWithCheckpoint(SharedTreeParameters checkpointParameters) {
  for (Field fAfter : this.getClass().getFields()) {
    // only look at non-modifiable fields
    if (ArrayUtils.contains(getCheckpointNonModifiableFields(),fAfter.getName())) {
      for (Field fBefore : checkpointParameters.getClass().getFields()) {
        if (fBefore.equals(fAfter)) {
          try {
            if (!PojoUtils.equals(this, fAfter, checkpointParameters, checkpointParameters.getClass().getField(fAfter.getName()))) {
              throw new H2OIllegalArgumentException(fAfter.getName(), "TreeBuilder", "Field " + fAfter.getName() + " cannot be modified if checkpoint is specified!");
            }
          } catch (NoSuchFieldException e) {
            throw new H2OIllegalArgumentException(fAfter.getName(), "TreeBuilder", "Field " + fAfter.getName() + " is not supported by checkpoint!");
          }
        }
      }
    }
  }
}
 
開發者ID:kyoren,項目名稱:https-github.com-h2oai-h2o-3,代碼行數:24,代碼來源:SharedTreeModel.java

示例2: validateHyperParams

import water.exceptions.H2OIllegalArgumentException; //導入依賴的package包/類
/**
 * Validate given hyper parameters with respect to type parameter P.
 *
 * It verifies that given parameters are annotated in P with @API annotation
 *
 * @param params      regular model build parameters
 * @param hyperParams map of hyper parameters
 */
protected void validateHyperParams(P params, Map<String, Object[]> hyperParams) {
  List<SchemaMetadata.FieldMetadata> fsMeta = SchemaMetadata.getFieldMetadata(params);
  for (Map.Entry<String, Object[]> hparam : hyperParams.entrySet()) {
    SchemaMetadata.FieldMetadata fieldMetadata = null;
    // Found corresponding metadata about the field
    for (SchemaMetadata.FieldMetadata fm : fsMeta) {
      if (fm.name.equals(hparam.getKey())) {
        fieldMetadata = fm;
        break;
      }
    }
    if (fieldMetadata == null) {
      throw new H2OIllegalArgumentException(hparam.getKey(), "grid",
                                            "Unknown hyper parameter for grid search!");
    }
    if (!fieldMetadata.is_gridable) {
      throw new H2OIllegalArgumentException(hparam.getKey(), "grid",
                                            "Illegal hyper parameter for grid search! The parameter '"
                                            + fieldMetadata.name + " is not gridable!");
    }
  }
}
 
開發者ID:kyoren,項目名稱:https-github.com-h2oai-h2o-3,代碼行數:31,代碼來源:GridSearchHandler.java

示例3: getPreviewChunkBytes

import water.exceptions.H2OIllegalArgumentException; //導入依賴的package包/類
/** Get all the bytes of a given chunk.
 *  Useful for previewing sections of files.
 *
 *  @param chkIdx index of desired chunk
 *  @return array of initial bytes
 */
public byte[] getPreviewChunkBytes(int chkIdx) {
  if (chkIdx >= nChunks())
    throw new H2OIllegalArgumentException("Asked for chunk index beyond the number of chunks.");
  if (chkIdx == 0)
    return chunkForChunkIdx(chkIdx)._mem;
  else { //must eat partial lines
    // FIXME: a hack to consume partial lines since each preview chunk is seen as cidx=0
    byte[] mem = chunkForChunkIdx(chkIdx)._mem;
    int i = 0, j = mem.length-1;
    while (i < mem.length && mem[i] != CHAR_CR && mem[i] != CHAR_LF) i++;
    while (j > i && mem[j] != CHAR_CR && mem[j] != CHAR_LF) j--;
    if (j-i > 1) return Arrays.copyOfRange(mem,i,j);
    else return null;
  }
}
 
開發者ID:kyoren,項目名稱:https-github.com-h2oai-h2o-3,代碼行數:22,代碼來源:ByteVec.java

示例4: calcTypeaheadMatches

import water.exceptions.H2OIllegalArgumentException; //導入依賴的package包/類
/**
 * Calculate typeahead matches for src
 *
 * @param filter Source string to match for typeahead
 * @param limit Max number of entries to return
 * @return List of matches
 */
public ArrayList<String> calcTypeaheadMatches(String filter, int limit) {
  String s = filter.toLowerCase();
  if (s.startsWith("http:") || s.startsWith("https:")) {
    if (httpUrlExists(filter)) {
      ArrayList<String> arrayList = new ArrayList<>();
      arrayList.add(filter);
      return arrayList;
    }
    else {
      return new ArrayList<>();
    }
  }
  else if (s.startsWith("hdfs:") || s.startsWith("s3:") || s.startsWith("s3n:") ||
           s.startsWith("s3a:") || s.startsWith("maprfs:")) {
    if (I[Value.HDFS] == null) {
      throw new H2OIllegalArgumentException("HDFS, S3, S3N, and S3A support is not configured");
    }

    return I[Value.HDFS].calcTypeaheadMatches(filter, limit);
  }

  return I[Value.NFS].calcTypeaheadMatches(filter, limit);
}
 
開發者ID:kyoren,項目名稱:https-github.com-h2oai-h2o-3,代碼行數:31,代碼來源:PersistManager.java

示例5: strToColumnTypes

import water.exceptions.H2OIllegalArgumentException; //導入依賴的package包/類
public static byte[] strToColumnTypes(String[] strs) {
  if (strs == null) return null;
  byte[] types = new byte[strs.length];
  for(int i=0; i< types.length;i++) {
    switch (strs[i].toLowerCase()) {
    case "unknown": types[i] = Vec.T_BAD;  break;
    case "uuid":    types[i] = Vec.T_UUID; break;
    case "string":  types[i] = Vec.T_STR;  break;
    case "numeric": types[i] = Vec.T_NUM;  break;
    case "enum":    types[i] = Vec.T_CAT;  break;
    case "time":    types[i] = Vec.T_TIME; break;
    default:        types[i] = Vec.T_BAD;
      throw new H2OIllegalArgumentException("Provided column type "+ strs[i] + " is unknown.  Cannot proceed with parse due to invalid argument.");
    }
  }
  return types;
}
 
開發者ID:kyoren,項目名稱:https-github.com-h2oai-h2o-3,代碼行數:18,代碼來源:ParseSetup.java

示例6: score

import water.exceptions.H2OIllegalArgumentException; //導入依賴的package包/類
/**
 * Score a frame with the given model and return just the metrics.
 * <p>
 * NOTE: ModelMetrics are now always being created by model.score. . .
 */
@SuppressWarnings("unused") // called through reflection by RequestServer
public ModelMetricsListSchemaV3 score(int version, ModelMetricsListSchemaV3 s) {
  // parameters checking:
  if (null == s.model) throw new H2OIllegalArgumentException("model", "predict", s.model);
  if (null == DKV.get(s.model.name)) throw new H2OKeyNotFoundArgumentException("model", "predict", s.model.name);

  if (null == s.frame) throw new H2OIllegalArgumentException("frame", "predict", s.frame);
  if (null == DKV.get(s.frame.name)) throw new H2OKeyNotFoundArgumentException("frame", "predict", s.frame.name);

  ModelMetricsList parms = s.createAndFillImpl();
  parms._model.score(parms._frame, parms._predictions_name).remove(); // throw away predictions, keep metrics as a side-effect
  ModelMetricsListSchemaV3 mm = this.fetch(version, s);

  // TODO: for now only binary predictors write an MM object.
  // For the others cons one up here to return the predictions frame.
  if (null == mm)
    mm = new ModelMetricsListSchemaV3();

  if (null == mm.model_metrics || 0 == mm.model_metrics.length) {
    Log.warn("Score() did not return a ModelMetrics for model: " + s.model + " on frame: " + s.frame);
  }

  return mm;
}
 
開發者ID:kyoren,項目名稱:https-github.com-h2oai-h2o-3,代碼行數:30,代碼來源:ModelMetricsHandler.java

示例7: setVisibility

import water.exceptions.H2OIllegalArgumentException; //導入依賴的package包/類
@SuppressWarnings("unused") // called through reflection by RequestServer
public ModelBuildersVisibilityV3 setVisibility(int version, ModelBuildersVisibilityV3 m) {
  if (m.value.equals("Stable")) {
    H2O.ARGS.model_builders_visibility = ModelBuilder.BuilderVisibility.Stable;
  }
  else if (m.value.equals("Beta")) {
    H2O.ARGS.model_builders_visibility = ModelBuilder.BuilderVisibility.Beta;
  }
  else if (m.value.equals("Experimental")) {
    H2O.ARGS.model_builders_visibility = ModelBuilder.BuilderVisibility.Experimental;
  }
  else {
    throw new H2OIllegalArgumentException("value", "setVisibility", "Level must be one of (Stable, Beta, Experimental)");
  }

  return getVisibility(version, m);
}
 
開發者ID:kyoren,項目名稱:https-github.com-h2oai-h2o-3,代碼行數:18,代碼來源:ModelBuildersHandler.java

示例8: KeyV3

import water.exceptions.H2OIllegalArgumentException; //導入依賴的package包/類
public KeyV3(Key key) {
  this();
  if (null != key) {
    Class clz = getKeyedClass();
    Value v = DKV.get(key);

    if (null != v) {
      // Type checking of value from DKV
      if (Job.class.isAssignableFrom(clz) && !v.isJob())
        throw new H2OIllegalArgumentException("For Key: " + key + " expected a value of type Job; found a: " + v.theFreezableClass(), "For Key: " + key + " expected a value of type Job; found a: " + v.theFreezableClass() + " (" + clz + ")");
      else if (Frame.class.isAssignableFrom(clz) && !v.isFrame() && !v.isVec())
      // NOTE: we currently allow Vecs to be fetched via the /Frames endpoint, so this constraint is relaxed accordingly.  Note this means that if the user gets hold of a (hidden) Vec key and passes it to some other endpoint they will get an ugly error instead of an H2OIllegalArgumentException.
        throw new H2OIllegalArgumentException("For Key: " + key + " expected a value of type Frame; found a: " + v.theFreezableClass(), "For Key: " + key + " expected a value of type Frame; found a: " + v.theFreezableClass() + " (" + clz + ")");
      else if (Model.class.isAssignableFrom(clz) && !v.isModel())
        throw new H2OIllegalArgumentException("For Key: " + key + " expected a value of type Model; found a: " + v.theFreezableClass(), "For Key: " + key + " expected a value of type Model; found a: " + v.theFreezableClass() + " (" + clz + ")");
      else if (Vec.class.isAssignableFrom(clz) && !v.isVec())
        throw new H2OIllegalArgumentException("For Key: " + key + " expected a value of type Vec; found a: " + v.theFreezableClass(), "For Key: " + key + " expected a value of type Vec; found a: " + v.theFreezableClass() + " (" + clz + ")");
    }

    this.fillFromImpl(key);
  }
}
 
開發者ID:kyoren,項目名稱:https-github.com-h2oai-h2o-3,代碼行數:23,代碼來源:KeyV3.java

示例9: export

import water.exceptions.H2OIllegalArgumentException; //導入依賴的package包/類
public static Job export(Frame fr, String path, String frameName, boolean overwrite, int nParts) {
  boolean forceSingle = nParts == 1;
  // Validate input
  if (forceSingle) {
    boolean fileExists = H2O.getPM().exists(path);
    if (overwrite && fileExists) {
      Log.warn("File " + path + " exists, but will be overwritten!");
    } else if (!overwrite && fileExists) {
      throw new H2OIllegalArgumentException(path, "exportFrame", "File " + path + " already exists!");
    }
  } else {
    if (! H2O.getPM().isEmptyDirectoryAllNodes(path)) {
      throw new H2OIllegalArgumentException(path, "exportFrame", "Cannot use path " + path +
              " to store part files! The target needs to be either an existing empty directory or not exist yet.");
    }
  }
  Job job =  new Job<>(fr._key, "water.fvec.Frame", "Export dataset");
  FrameUtils.ExportTaskDriver t = new FrameUtils.ExportTaskDriver(fr, path, frameName, overwrite, job, nParts);
  return job.start(t, fr.anyVec().nChunks());
}
 
開發者ID:h2oai,項目名稱:h2o-3,代碼行數:21,代碼來源:Frame.java

示例10: anyURIToKey

import water.exceptions.H2OIllegalArgumentException; //導入依賴的package包/類
/** Convert given URI into a specific H2O key representation.
 *
 * The representation depends on persistent backend, since it will
 * deduce file location from the key content.
 *
 * The method will look at scheme of URI and based on it, it will
 * ask a backend to provide a conversion to a key (i.e., URI with scheme
 * 'hdfs' will be forwared to HDFS backend).
 *
 * @param uri file location
 * @return a key encoding URI
 * @throws IOException in the case of uri conversion problem
 * @throws water.exceptions.H2OIllegalArgumentException in case of unsupported scheme
 */
public final Key anyURIToKey(URI uri) throws IOException {
  Key ikey = null;
  String scheme = uri.getScheme();
  if("s3".equals(scheme)) {
    ikey = I[Value.S3].uriToKey(uri);
  } else if ("hdfs".equals(scheme)) {
    ikey = I[Value.HDFS].uriToKey(uri);
  } else if ("s3".equals(scheme) || "s3n".equals(scheme) || "s3a".equals(scheme)) {
    ikey = I[Value.HDFS].uriToKey(uri);
  } else if ("file".equals(scheme) || scheme == null) {
    ikey = I[Value.NFS].uriToKey(uri);
  } else if (useHdfsAsFallback() && I[Value.HDFS].canHandle(uri.toString())) {
      ikey = I[Value.HDFS].uriToKey(uri);
  } else {
    throw new H2OIllegalArgumentException("Unsupported schema '" + scheme + "' for given uri " + uri);
  }
  return ikey;
}
 
開發者ID:h2oai,項目名稱:h2o-3,代碼行數:33,代碼來源:PersistManager.java

示例11: strToColumnTypes

import water.exceptions.H2OIllegalArgumentException; //導入依賴的package包/類
public static byte[] strToColumnTypes(String[] strs) {
  if (strs == null) return null;
  byte[] types = new byte[strs.length];
  for(int i=0; i< types.length;i++) {
    switch (strs[i].toLowerCase()) {
    case "unknown": types[i] = Vec.T_BAD;  break;
    case "uuid":    types[i] = Vec.T_UUID; break;
    case "string":  types[i] = Vec.T_STR;  break;
    case "float":
    case "real":
    case "double":
    case "int":
    case "numeric": types[i] = Vec.T_NUM;  break;
    case "categorical":
    case "factor":
    case "enum":    types[i] = Vec.T_CAT;  break;
    case "time":    types[i] = Vec.T_TIME; break;
    default:        types[i] = Vec.T_BAD;
      throw new H2OIllegalArgumentException("Provided column type "+ strs[i] + " is unknown.  Cannot proceed with parse due to invalid argument.");
    }
  }
  return types;
}
 
開發者ID:h2oai,項目名稱:h2o-3,代碼行數:24,代碼來源:ParseSetup.java

示例12: killm3

import water.exceptions.H2OIllegalArgumentException; //導入依賴的package包/類
public KillMinus3V3 killm3(int version, KillMinus3V3 u) {
    new MRTask((byte)(H2O.MIN_HI_PRIORITY - 1)) {
      @Override public void setupLocal() {
        try {
          String cmd = "/bin/kill -3 " + getProcessId();
          java.lang.Runtime.getRuntime().exec(cmd);
        } catch( java.io.IOException ioe ) {
          // Silently ignore if, e.g. /bin/kill does not exist on windows
        } catch (Exception xe) {
          xe.printStackTrace();
          throw new H2OIllegalArgumentException("");
        }
      }
    }.doAllNodes();
  return u;
}
 
開發者ID:h2oai,項目名稱:h2o-3,代碼行數:17,代碼來源:KillMinus3Handler.java

示例13: importModel

import water.exceptions.H2OIllegalArgumentException; //導入依賴的package包/類
public ModelsV3 importModel(int version, ModelImportV3 mimport) {
  ModelsV3 s = Schema.newInstance(ModelsV3.class);
  InputStream is = null;
  try {
    URI targetUri = FileUtils.getURI(mimport.dir);
    Persist p = H2O.getPM().getPersistForURI(targetUri);
    is = p.open(targetUri.toString());
    final AutoBuffer ab = new AutoBuffer(is);
    ab.sourceName = targetUri.toString();
    Model model = (Model)Keyed.readAll(ab);
    ab.close();
    s.models = new ModelSchemaV3[]{(ModelSchemaV3) SchemaServer.schema(version, model).fillFromImpl(model)};
  } catch (FSIOException e) {
    throw new H2OIllegalArgumentException("dir", "importModel", mimport.dir);
  } finally {
    FileUtils.close(is);
  }
  return s;
}
 
開發者ID:h2oai,項目名稱:h2o-3,代碼行數:20,代碼來源:ModelsHandler.java

示例14: exportModelDetails

import water.exceptions.H2OIllegalArgumentException; //導入依賴的package包/類
public ModelExportV3 exportModelDetails(int version, ModelExportV3 mexport){
  Model model = getFromDKV("model_id", mexport.model_id.key());
  try {
    URI targetUri = FileUtils.getURI(mexport.dir); // Really file, not dir
    Persist p = H2O.getPM().getPersistForURI(targetUri);
    //Make model schema before exporting
    ModelSchemaV3 modelSchema = (ModelSchemaV3)SchemaServer.schema(version, model).fillFromImpl(model);
    //Output model details to JSON
    OutputStream os = p.create(targetUri.toString(),mexport.force);
    os.write(modelSchema.writeJSON(new AutoBuffer()).buf());
    // Send back
    mexport.dir = "file".equals(targetUri.getScheme()) ? new File(targetUri).getCanonicalPath() : targetUri.toString();
  } catch (IOException e) {
    throw new H2OIllegalArgumentException("dir", "exportModelDetails", e);
  }
  return mexport;
}
 
開發者ID:h2oai,項目名稱:h2o-3,代碼行數:18,代碼來源:ModelsHandler.java

示例15: toCategoricalVec

import water.exceptions.H2OIllegalArgumentException; //導入依賴的package包/類
/**
 * Create a new {@link Vec} of categorical values from an existing {@link Vec}.
 *
 * This method accepts all {@link Vec} types as input. The original Vec is not mutated.
 *
 * If src is a categorical {@link Vec}, a copy is returned.
 *
 * If src is a numeric {@link Vec}, the values are converted to strings used as domain
 * values.
 *
 * For all other types, an exception is currently thrown. These need to be replaced
 * with appropriate conversions.
 *
 * Throws H2OIllegalArgumentException() if the resulting domain exceeds
 * Categorical.MAX_CATEGORICAL_COUNT.
 *
 *  @param src A {@link Vec} whose values will be used as the basis for a new categorical {@link Vec}
 *  @return the resulting categorical Vec
 */
public static Vec toCategoricalVec(Vec src) {
  switch (src.get_type()) {
    case Vec.T_CAT:
      return src.makeCopy(src.domain());
    case Vec.T_NUM:
      return numericToCategorical(src);
    case Vec.T_STR: // PUBDEV-2204
      return stringToCategorical(src);
    case Vec.T_TIME: // PUBDEV-2205
      throw new H2OIllegalArgumentException("Changing time/date columns to a categorical"
          + " column has not been implemented yet.");
    case Vec.T_UUID:
      throw new H2OIllegalArgumentException("Changing UUID columns to a categorical"
          + " column has not been implemented yet.");
    default:
      throw new H2OIllegalArgumentException("Unrecognized column type " + src.get_type_str()
          + " given to toCategoricalVec()");
  }
}
 
開發者ID:h2oai,項目名稱:h2o-3,代碼行數:39,代碼來源:VecUtils.java


注:本文中的water.exceptions.H2OIllegalArgumentException類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。