@Test public void evaluateClassificationDefault(){ TargetValue yesValue = new TargetValue() .setValue("yes") .setPriorProbability(1d / 7d); TargetValue noValue = new TargetValue() .setValue("no") .setPriorProbability(1d - NumberUtil.asDouble(yesValue.getPriorProbability())); Target target = new Target() .setField(null) .addTargetValues(yesValue, noValue); ModelEvaluator<?> evaluator = createTreeModelEvaluator(MiningFunction.CLASSIFICATION, MathContext.FLOAT, target); DataField dataField = evaluator.getDataField(target.getField()); assertEquals(OpType.CATEGORICAL, dataField.getOpType()); assertEquals(DataType.STRING, dataField.getDataType()); Map<FieldName, ?> results = evaluator.evaluate(Collections.emptyMap()); HasProbability hasProbability = (HasProbability)results.get(dataField.getName()); assertEquals((Double)((double)(float)(1d / 7d)), hasProbability.getProbability("yes")); assertEquals((Double)((double)(float)(1d - (1d / 7d))), hasProbability.getProbability("no")); evaluator = createTreeModelEvaluator(MiningFunction.CLASSIFICATION, MathContext.DOUBLE, target); dataField = evaluator.getDataField(target.getField()); assertEquals(OpType.CATEGORICAL, dataField.getOpType()); assertEquals(DataType.STRING, dataField.getDataType()); results = evaluator.evaluate(Collections.emptyMap()); hasProbability = (HasProbability)results.get(dataField.getName()); assertEquals(yesValue.getPriorProbability(), hasProbability.getProbability("yes")); assertEquals(noValue.getPriorProbability(), hasProbability.getProbability("no")); }
static public <V extends Number> Map<FieldName, ? extends Classification<?, V>> evaluateClassificationDefault(ValueFactory<V> valueFactory, TargetField targetField){ Target target = targetField.getTarget(); if(target != null && target.hasTargetValues()){ ProbabilityDistribution<V> result = getPriorProbabilities(valueFactory, target); if(result != null){ return evaluateClassification(targetField, result); } } return Collections.singletonMap(targetField.getFieldName(), null); }
TargetUtil { static public <V extends Number> Map<FieldName, ? extends Classification<?, V>> evaluateClassificationDefault(ValueFactory<V> valueFactory, TargetField targetField){ Target target = targetField.getTarget(); if(target != null && target.hasTargetValues()){ ProbabilityDistribution<V> result = getPriorProbabilities(valueFactory, target); if(result != null){ return evaluateClassification(targetField, result); } } return Collections.singletonMap(targetField.getFieldName(), null); } }
TargetUtil { static public <V extends Number> Map<FieldName, ? extends Classification<?, V>> evaluateClassificationDefault(ValueFactory<V> valueFactory, TargetField targetField){ Target target = targetField.getTarget(); if(target != null && target.hasTargetValues()){ ProbabilityDistribution<V> result = getPriorProbabilities(valueFactory, target); if(result != null){ return evaluateClassification(targetField, result); } } return Collections.singletonMap(targetField.getFieldName(), null); } private  TargetUtil(); }
TargetUtil { static public <V extends Number> Map<FieldName, ? extends Classification<?, V>> evaluateClassificationDefault(ValueFactory<V> valueFactory, TargetField targetField){ Target target = targetField.getTarget(); if(target != null && target.hasTargetValues()){ ProbabilityDistribution<V> result = getPriorProbabilities(valueFactory, target); if(result != null){ return evaluateClassification(targetField, result); } } return Collections.singletonMap(targetField.getFieldName(), null); } private  TargetUtil(); static void computeResult(DataType dataType, Regression<?> regression); static void computeResult(DataType dataType, Classification<?, ?> classification); static void computeResult(DataType dataType, Vote vote); static Map<FieldName, ?> evaluateRegressionDefault(ValueFactory<V> valueFactory, TargetField targetField); static Map<FieldName, ?> evaluateRegression(TargetField targetField, Value<V> value); static Map<FieldName, ? extends Regression<V>> evaluateRegression(TargetField targetField, Regression<V> regression); static Value<V> evaluateRegressionInternal(TargetField targetField, Value<V> value); static Map<FieldName, ? extends Vote> evaluateVote(TargetField targetField, Vote vote); static Map<FieldName, ? extends Classification<?, V>> evaluateClassificationDefault(ValueFactory<V> valueFactory, TargetField targetField); static Map<FieldName, ? extends Classification<?, V>> evaluateClassification(TargetField targetField, Classification<?, V> classification); static Value<V> processValue(Target target, Value<V> value); static TargetValue getTargetValue(Target target, Object value); }
TargetUtil { static public <V extends Number> Map<FieldName, ? extends Classification<?, V>> evaluateClassificationDefault(ValueFactory<V> valueFactory, TargetField targetField){ Target target = targetField.getTarget(); if(target != null && target.hasTargetValues()){ ProbabilityDistribution<V> result = getPriorProbabilities(valueFactory, target); if(result != null){ return evaluateClassification(targetField, result); } } return Collections.singletonMap(targetField.getFieldName(), null); } private  TargetUtil(); static void computeResult(DataType dataType, Regression<?> regression); static void computeResult(DataType dataType, Classification<?, ?> classification); static void computeResult(DataType dataType, Vote vote); static Map<FieldName, ?> evaluateRegressionDefault(ValueFactory<V> valueFactory, TargetField targetField); static Map<FieldName, ?> evaluateRegression(TargetField targetField, Value<V> value); static Map<FieldName, ? extends Regression<V>> evaluateRegression(TargetField targetField, Regression<V> regression); static Value<V> evaluateRegressionInternal(TargetField targetField, Value<V> value); static Map<FieldName, ? extends Vote> evaluateVote(TargetField targetField, Vote vote); static Map<FieldName, ? extends Classification<?, V>> evaluateClassificationDefault(ValueFactory<V> valueFactory, TargetField targetField); static Map<FieldName, ? extends Classification<?, V>> evaluateClassification(TargetField targetField, Classification<?, V> classification); static Value<V> processValue(Target target, Value<V> value); static TargetValue getTargetValue(Target target, Object value);  }