NormalizationUtil { static public FieldValue normalize(NormContinuous normContinuous, FieldValue value){ Number result = normalize(normContinuous, value.asNumber()); return FieldValueUtil.create(TypeInfos.CONTINUOUS_DOUBLE, result); } private  NormalizationUtil(); static FieldValue normalize(NormContinuous normContinuous, FieldValue value); static Number normalize(NormContinuous normContinuous, Number value); static Value<V> normalize(NormContinuous normContinuous, Value<V> value); static Number denormalize(NormContinuous normContinuous, Number value); static Value<V> denormalize(NormContinuous normContinuous, Value<V> value);  }
@Test public void normalize(){ NormContinuous normContinuous = createNormContinuous(); assertEquals(BEGIN[1], (double)NormalizationUtil.normalize(normContinuous, BEGIN[0]), 1e-8); assertEquals(interpolate(1.212d, BEGIN, MIDPOINT), (double)NormalizationUtil.normalize(normContinuous, 1.212d), 1e-8); assertEquals(MIDPOINT[1], (double)NormalizationUtil.normalize(normContinuous, MIDPOINT[0]), 1e-8); assertEquals(interpolate(6.5d, MIDPOINT, END), (double)NormalizationUtil.normalize(normContinuous, 6.5d), 1e-8); assertEquals(END[1], (double)NormalizationUtil.normalize(normContinuous, END[0]), 1e-8); }
@Test public void normalizeOutliers(){ NormContinuous normContinuous = createNormContinuous(); assertEquals(interpolate(-1d, BEGIN, MIDPOINT), (double)NormalizationUtil.normalize(normContinuous, -1d), 1e-8); assertEquals(interpolate(12.2d, MIDPOINT, END), (double)NormalizationUtil.normalize(normContinuous, 12.2d), 1e-8); normContinuous.setOutliers(OutlierTreatmentMethod.AS_MISSING_VALUES); assertNull(NormalizationUtil.normalize(normContinuous, -1d)); assertNull(NormalizationUtil.normalize(normContinuous, 12.2d)); normContinuous.setOutliers(OutlierTreatmentMethod.AS_EXTREME_VALUES); assertEquals(BEGIN[1], (double)NormalizationUtil.normalize(normContinuous, -1d), 1e-8); assertEquals(END[1], (double)NormalizationUtil.normalize(normContinuous, 12.2d), 1e-8); }