gov.sandia.cognition.learning.algorithm.clustering.divergence.CentroidClusterDivergenceFunction 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: CentroidClusterDivergenceFunction.java
* Authors: Justin Basilico and Kevin R. Dixon.
* Company: Sandia National Laboratories
* Project: Cognitive Foundry
*
* Copyright March 1, 2006, 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. See CopyrightHistory.txt for
* complete details.
*
*/
package gov.sandia.cognition.learning.algorithm.clustering.divergence;
import gov.sandia.cognition.annotation.CodeReview;
import gov.sandia.cognition.learning.algorithm.clustering.cluster.CentroidCluster;
import gov.sandia.cognition.learning.function.distance.DefaultDivergenceFunctionContainer;
import gov.sandia.cognition.math.DivergenceFunction;
/**
* The CentroidClusterDivergenceFunction class implements a divergence function
* between a cluster and an object by computing the divergence between the
* center of the cluster and the object.
*
* @param The algorithm operates on a {@code Collection},
* so {@code DataType} will be something like Vector or String
* @author Justin Basilico
* @author Kevin R. Dixon
* @since 1.0
*/
@CodeReview(
reviewer="Kevin R. Dixon",
date="2008-07-23",
changesNeeded=false,
comments="Interface looks fine."
)
public class CentroidClusterDivergenceFunction
extends DefaultDivergenceFunctionContainer
implements ClusterDivergenceFunction, DataType>
{
/**
* Creates a new instance of CentroidClusterDivergenceFunction.
*
* @param divergenceFunction
* The divergenceFunction to use to compute distances.
*/
public CentroidClusterDivergenceFunction(
final DivergenceFunction super DataType, ? super DataType>
divergenceFunction )
{
super( divergenceFunction );
}
@Override
public CentroidClusterDivergenceFunction clone()
{
@SuppressWarnings("unchecked")
CentroidClusterDivergenceFunction clone =
(CentroidClusterDivergenceFunction) super.clone();
return clone;
}
/**
* Evaluates the divergence between the cluster centroid and the given
* object.
*
* @param cluster The cluster to compute distance from.
* @param other The object to compute the distance to.
* @return The divergence between the center of the cluster and the given
* object.
*/
public double evaluate(
final CentroidCluster cluster,
final DataType other)
{
return this.divergenceFunction.evaluate(other, cluster.getCentroid());
}
}