![JAR search and dependency download from the Maven repository](/logo.png)
gov.sandia.cognition.learning.algorithm.clustering.divergence.WithinClusterDivergenceWrapper 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: WithinClusterDivergenceWrapper.java
* Authors: Andrew Fisher
* Company: Sandia National Laboratories
* Project: Cognitive Foundry
*
* Copyright July 12, 2016, 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.learning.algorithm.clustering.cluster.Cluster;
import gov.sandia.cognition.math.DivergenceFunction;
import gov.sandia.cognition.util.CloneableSerializable;
/**
* Accumulates the results of a {@link ClusterDivergenceFunction} by summing the
* divergence of each point to its cluster.
*
* @author Andrew N. Fisher <[email protected]>
* @param
* @param
*/
public class WithinClusterDivergenceWrapper, DataType extends Object>
implements WithinClusterDivergence
{
/** The divergence function. */
protected DivergenceFunction super ClusterType, ? super DataType> divergenceFunction;
/**
* Creates a new {@link WithinClusterDivergenceWrapper}.
*
* @param divergenceFunction
* The divergence function to use.
*/
public WithinClusterDivergenceWrapper(
DivergenceFunction super ClusterType, ? super DataType> divergenceFunction)
{
this.divergenceFunction = divergenceFunction;
}
@Override
public double evaluate(ClusterType cluster)
{
double total = 0.0;
for (DataType member : cluster.getMembers())
{
total += this.divergenceFunction.evaluate(cluster, member);
}
return total;
}
@Override
public CloneableSerializable clone()
{
return new WithinClusterDivergenceWrapper<>(this.divergenceFunction);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy