コード例 #1
0
  static Object evaluateRegressionInternal(
      FieldName name, Object value, ModelEvaluationContext context) {
    ModelEvaluator<?> evaluator = context.getModelEvaluator();

    if (Objects.equals(Evaluator.DEFAULT_TARGET, name)) {
      DataField dataField = evaluator.getDataField();

      if (value != null) {
        value = TypeUtil.cast(dataField.getDataType(), value);
      }
    } else {
      Target target = evaluator.getTarget(name);
      if (target != null) {

        if (value == null) {
          value = getDefaultValue(target);
        } // End if

        if (value != null) {
          value = processValue(target, (Double) value);
        }
      }

      DataField dataField = evaluator.getDataField(name);
      if (dataField == null) {
        throw new MissingFieldException(name);
      } // End if

      if (value != null) {
        value = TypeUtil.cast(dataField.getDataType(), value);
      }

      MiningField miningField = evaluator.getMiningField(name);

      context.declare(
          name, FieldValueUtil.createTargetValue(dataField, miningField, target, value));
    }

    return value;
  }
コード例 #2
0
  static Classification evaluateClassificationInternal(
      FieldName name, Classification value, ModelEvaluationContext context) {
    ModelEvaluator<?> evaluator = context.getModelEvaluator();

    if (Objects.equals(Evaluator.DEFAULT_TARGET, name)) {
      DataField dataField = evaluator.getDataField();

      if (value != null) {
        value.computeResult(dataField.getDataType());
      }
    } else {
      Target target = evaluator.getTarget(name);
      if (target != null) {

        if (value == null) {
          value = getPriorProbabilities(target);
        }
      }

      DataField dataField = evaluator.getDataField(name);
      if (dataField == null) {
        throw new MissingFieldException(name);
      } // End if

      if (value != null) {
        value.computeResult(dataField.getDataType());
      }

      MiningField miningField = evaluator.getMiningField(name);

      context.declare(
          name,
          FieldValueUtil.createTargetValue(
              dataField, miningField, target, value != null ? value.getResult() : null));
    }

    return value;
  }