be.ac.ulb.mlg.utils
Class DefaultRenormalizer

java.lang.Object
  extended by be.ac.ulb.mlg.utils.DefaultRenormalizer
All Implemented Interfaces:
Renormalizer
Direct Known Subclasses:
TaxonRenormalizer

public class DefaultRenormalizer
extends Object
implements Renormalizer

DefaultRenormalizer supports custom or columns summing renormalization with features (row to be ignorated) and can handle non-overlapping groups (division of input vectors into subsets where elements of each subset are normalized only with others from the same group)


Field Summary
static double SUM_NORMILIZER
          Sentinel value meaning that the renormalizer use the sum function on columns
 
Constructor Summary
DefaultRenormalizer()
          Construct a new DefaultRenormalizer without groups, without features and with sum normalization shuffles are disable
 
Method Summary
 void addFeature(int dataIndex)
           
 int countFeatures()
          Count the number of features
 int countGroups()
          Count the number of groups
 int groupOf(int row)
          Get the group of a row
 boolean hasNativeImplementation()
          Know if the current renormalizer owns a native implementation
 boolean isUsingCustomNormalizer()
          Know if the configuration of the DefaultRenormalizer uses custom renormalization values
 boolean isUsingFeatures()
          Know if the configuration of the DefaultRenormalizer use the feature renormalization
 boolean isUsingGroups()
          Know if the configuration of the DefaultRenormalizer use the group renormalization
 void noFeatures()
          Specifies to no longer use the features renormalization
 void noGroups()
          Specifies to no longer use the group renormalization but preserve renormalization values by group to rester them, use resetNormalizer()
 double[][] normalizeInput(double[][] input)
          Apply the normalization process on the given vector of data vectors
 double[][] normalizeOutput(double[][] input, double[][] output, Measure measure)
          Apply the normalization process on the given vector of data vectors and result measures
 boolean processInput()
          Know if the renormalizer can handle input (call normalizeInput has effect)
 boolean processOutput()
          Know if the renormalizer can handle output (call normalizeOutput has effect)
 void resetNormalizer()
          Reset the custom renormalizer to use the default method (sum by columns)
 void setGroup(int row, int group)
          Define the group for one input data vector
 void setGroup(int row, String groupName)
          Define the group for one input data vector
 void setGroups(int[] groups, int groupCount)
          Define the group of all input data vectors by their indexes
 void setGroupsNames(int rows, String[] names)
          Define groups and associate them a label.
 void setNormalizer(int column, double divider)
          Define a specific value to use instead of the sum by column
 void setNormalizer(int group, int column, double divider)
          Define a specific value to use instead of the sum by column for groups
 void setNormalizer(String groupName, int column, double divider)
          Define a specific value to use instead of the sum by column for groups
 boolean shufflePair()
          Know if the measurer use pre-shuffle
 void simulateRenormalization(double[] shuffledFirst, double[] shuffledSecond, int first, int second)
          Method called when pairwise renormalization is used in order to obtain a normalized version of the shuffled vector as if it was in the original input matrix
 void updateRenormalization(double[] vect, int row, boolean ignore)
          Method called when pairwise renormalization is used in order to ignore or not a row from the original input matrix
 void usePairShuffle(boolean shuffle)
          Enable or disable pairwise shuffle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUM_NORMILIZER

public static final double SUM_NORMILIZER
Sentinel value meaning that the renormalizer use the sum function on columns

See Also:
Constant Field Values
Constructor Detail

DefaultRenormalizer

public DefaultRenormalizer()
Construct a new DefaultRenormalizer without groups, without features and with sum normalization shuffles are disable

Method Detail

addFeature

public void addFeature(int dataIndex)

isUsingGroups

public boolean isUsingGroups()
Know if the configuration of the DefaultRenormalizer use the group renormalization

Returns:
true if the DefaultRenormalizer use the group renormalization

noGroups

public void noGroups()
Specifies to no longer use the group renormalization but preserve renormalization values by group to rester them, use resetNormalizer()


resetNormalizer

public void resetNormalizer()
Reset the custom renormalizer to use the default method (sum by columns)


isUsingFeatures

public boolean isUsingFeatures()
Know if the configuration of the DefaultRenormalizer use the feature renormalization

Returns:
true if the DefaultRenormalizer use the feature renormalization

isUsingCustomNormalizer

public boolean isUsingCustomNormalizer()
Know if the configuration of the DefaultRenormalizer uses custom renormalization values

Returns:
true if the DefaultRenormalizer uses custom renormalization values

noFeatures

public void noFeatures()
Specifies to no longer use the features renormalization


setGroup

public void setGroup(int row,
                     String groupName)
Define the group for one input data vector

Parameters:
row - The index of the input data vector (used with Measurer)
groupName - The name of the group of the input data vector

setGroup

public void setGroup(int row,
                     int group)
Define the group for one input data vector

Parameters:
row - The index of the input data vector (used with Measurer)
group - The index of the group of the input data vector

setGroupsNames

public void setGroupsNames(int rows,
                           String[] names)
Define groups and associate them a label.

Parameters:
rows - The number of input data vectors to be processed
names - The name of all existing groups

setGroups

public void setGroups(int[] groups,
                      int groupCount)
Define the group of all input data vectors by their indexes

Parameters:
groups - The array mapping each for index i, the input data vector i to the group groups[i]
groupCount - The number of groups

setNormalizer

public void setNormalizer(String groupName,
                          int column,
                          double divider)
Define a specific value to use instead of the sum by column for groups

Parameters:
groupName - The name of the group
column - The column index (for an input data vector v, it's i of v[i])
divider - The specific value to use as normalizer

setNormalizer

public void setNormalizer(int group,
                          int column,
                          double divider)
Define a specific value to use instead of the sum by column for groups

Parameters:
group - The index of the group
column - The column index (for an input data vector v, it's i of v[i])
divider - The specific value to use as normalizer

setNormalizer

public void setNormalizer(int column,
                          double divider)
Define a specific value to use instead of the sum by column

Parameters:
column - The column index (for an input data vector v, it's i of v[i])
divider - The specific value to use as normalizer

countFeatures

public int countFeatures()
Count the number of features

Returns:
The number of features

countGroups

public int countGroups()
Count the number of groups

Returns:
The number of groups

groupOf

public int groupOf(int row)
Get the group of a row

Parameters:
row - The row index
Returns:
The group identifier

normalizeInput

public double[][] normalizeInput(double[][] input)
Description copied from interface: Renormalizer
Apply the normalization process on the given vector of data vectors

Specified by:
normalizeInput in interface Renormalizer
Parameters:
input - The given vector of data vectors
Returns:
the input array

updateRenormalization

public void updateRenormalization(double[] vect,
                                  int row,
                                  boolean ignore)
Description copied from interface: Renormalizer
Method called when pairwise renormalization is used in order to ignore or not a row from the original input matrix

Specified by:
updateRenormalization in interface Renormalizer
Parameters:
vect - A vector which is considerate as a row from the original input matrix corresponding to the row at the given index
row - The index of the vector to map it into the original matrix at this index
ignore - A boolean to tell if the values of the vector must be ignored (typically remove these values from the normalization process as if it was the row "index" from the original input matrix) with the true value (typically false to add it into renormalization)

simulateRenormalization

public void simulateRenormalization(double[] shuffledFirst,
                                    double[] shuffledSecond,
                                    int first,
                                    int second)
Description copied from interface: Renormalizer
Method called when pairwise renormalization is used in order to obtain a normalized version of the shuffled vector as if it was in the original input matrix

Specified by:
simulateRenormalization in interface Renormalizer
Parameters:
shuffledFirst - The first vector of the pairwise comparison (shuffled version)
shuffledSecond - The second vector of the pairwise comparison (shuffled version)
first - The index of the first vector from the original input matrix
second - The index of the second vector from the original input matrix

normalizeOutput

public double[][] normalizeOutput(double[][] input,
                                  double[][] output,
                                  Measure measure)
Description copied from interface: Renormalizer
Apply the normalization process on the given vector of data vectors and result measures

Specified by:
normalizeOutput in interface Renormalizer
Parameters:
input - The given vector of data vectors
output - The result vector (measures of data vectors)
measure - The corresponding measure
Returns:
the output array

hasNativeImplementation

public boolean hasNativeImplementation()
Description copied from interface: Renormalizer
Know if the current renormalizer owns a native implementation

Specified by:
hasNativeImplementation in interface Renormalizer
Returns:
true if the native implementation exists

processInput

public boolean processInput()
Description copied from interface: Renormalizer
Know if the renormalizer can handle input (call normalizeInput has effect)

Specified by:
processInput in interface Renormalizer
Returns:
true if it can handle

processOutput

public boolean processOutput()
Description copied from interface: Renormalizer
Know if the renormalizer can handle output (call normalizeOutput has effect)

Specified by:
processOutput in interface Renormalizer
Returns:
true if it can handle

usePairShuffle

public void usePairShuffle(boolean shuffle)
Enable or disable pairwise shuffle

Parameters:
shuffle - true to enable, false to disable

shufflePair

public boolean shufflePair()
Description copied from interface: Renormalizer
Know if the measurer use pre-shuffle

Specified by:
shufflePair in interface Renormalizer
Returns:
true if pair will be shuffled, false otherwise