hex.KeyValue.getKey()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(3.8k)|赞(0)|评价(0)|浏览(94)

本文整理了Java中hex.KeyValue.getKey()方法的一些代码示例,展示了KeyValue.getKey()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KeyValue.getKey()方法的具体详情如下:
包路径:hex.KeyValue
类名称:KeyValue
方法名:getKey

KeyValue.getKey介绍

暂无

代码示例

代码示例来源:origin: h2oai/h2o-3

public static void checkMonotoneConstraints(ModelBuilder<?, ?, ?> mb, Frame train, KeyValue[] constraints) {
 // we check that there are no duplicate definitions and constraints are defined only for numerical columns
 Set<String> constrained = new HashSet<>();
 for (KeyValue constraint : constraints) {
  if (constrained.contains(constraint.getKey())) {
   mb.error("_monotone_constraints", "Feature '" + constraint.getKey() + "' has multiple constraints.");
   continue;
  }
  constrained.add(constraint.getKey());
  Vec v = train.vec(constraint.getKey());
  if (v == null) {
   mb.error("_monotone_constraints", "Invalid constraint - there is no column '" + constraint.getKey() + "' in the training frame.");
  } else if (v.get_type() != Vec.T_NUM) {
   mb.error("_monotone_constraints", "Invalid constraint - column '" + constraint.getKey() +
       "' has type " + v.get_type_str() + ". Only numeric columns can have monotonic constraints.");
  }
 }
}

代码示例来源:origin: h2oai/h2o-3

Constraints constraints(Frame f) {
 if (_monotone_constraints == null || _monotone_constraints.length == 0) {
  return null;
 }
 Constraint[] cs = new Constraint[f.numCols()];
 for (KeyValue spec : _monotone_constraints) {
  if (spec.getValue() == 0)
   continue;
  int col = f.find(spec.getKey());
  if (col < 0) {
   throw new IllegalStateException("Invalid constraint specification, column '" + spec.getKey() + "' doesn't exist.");
  }
  int direction = spec.getValue() < 0 ? -1 : 1;
  cs[col] = new Constraint(direction);
 }
 return new Constraints(cs);
}

代码示例来源:origin: ai.h2o/h2o-ext-xgboost

Map<String, Integer> monotoneConstraints() {
 if (_monotone_constraints == null || _monotone_constraints.length == 0) {
  return Collections.emptyMap();
 }
 Map<String, Integer> constraints = new HashMap<>(_monotone_constraints.length);
 for (KeyValue constraint : _monotone_constraints) {
  final double val = constraint.getValue();
  if (val == 0) {
   continue;
  }
  if (constraints.containsKey(constraint.getKey())) {
   throw new IllegalStateException("Duplicate definition of constraint for feature '" + constraint.getKey() + "'.");
  }
  final int direction = val < 0 ? -1 : 1;
  constraints.put(constraint.getKey(), direction);
 }
 return constraints;
}

代码示例来源:origin: ai.h2o/h2o-algos

public static void checkMonotoneConstraints(ModelBuilder<?, ?, ?> mb, Frame train, KeyValue[] constraints) {
 // we check that there are no duplicate definitions and constraints are defined only for numerical columns
 Set<String> constrained = new HashSet<>();
 for (KeyValue constraint : constraints) {
  if (constrained.contains(constraint.getKey())) {
   mb.error("_monotone_constraints", "Feature '" + constraint.getKey() + "' has multiple constraints.");
   continue;
  }
  constrained.add(constraint.getKey());
  Vec v = train.vec(constraint.getKey());
  if (v == null) {
   mb.error("_monotone_constraints", "Invalid constraint - there is no column '" + constraint.getKey() + "' in the training frame.");
  } else if (v.get_type() != Vec.T_NUM) {
   mb.error("_monotone_constraints", "Invalid constraint - column '" + constraint.getKey() +
       "' has type " + v.get_type_str() + ". Only numeric columns can have monotonic constraints.");
  }
 }
}

代码示例来源:origin: ai.h2o/h2o-algos

Constraints constraints(Frame f) {
 if (_monotone_constraints == null || _monotone_constraints.length == 0) {
  return null;
 }
 Constraint[] cs = new Constraint[f.numCols()];
 for (KeyValue spec : _monotone_constraints) {
  if (spec.getValue() == 0)
   continue;
  int col = f.find(spec.getKey());
  if (col < 0) {
   throw new IllegalStateException("Invalid constraint specification, column '" + spec.getKey() + "' doesn't exist.");
  }
  int direction = spec.getValue() < 0 ? -1 : 1;
  cs[col] = new Constraint(direction);
 }
 return new Constraints(cs);
}

相关文章

微信公众号

最新文章

更多