/** * Convenience method for creating a new {@code DefaultTargetEstimatePair}. * * @param <TargetType> * The target (ground-truth) type. * @param <EstimateType> * The estimate (prediction) type. Usually the same as TargetType. * @return * A new, empty pair. */ public static <TargetType, EstimateType> DefaultTargetEstimatePair<TargetType, EstimateType> create() { return new DefaultTargetEstimatePair<TargetType, EstimateType>(); }
@Override public TargetEstimatePair<TargetType, EstimateType> createPair( final TargetType first, final EstimateType second) { return DefaultTargetEstimatePair.create(first, second); }
/** * Creates a new instance of {@code TargetEstimatePair} with the given * target and estimate values. * * @param target * Target (ground-truth) value. * @param estimate * Estimate (prediction) of the target value. */ public DefaultTargetEstimatePair( final TargetType target, final EstimateType estimate) { super(); this.setTarget(target); this.setEstimate(estimate); }
@Override public DefaultTargetEstimatePair<TargetType, EstimateType> clone() { @SuppressWarnings("unchecked") DefaultTargetEstimatePair<TargetType, EstimateType> clone = (DefaultTargetEstimatePair<TargetType, EstimateType>) super.clone(); clone.setTarget(ObjectUtil.cloneSmart(this.getTarget())); clone.setEstimate(ObjectUtil.cloneSmart(this.getEstimate())); return clone; }
@Override public DefaultTargetEstimatePair<TargetType, EstimateType> clone() { @SuppressWarnings("unchecked") DefaultTargetEstimatePair<TargetType, EstimateType> clone = (DefaultTargetEstimatePair<TargetType, EstimateType>) super.clone(); clone.setTarget(ObjectUtil.cloneSmart(this.getTarget())); clone.setEstimate(ObjectUtil.cloneSmart(this.getEstimate())); return clone; }
@Override public DefaultTargetEstimatePair<TargetType, EstimateType> clone() { @SuppressWarnings("unchecked") DefaultTargetEstimatePair<TargetType, EstimateType> clone = (DefaultTargetEstimatePair<TargetType, EstimateType>) super.clone(); clone.setTarget(ObjectUtil.cloneSmart(this.getTarget())); clone.setEstimate(ObjectUtil.cloneSmart(this.getEstimate())); return clone; }
/** * Convenience method for creating a new {@code DefaultTargetEstimatePair}. * * @param <TargetType> * The target (ground-truth) type. * @param <EstimateType> * The estimate (prediction) type. Usually the same as TargetType. * @return * A new, empty pair. */ public static <TargetType, EstimateType> DefaultTargetEstimatePair<TargetType, EstimateType> create() { return new DefaultTargetEstimatePair<TargetType, EstimateType>(); }
@Override public TargetEstimatePair<TargetType, EstimateType> createPair( final TargetType first, final EstimateType second) { return DefaultTargetEstimatePair.create(first, second); }
/** * Creates a new instance of {@code TargetEstimatePair} with the given * target and estimate values. * * @param target * Target (ground-truth) value. * @param estimate * Estimate (prediction) of the target value. */ public DefaultTargetEstimatePair( final TargetType target, final EstimateType estimate) { super(); this.setTarget(target); this.setEstimate(estimate); }
/** * Convenience method for creating a new {@code DefaultTargetEstimatePair}. * * @param <TargetType> * The target (ground-truth) type. * @param <EstimateType> * The estimate (prediction) type. Usually the same as TargetType. * @return * A new, empty pair. */ public static <TargetType, EstimateType> DefaultTargetEstimatePair<TargetType, EstimateType> create() { return new DefaultTargetEstimatePair<TargetType, EstimateType>(); }
@Override protected <CLASS> void add( List<TargetEstimatePair<CLASS, CLASS>> data, Set<CLASS> predicted, Set<CLASS> actual) { data.add(DefaultTargetEstimatePair.create( actual.size() == 0 ? null : new ArrayList<CLASS>(actual).get(0), predicted.size() == 0 ? null : new ArrayList<CLASS>(predicted).get(0) )); } },
/** * Creates a new instance of {@code TargetEstimatePair} with the given * target and estimate values. * * @param target * Target (ground-truth) value. * @param estimate * Estimate (prediction) of the target value. */ public DefaultTargetEstimatePair( final TargetType target, final EstimateType estimate) { super(); this.setTarget(target); this.setEstimate(estimate); }
/** * Convenience method for creating a new {@code DefaultTargetEstimatePair}. * * @param <TargetType> * The target (ground-truth) type. * @param <EstimateType> * The estimate (prediction) type. Usually the same as TargetType. * @param target * The target (ground-truth) value. * @param estimate * The estimate (prediction) value. * @return * A new target-estimate pair. */ public static <TargetType, EstimateType> DefaultTargetEstimatePair<TargetType, EstimateType> create( final TargetType target, final EstimateType estimate) { return new DefaultTargetEstimatePair<TargetType, EstimateType>( target, estimate); }
@Override protected <CLASS> void add( List<TargetEstimatePair<CLASS, CLASS>> data, Set<CLASS> predicted, Set<CLASS> actual) { data.add(DefaultTargetEstimatePair.create( actual.size() == 0 ? null : new ArrayList<CLASS>(actual).get(0), predicted.size() == 0 ? null : new ArrayList<CLASS>(predicted).get(0) )); } },
/** * Convenience method for creating a new {@code DefaultTargetEstimatePair}. * * @param <TargetType> * The target (ground-truth) type. * @param <EstimateType> * The estimate (prediction) type. Usually the same as TargetType. * @param target * The target (ground-truth) value. * @param estimate * The estimate (prediction) value. * @return * A new target-estimate pair. */ public static <TargetType, EstimateType> DefaultTargetEstimatePair<TargetType, EstimateType> create( final TargetType target, final EstimateType estimate) { return new DefaultTargetEstimatePair<TargetType, EstimateType>( target, estimate); }
@Override protected <CLASS> void add( List<TargetEstimatePair<CLASS, CLASS>> data, Set<CLASS> predicted, Set<CLASS> actual) { final HashSet<CLASS> allClasses = new HashSet<CLASS>(); allClasses.addAll(predicted); allClasses.addAll(actual); for (final CLASS clz : allClasses) { final CLASS target = actual.contains(clz) ? clz : null; final CLASS estimate = predicted.contains(clz) ? clz : null; data.add(DefaultTargetEstimatePair.create(target, estimate)); } } },
/** * Convenience method for creating a new {@code DefaultTargetEstimatePair}. * * @param <TargetType> * The target (ground-truth) type. * @param <EstimateType> * The estimate (prediction) type. Usually the same as TargetType. * @param target * The target (ground-truth) value. * @param estimate * The estimate (prediction) value. * @return * A new target-estimate pair. */ public static <TargetType, EstimateType> DefaultTargetEstimatePair<TargetType, EstimateType> create( final TargetType target, final EstimateType estimate) { return new DefaultTargetEstimatePair<TargetType, EstimateType>( target, estimate); }
@Override protected <CLASS> void add( List<TargetEstimatePair<CLASS, CLASS>> data, Set<CLASS> predicted, Set<CLASS> actual) { final HashSet<CLASS> allClasses = new HashSet<CLASS>(); allClasses.addAll(predicted); allClasses.addAll(actual); for (final CLASS clz : allClasses) { final CLASS target = actual.contains(clz) ? clz : null; final CLASS estimate = predicted.contains(clz) ? clz : null; data.add(DefaultTargetEstimatePair.create(target, estimate)); } } },
@SuppressWarnings("unchecked") @Override protected <CLASS> void add( List<TargetEstimatePair<CLASS, CLASS>> data, Set<CLASS> predicted, Set<CLASS> actual) { final LinkedHashSet<CLASS> op = (LinkedHashSet<CLASS>) predicted; final LinkedHashSet<CLASS> ap = (LinkedHashSet<CLASS>) actual; if (op.size() != ap.size()) throw new RuntimeException("Sets are not the same size!"); final Object[] opa = op.toArray(); final Object[] apa = ap.toArray(); for (int i = 0; i < opa.length; i++) data.add(new DefaultTargetEstimatePair<CLASS, CLASS>((CLASS) opa[i], (CLASS) apa[i])); } };
@SuppressWarnings("unchecked") @Override protected <CLASS> void add( List<TargetEstimatePair<CLASS, CLASS>> data, Set<CLASS> predicted, Set<CLASS> actual) { final LinkedHashSet<CLASS> op = (LinkedHashSet<CLASS>) predicted; final LinkedHashSet<CLASS> ap = (LinkedHashSet<CLASS>) actual; if (op.size() != ap.size()) throw new RuntimeException("Sets are not the same size!"); final Object[] opa = op.toArray(); final Object[] apa = ap.toArray(); for (int i = 0; i < opa.length; i++) data.add(new DefaultTargetEstimatePair<CLASS, CLASS>((CLASS) opa[i], (CLASS) apa[i])); } };