static public boolean equals(DataType dataType, Object value, String referenceValue){ try { return (parseOrCast(dataType, value)).equals(parse(dataType, referenceValue)); } catch(IllegalArgumentException | TypeCheckException e){ // The String representation of invalid or missing values (eg. "N/A") may not be parseable to the requested representation try { return (parseOrCast(DataType.STRING, value)).equals(referenceValue); } catch(TypeCheckException tce){ // Ignored } throw e; } }
@Override public boolean doEquivalent(Object expected, Object actual){ if(actual instanceof Computable){ actual = EvaluatorUtil.decode(actual); } // End if if(actual instanceof Number){ actual = TypeUtil.parseOrCast(DataType.FLOAT, actual); expected = TypeUtil.parseOrCast(DataType.FLOAT, expected); } return super.doEquivalent(expected, actual); } }
@Override public boolean doEquivalent(Object expected, Object actual){ if(actual instanceof Computable){ actual = EvaluatorUtil.decode(actual); } // End if if(actual instanceof Number){ actual = TypeUtil.parseOrCast(DataType.FLOAT, actual); expected = TypeUtil.parseOrCast(DataType.FLOAT, expected); } return super.doEquivalent(expected, actual); } }
private boolean equalsValue(Object value){ value = TypeUtil.parseOrCast(getDataType(), value); return (getValue()).equals(value); }
private int compareToValue(Object value){ value = TypeUtil.parseOrCast(getDataType(), value); return ((Comparable)getValue()).compareTo(value); }
static private Double evaluate(Collection<?> values, int percentile){ DoubleVector doubleValues = new ComplexDoubleVector(values.size()); for(Object value : values){ Number number = (Number)TypeUtil.parseOrCast(DataType.DOUBLE, value); doubleValues.add(number.doubleValue()); } return doubleValues.doublePercentile(percentile); } }
static private Double evaluate(Collection<?> values, int percentile){ DoubleVector doubleValues = new ComplexDoubleVector(values.size()); for(Object value : values){ Number number = (Number)TypeUtil.parseOrCast(DataType.DOUBLE, value); doubleValues.add(number.doubleValue()); } return doubleValues.doublePercentile(percentile); } }
static private Double evaluate(Collection<?> values, int percentile){ DoubleVector doubleValues = new DoubleVector(values.size()); for(Object value : values){ Double doubleValue = (Double)TypeUtil.parseOrCast(DataType.DOUBLE, value); doubleValues.add(doubleValue.doubleValue()); } return doubleValues.percentile(percentile); } }
static private Double evaluate(Collection<?> values){ Mean statistic = new Mean(); for(Object value : values){ Number number = (Number)TypeUtil.parseOrCast(DataType.DOUBLE, value); statistic.increment(number.doubleValue()); } return statistic.getResult(); } }
static private Double evaluate(Collection<?> values){ Mean statistic = new Mean(); for(Object value : values){ Number number = (Number)TypeUtil.parseOrCast(DataType.DOUBLE, value); statistic.increment(number.doubleValue()); } return statistic.getResult(); } }
static private Double evaluate(Collection<?> values){ Mean statistic = new Mean(); for(Object value : values){ Double doubleValue = (Double)TypeUtil.parseOrCast(DataType.DOUBLE, value); statistic.increment(doubleValue.doubleValue()); } return statistic.getResult(); } }
@Override protected void computeResult(DataType dataType){ Node node = getNode(); Object result = TypeUtil.parseOrCast(dataType, node.getScore()); setResult(result); }
@Override protected void computeResult(DataType dataType){ Node node = getNode(); Object result = TypeUtil.parseOrCast(dataType, node.getScore()); setResult(result); }
static private Double evaluate(Collection<?> values, boolean biasCorrected){ StandardDeviation statistic = new StandardDeviation(); statistic.setBiasCorrected(biasCorrected); for(Object value : values){ Number number = (Number)TypeUtil.parseOrCast(DataType.DOUBLE, value); statistic.increment(number.doubleValue()); } return statistic.getResult(); } }
static private Double evaluate(Collection<?> values, boolean biasCorrected){ StandardDeviation statistic = new StandardDeviation(); statistic.setBiasCorrected(biasCorrected); for(Object value : values){ Number number = (Number)TypeUtil.parseOrCast(DataType.DOUBLE, value); statistic.increment(number.doubleValue()); } return statistic.getResult(); } }
static private Double evaluate(Collection<?> values, boolean biasCorrected){ StandardDeviation statistic = new StandardDeviation(); statistic.setBiasCorrected(biasCorrected); for(Object value : values){ Double doubleValue = (Double)TypeUtil.parseOrCast(DataType.DOUBLE, value); statistic.increment(doubleValue); } return statistic.getResult(); } }
@Override public boolean doEquivalent(Object expected, Object actual){ double precision = getPrecision(); double zeroThreshold = getZeroThreshold(); if(actual instanceof Computable){ actual = EvaluatorUtil.decode(actual); } expected = TypeUtil.parseOrCast(TypeUtil.getDataType(actual), expected); return VerificationUtil.acceptable(expected, actual, precision, zeroThreshold); }
private void verify(Object expected, Object actual, double precision, double zeroThreshold){ if(expected == null){ return; } // End if if(!(actual instanceof Collection)){ DataType dataType = TypeUtil.getDataType(actual); expected = TypeUtil.parseOrCast(dataType, expected); } boolean acceptable = VerificationUtil.acceptable(expected, actual, precision, zeroThreshold); if(!acceptable){ throw new EvaluationException("Values " + PMMLException.formatValue(expected) + " and " + PMMLException.formatValue(actual) + " do not match"); } }
@Override public boolean doEquivalent(Object expected, Object actual){ double precision = getPrecision(); double zeroThreshold = getZeroThreshold(); if(actual instanceof Computable){ actual = EvaluatorUtil.decode(actual); } expected = TypeUtil.parseOrCast(TypeUtil.getDataType(actual), expected); return VerificationUtil.acceptable(expected, actual, precision, zeroThreshold); }
@Override public int compareToValue(FieldValue value){ List<?> ordering = getOrdering(); if(ordering == null){ return super.compareToValue(value); } return compare(ordering, getValue(), TypeUtil.parseOrCast(getDataType(), value.getValue())); }