Environment for
DeveLoping
KDD-Applications
Supported by Index-Structures

de.lmu.ifi.dbs.elki.math.linearalgebra.pca
Class WeightedCovarianceMatrixBuilder<V extends RealVector<V,?>,D extends NumberDistance<D,?>>

java.lang.Object
  extended by de.lmu.ifi.dbs.elki.logging.AbstractLoggable
      extended by de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
          extended by de.lmu.ifi.dbs.elki.math.linearalgebra.pca.CovarianceMatrixBuilder<V,D>
              extended by de.lmu.ifi.dbs.elki.math.linearalgebra.pca.WeightedCovarianceMatrixBuilder<V,D>
Type Parameters:
V - Vector class to use
All Implemented Interfaces:
Parameterizable

public class WeightedCovarianceMatrixBuilder<V extends RealVector<V,?>,D extends NumberDistance<D,?>>
extends CovarianceMatrixBuilder<V,D>

CovarianceMatrixBuilder with weights. This builder uses a weight function to weight points differently during build a covariance matrix. Covariance can be canonically extended with weights, as shown in the article A General Framework for Increasing the Robustness of PCA-Based Correlation Clustering Algorithms Hans-Peter Kriegel and Peer Kröger and Erich Schubert and Arthur Zimek In: Proc. 20th Int. Conf. on Scientific and Statistical Database Management (SSDBM), 2008, Hong Kong Lecture Notes in Computer Science 5069, Springer

Author:
Erich Schubert

Field Summary
static OptionID WEIGHT_ID
          OptionID for WEIGHT_PARAM
private  ClassParameter<WeightFunction> WEIGHT_PARAM
          Parameter to specify the weight function to use in weighted PCA, must implement WeightFunction.
private  DistanceFunction<V,DoubleDistance> weightDistance
          Holds the distance function used for weight calculation
 WeightFunction weightfunction
          Holds the weight function.
 
Fields inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
optionHandler
 
Fields inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debug, logger
 
Constructor Summary
WeightedCovarianceMatrixBuilder()
          Constructor, setting up parameter.
 
Method Summary
private  double[][] finishCovarianceMatrix(double[] sums, double[][] squares, double weightsum)
          Finish the Covariance matrix in array "squares".
 Matrix processIds(Collection<Integer> ids, Database<V> database)
          Weighted Covariance Matrix for a set of IDs.
 Matrix processQueryResults(Collection<DistanceResultPair<D>> results, Database<V> database, int k)
          Compute Covariance Matrix for a QueryResult Collection By default it will just collect the ids and run processIds
 List<String> setParameters(List<String> args)
          Parse parameters.
 
Methods inherited from class de.lmu.ifi.dbs.elki.math.linearalgebra.pca.CovarianceMatrixBuilder
processDatabase, processQueryResults
 
Methods inherited from class de.lmu.ifi.dbs.elki.utilities.optionhandling.AbstractParameterizable
addOption, addParameterizable, addParameterizable, checkGlobalParameterConstraints, collectOptions, getAttributeSettings, getParameters, rememberParametersExcept, removeOption, removeParameterizable, shortDescription
 
Methods inherited from class de.lmu.ifi.dbs.elki.logging.AbstractLoggable
debugFine, debugFiner, debugFinest, exception, progress, verbose, warning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WEIGHT_ID

public static final OptionID WEIGHT_ID
OptionID for WEIGHT_PARAM


WEIGHT_PARAM

private final ClassParameter<WeightFunction> WEIGHT_PARAM
Parameter to specify the weight function to use in weighted PCA, must implement WeightFunction.

Key: -pca.weight


weightfunction

public WeightFunction weightfunction
Holds the weight function.


weightDistance

private DistanceFunction<V extends RealVector<V,?>,DoubleDistance> weightDistance
Holds the distance function used for weight calculation

Constructor Detail

WeightedCovarianceMatrixBuilder

public WeightedCovarianceMatrixBuilder()
Constructor, setting up parameter.

Method Detail

setParameters

public List<String> setParameters(List<String> args)
                           throws ParameterException
Parse parameters.

Specified by:
setParameters in interface Parameterizable
Overrides:
setParameters in class AbstractParameterizable
Parameters:
args - parameters to set the attributes accordingly to
Returns:
a list containing the unused parameters
Throws:
ParameterException - in case of wrong parameter-setting

processIds

public Matrix processIds(Collection<Integer> ids,
                         Database<V> database)
Weighted Covariance Matrix for a set of IDs. Since we are not supplied any distance information, we'll need to compute it ourselves. Covariance is tied to Euclidean distance, so it probably does not make much sense to add support for other distance functions?

Specified by:
processIds in class CovarianceMatrixBuilder<V extends RealVector<V,?>,D extends NumberDistance<D,?>>
Parameters:
ids - a collection of ids
database - the database used
Returns:
Covariance Matrix

processQueryResults

public Matrix processQueryResults(Collection<DistanceResultPair<D>> results,
                                  Database<V> database,
                                  int k)
Compute Covariance Matrix for a QueryResult Collection By default it will just collect the ids and run processIds

Overrides:
processQueryResults in class CovarianceMatrixBuilder<V extends RealVector<V,?>,D extends NumberDistance<D,?>>
Parameters:
results - a collection of QueryResults
database - the database used
k - number of elements to process
Returns:
Covariance Matrix

finishCovarianceMatrix

private double[][] finishCovarianceMatrix(double[] sums,
                                          double[][] squares,
                                          double weightsum)
Finish the Covariance matrix in array "squares".

Parameters:
sums - Sums of values.
squares - Sums of squares. Contents are destroyed and replaced with Covariance Matrix!
weightsum - Sum of weights.
Returns:
modified squares array

Release 0.2 (2009-07-06_1820)