Class AttributeWiseVarianceNormalization<V extends elki.data.NumberVector>

  • Type Parameters:
    V - vector type
    All Implemented Interfaces:
    Normalization<V>, elki.datasource.filter.ObjectFilter

    @Alias({"z","standard","standardize","standardization"})
    @Priority(200)
    public class AttributeWiseVarianceNormalization<V extends elki.data.NumberVector>
    extends AbstractVectorConversionFilter<V,​V>
    implements Normalization<V>
    Class to perform and undo a normalization on real vectors with respect to given mean and standard deviation in each dimension.

    We use the biased variance (MeanVariance.getPopulationStddev()), because this produces that with exactly standard deviation 1. While often the unbiased estimate (MeanVariance.getSampleStddev()) is more appropriate, it will not ensure this interesting property. For large data, the difference will be small anyway.

    Since:
    0.4.0
    Author:
    Erich Schubert
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private static elki.logging.Logging LOG
      Class logger.
      private double[] mean
      Stores the mean in each dimension.
      (package private) elki.math.MeanVariance[] mvs
      Temporary storage used during initialization.
      private double[] stddev
      Stores the standard deviation in each dimension.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected elki.data.type.SimpleTypeInformation<? super V> convertedType​(elki.data.type.SimpleTypeInformation<V> in)
      Get the output type from the input type after conversion.
      protected V filterSingleObject​(V featureVector)
      Normalize a single instance.
      protected elki.data.type.SimpleTypeInformation<? super V> getInputTypeRestriction()
      Get the input type restriction used for negotiating the data query.
      protected elki.logging.Logging getLogger()
      Class logger.
      private double normalize​(int d, double val)
      Normalize a single dimension.
      protected void prepareComplete()
      Complete the initialization phase.
      protected void prepareProcessInstance​(V featureVector)
      Process a single object during initialization.
      protected boolean prepareStart​(elki.data.type.SimpleTypeInformation<V> in)
      Return "true" when the normalization needs initialization (two-pass filtering!).
      private double restore​(int d, double val)
      Restore a single dimension.
      V restore​(V featureVector)
      Transforms a feature vector to the original attribute ranges.
      java.lang.String toString()  
      elki.math.linearalgebra.LinearEquationSystem transform​(elki.math.linearalgebra.LinearEquationSystem linearEquationSystem)
      Transforms a linear equation system describing linear dependencies derived on the normalized space into a linear equation system describing linear dependencies quantitatively adapted to the original space.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
      • Methods inherited from interface elki.datasource.filter.ObjectFilter

        filter
    • Field Detail

      • LOG

        private static final elki.logging.Logging LOG
        Class logger.
      • mean

        private double[] mean
        Stores the mean in each dimension.
      • stddev

        private double[] stddev
        Stores the standard deviation in each dimension.
      • mvs

        elki.math.MeanVariance[] mvs
        Temporary storage used during initialization.
    • Constructor Detail

      • AttributeWiseVarianceNormalization

        public AttributeWiseVarianceNormalization()
        Constructor.
      • AttributeWiseVarianceNormalization

        public AttributeWiseVarianceNormalization​(double[] mean,
                                                  double[] stddev)
        Constructor.
        Parameters:
        mean - Mean value
        stddev - Standard deviation
    • Method Detail

      • prepareStart

        protected boolean prepareStart​(elki.data.type.SimpleTypeInformation<V> in)
        Description copied from class: AbstractConversionFilter
        Return "true" when the normalization needs initialization (two-pass filtering!).
        Overrides:
        prepareStart in class AbstractConversionFilter<V extends elki.data.NumberVector,​V extends elki.data.NumberVector>
        Parameters:
        in - Input type information
        Returns:
        true or false
      • prepareProcessInstance

        protected void prepareProcessInstance​(V featureVector)
        Description copied from class: AbstractConversionFilter
        Process a single object during initialization.
        Overrides:
        prepareProcessInstance in class AbstractConversionFilter<V extends elki.data.NumberVector,​V extends elki.data.NumberVector>
        Parameters:
        featureVector - Object to process
      • filterSingleObject

        protected V filterSingleObject​(V featureVector)
        Description copied from class: AbstractConversionFilter
        Normalize a single instance. You can implement this as UnsupportedOperationException if you override both public "normalize" functions!
        Specified by:
        filterSingleObject in class AbstractConversionFilter<V extends elki.data.NumberVector,​V extends elki.data.NumberVector>
        Parameters:
        featureVector - Database object to normalize
        Returns:
        Normalized database object
      • restore

        public V restore​(V featureVector)
                  throws NonNumericFeaturesException
        Description copied from interface: Normalization
        Transforms a feature vector to the original attribute ranges.
        Specified by:
        restore in interface Normalization<V extends elki.data.NumberVector>
        Parameters:
        featureVector - a feature vector to be transformed into original space
        Returns:
        a feature vector transformed into original space corresponding to the given feature vector
        Throws:
        NonNumericFeaturesException - feature vector is not compatible with values initialized during normalization
      • normalize

        private double normalize​(int d,
                                 double val)
        Normalize a single dimension.
        Parameters:
        d - Dimension
        val - Value
        Returns:
        Normalized value
      • restore

        private double restore​(int d,
                               double val)
        Restore a single dimension.
        Parameters:
        d - Dimension
        val - Value
        Returns:
        Normalized value
      • transform

        public elki.math.linearalgebra.LinearEquationSystem transform​(elki.math.linearalgebra.LinearEquationSystem linearEquationSystem)
        Description copied from interface: Normalization
        Transforms a linear equation system describing linear dependencies derived on the normalized space into a linear equation system describing linear dependencies quantitatively adapted to the original space.
        Specified by:
        transform in interface Normalization<V extends elki.data.NumberVector>
        Parameters:
        linearEquationSystem - the linear equation system to be transformed
        Returns:
        a linear equation system describing linear dependencies derived on the normalized space transformed into a linear equation system describing linear dependencies quantitatively adapted to the original space
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class AbstractConversionFilter<V extends elki.data.NumberVector,​V extends elki.data.NumberVector>
      • convertedType

        protected elki.data.type.SimpleTypeInformation<? super V> convertedType​(elki.data.type.SimpleTypeInformation<V> in)
        Description copied from class: AbstractConversionFilter
        Get the output type from the input type after conversion.
        Specified by:
        convertedType in class AbstractConversionFilter<V extends elki.data.NumberVector,​V extends elki.data.NumberVector>
        Parameters:
        in - input type restriction
        Returns:
        output type restriction
      • getInputTypeRestriction

        protected elki.data.type.SimpleTypeInformation<? super V> getInputTypeRestriction()
        Description copied from class: AbstractConversionFilter
        Get the input type restriction used for negotiating the data query.
        Specified by:
        getInputTypeRestriction in class AbstractConversionFilter<V extends elki.data.NumberVector,​V extends elki.data.NumberVector>
        Returns:
        Type restriction