@Test public void computeOrdinalProbabilities(){ ValueMap<String, Float> values = new ValueMap<>(); values.put("loud", new FloatValue(0.2f)); values.put("louder", new FloatValue(0.7f)); values.put("insane", new FloatValue(1f)); RegressionModelUtil.computeOrdinalProbabilities(RegressionModel.NormalizationMethod.NONE, values); assertEquals(new FloatValue(0.2f - 0f), values.get("loud")); assertEquals(new FloatValue(0.7f - 0.2f), values.get("louder")); assertEquals(new FloatValue(1f - 0.7f), values.get("insane")); }
static public <K, V extends Number> ValueMap<K, V> computeOrdinalProbabilities(RegressionModel.NormalizationMethod normalizationMethod, ValueMap<K, V> values){ if(values.size() < 2){ throw new IllegalArgumentException(); } switch(normalizationMethod){ case NONE: case LOGIT: case PROBIT: case CLOGLOG: case LOGLOG: case CAUCHIT: { Value<V> sum = null; Iterator<Value<V>> valueIt = values.iterator(); for(int i = 0, max = values.size() - 1; i < max; i++){ Value<V> value = valueIt.next(); normalizeBinaryLogisticClassificationResult(normalizationMethod, value); if(sum == null){ sum = value.copy(); } else { value.subtract(sum); sum.add(value); } } Value<V> lastValue = valueIt.next(); lastValue.residual(sum); } break; default: throw new IllegalArgumentException(); } return values; }
RegressionModelUtil { static public <K, V extends Number> ValueMap<K, V> computeOrdinalProbabilities(RegressionModel.NormalizationMethod normalizationMethod, ValueMap<K, V> values){ if(values.size() < 2){ throw new IllegalArgumentException(); } switch(normalizationMethod){ case NONE: case LOGIT: case PROBIT: case CLOGLOG: case LOGLOG: case CAUCHIT: { Value<V> sum = null; Iterator<Value<V>> valueIt = values.iterator(); for(int i = 0, max = values.size() - 1; i < max; i++){ Value<V> value = valueIt.next(); normalizeBinaryLogisticClassificationResult(normalizationMethod, value); if(sum == null){ sum = value.copy(); } else { value.subtract(sum); sum.add(value); } } Value<V> lastValue = valueIt.next(); lastValue.residual(sum); } break; default: throw new IllegalArgumentException(); } return values; } }
RegressionModelUtil { static public <K, V extends Number> ValueMap<K, V> computeOrdinalProbabilities(RegressionModel.NormalizationMethod normalizationMethod, ValueMap<K, V> values){ if(values.size() < 2){ throw new IllegalArgumentException(); } switch(normalizationMethod){ case NONE: case LOGIT: case PROBIT: case CLOGLOG: case LOGLOG: case CAUCHIT: { Value<V> sum = null; Iterator<Value<V>> valueIt = values.iterator(); for(int i = 0, max = values.size() - 1; i < max; i++){ Value<V> value = valueIt.next(); normalizeBinaryLogisticClassificationResult(normalizationMethod, value); if(sum == null){ sum = value.copy(); } else { value.subtract(sum); sum.add(value); } } Value<V> lastValue = valueIt.next(); lastValue.residual(sum); } break; default: throw new IllegalArgumentException(); } return values; } private  RegressionModelUtil(); }
RegressionModelUtil { static public <K, V extends Number> ValueMap<K, V> computeOrdinalProbabilities(RegressionModel.NormalizationMethod normalizationMethod, ValueMap<K, V> values){ if(values.size() < 2){ throw new IllegalArgumentException(); } switch(normalizationMethod){ case NONE: case LOGIT: case PROBIT: case CLOGLOG: case LOGLOG: case CAUCHIT: { Value<V> sum = null; Iterator<Value<V>> valueIt = values.iterator(); for(int i = 0, max = values.size() - 1; i < max; i++){ Value<V> value = valueIt.next(); normalizeBinaryLogisticClassificationResult(normalizationMethod, value); if(sum == null){ sum = value.copy(); } else { value.subtract(sum); sum.add(value); } } Value<V> lastValue = valueIt.next(); lastValue.residual(sum); } break; default: throw new IllegalArgumentException(); } return values; } private  RegressionModelUtil(); static ValueMap<K, V> computeBinomialProbabilities(RegressionModel.NormalizationMethod normalizationMethod, ValueMap<K, V> values); static ValueMap<K, V> computeMultinomialProbabilities(RegressionModel.NormalizationMethod normalizationMethod, ValueMap<K, V> values); static ValueMap<K, V> computeOrdinalProbabilities(RegressionModel.NormalizationMethod normalizationMethod, ValueMap<K, V> values); static Value<V> normalizeRegressionResult(RegressionModel.NormalizationMethod normalizationMethod, Value<V> value); static Value<V> normalizeBinaryLogisticClassificationResult(RegressionModel.NormalizationMethod normalizationMethod, Value<V> value); }
RegressionModelUtil { static public <K, V extends Number> ValueMap<K, V> computeOrdinalProbabilities(RegressionModel.NormalizationMethod normalizationMethod, ValueMap<K, V> values){ if(values.size() < 2){ throw new IllegalArgumentException(); } switch(normalizationMethod){ case NONE: case LOGIT: case PROBIT: case CLOGLOG: case LOGLOG: case CAUCHIT: { Value<V> sum = null; Iterator<Value<V>> valueIt = values.iterator(); for(int i = 0, max = values.size() - 1; i < max; i++){ Value<V> value = valueIt.next(); normalizeBinaryLogisticClassificationResult(normalizationMethod, value); if(sum == null){ sum = value.copy(); } else { value.subtract(sum); sum.add(value); } } Value<V> lastValue = valueIt.next(); lastValue.residual(sum); } break; default: throw new IllegalArgumentException(); } return values; } private  RegressionModelUtil(); static ValueMap<K, V> computeBinomialProbabilities(RegressionModel.NormalizationMethod normalizationMethod, ValueMap<K, V> values); static ValueMap<K, V> computeMultinomialProbabilities(RegressionModel.NormalizationMethod normalizationMethod, ValueMap<K, V> values); static ValueMap<K, V> computeOrdinalProbabilities(RegressionModel.NormalizationMethod normalizationMethod, ValueMap<K, V> values); static Value<V> normalizeRegressionResult(RegressionModel.NormalizationMethod normalizationMethod, Value<V> value); static Value<V> normalizeBinaryLogisticClassificationResult(RegressionModel.NormalizationMethod normalizationMethod, Value<V> value);  }