gov.sandia.cognition.learning.data.DefaultWeightedTargetEstimatePair Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of cognitive-foundry Show documentation
Show all versions of cognitive-foundry Show documentation
A single jar with all the Cognitive Foundry components.
/*
* File: DefaultWeightedTargetEstimatePair.java
* Authors: Justin Basilico
* Company: Sandia National Laboratories
* Project: Cognitive Foundry Learning Core
*
* Copyright February 22, 2011, Sandia Corporation.
* Under the terms of Contract DE-AC04-94AL85000, there is a non-exclusive
* license for use of this work by or on behalf of the U.S. Government. Export
* of this program may require a license from the United States Government.
*/
package gov.sandia.cognition.learning.data;
/**
* Extends {@code TargetEstimatePair} with an additional weight field.
*
* @param
* The type of the target (ground truth).
* @param
* The type of the estimate. Typically this is the same as TargetType,
* but it does not have to be.
* @author Justin Basilico
* @since 3.0
*/
public class DefaultWeightedTargetEstimatePair
extends DefaultTargetEstimatePair
implements WeightedTargetEstimatePair
{
/** The default weight is {@value}. */
public static final double DEFAULT_WEIGHT = 1.0;
/** The weight. */
protected double weight;
/**
* Creates a new {@code WeightedTargetEstimatePair} with nulls for the
* target and estimate and 1.0 for the weight.
*/
public DefaultWeightedTargetEstimatePair()
{
this(null, null, DEFAULT_WEIGHT);
}
/**
* Creates a new {@code WeightedTargetEstimatePair} with the given target,
* estimate, and weight.
*
* @param target
* The target.
* @param estimate
* The estimate.
* @param weight
* The eight.
*/
public DefaultWeightedTargetEstimatePair(
final TargetType target,
final EstimateType estimate,
final double weight)
{
super(target, estimate);
this.setWeight(weight);
}
/**
* Creates a new {@code WeightedTargetEstimatePair} as a shallow copy of
* the given other object.
*
* @param other
* The other object to get the target, estimate, and weight from.
*/
public DefaultWeightedTargetEstimatePair(
final DefaultWeightedTargetEstimatePair extends TargetType, ? extends EstimateType> other)
{
this(other.getTarget(), other.getEstimate(), other.getWeight());
}
public double getWeight()
{
return this.weight;
}
/**
* Sets the weight.
*
* @param weight
* The weight for the pair.
*/
public void setWeight(
final double weight)
{
this.weight = weight;
}
/**
* Convenience method for creating a new {@code DefaultWeightedTargetEstimatePair}.
*
* @param
* The target (ground-truth) type.
* @param
* The estimate (prediction) type. Usually the same as TargetType.
* @return
* A new, empty pair with a default weight of 1.0.
*/
public static DefaultWeightedTargetEstimatePair create()
{
return create(null, null);
}
/**
* Convenience method for creating a new {@code DefaultWeightedTargetEstimatePair}.
*
* @param
* The target (ground-truth) type.
* @param
* 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 with a default weight of 1.0.
*/
public static DefaultWeightedTargetEstimatePair create(
final TargetType target,
final EstimateType estimate)
{
return create(target, estimate, DEFAULT_WEIGHT);
}
/**
* Convenience method for creating a new {@code DefaultWeightedTargetEstimatePair}.
*
* @param
* The target (ground-truth) type.
* @param
* The estimate (prediction) type. Usually the same as TargetType.
* @param target
* The target (ground-truth) value.
* @param estimate
* The estimate (prediction) value.
* @param weight
* The weight for the pair.
* @return
* A new target-estimate pair with the given weight.
*/
public static DefaultWeightedTargetEstimatePair create(
final TargetType target,
final EstimateType estimate,
final double weight)
{
return new DefaultWeightedTargetEstimatePair(
target, estimate, weight);
}
}