Class PCA

  • All Implemented Interfaces:
    adams.core.Destroyable, adams.core.GlobalInfoSupporter, adams.core.logging.LoggingLevelHandler, adams.core.logging.LoggingSupporter, adams.core.option.OptionHandler, adams.core.SizeOfHandler, Serializable

    public class PCA
    extends AbstractInstancesAnalysis
    Performs principal components analysis and allows access to loadings and scores.
    Version:
    $Revision$
    Author:
    FracPete (fracpete at waikato dot ac dot nz)
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected WekaAttributeRange m_AttributeRange
      the range of attributes to work.
      protected ArrayList<Integer> m_Kept
      the indices of the kept attributes.
      protected adams.data.spreadsheet.SpreadSheet m_Loadings
      the loadings.
      protected int m_MaxAttributeNames
      the maximum number of attribute names.
      protected int m_MaxAttributes
      the maximum number of attributes.
      protected int m_NumAttributes
      the number of attributes in the data (excl class).
      protected adams.data.spreadsheet.SpreadSheet m_Scores
      the scores.
      protected boolean m_SkipNominal
      whether to skip nominal attributes (and not apply NominalToBinary).
      protected gnu.trove.list.TIntList m_Supported
      the supported attributes.
      protected gnu.trove.list.TIntList m_Unsupported
      the unsupported attributes.
      protected double m_Variance
      the variance to cover.
      • Fields inherited from class adams.core.option.AbstractOptionHandler

        m_OptionManager
      • Fields inherited from class adams.core.logging.LoggingObject

        m_Logger, m_LoggingIsEnabled, m_LoggingLevel
    • Constructor Summary

      Constructors 
      Constructor Description
      PCA()  
    • Field Detail

      • m_AttributeRange

        protected WekaAttributeRange m_AttributeRange
        the range of attributes to work.
      • m_Variance

        protected double m_Variance
        the variance to cover.
      • m_MaxAttributes

        protected int m_MaxAttributes
        the maximum number of attributes.
      • m_MaxAttributeNames

        protected int m_MaxAttributeNames
        the maximum number of attribute names.
      • m_SkipNominal

        protected boolean m_SkipNominal
        whether to skip nominal attributes (and not apply NominalToBinary).
      • m_Loadings

        protected adams.data.spreadsheet.SpreadSheet m_Loadings
        the loadings.
      • m_Scores

        protected adams.data.spreadsheet.SpreadSheet m_Scores
        the scores.
      • m_Supported

        protected gnu.trove.list.TIntList m_Supported
        the supported attributes.
      • m_Unsupported

        protected gnu.trove.list.TIntList m_Unsupported
        the unsupported attributes.
      • m_Kept

        protected ArrayList<Integer> m_Kept
        the indices of the kept attributes.
      • m_NumAttributes

        protected int m_NumAttributes
        the number of attributes in the data (excl class).
    • Constructor Detail

      • PCA

        public PCA()
    • Method Detail

      • globalInfo

        public String globalInfo()
        Returns a string describing the object.
        Specified by:
        globalInfo in interface adams.core.GlobalInfoSupporter
        Specified by:
        globalInfo in class adams.core.option.AbstractOptionHandler
        Returns:
        a description suitable for displaying in the gui
      • defineOptions

        public void defineOptions()
        Adds options to the internal list of options.
        Specified by:
        defineOptions in interface adams.core.option.OptionHandler
        Overrides:
        defineOptions in class adams.core.option.AbstractOptionHandler
      • reset

        protected void reset()
        Resets the scheme.
        Overrides:
        reset in class adams.core.option.AbstractOptionHandler
      • setAttributeRange

        public void setAttributeRange​(WekaAttributeRange value)
        Sets the attribute range parameter.
        Parameters:
        value - the range
      • getAttributeRange

        public WekaAttributeRange getAttributeRange()
        Returns the attribute range parameter.
        Returns:
        the range
      • attributeRangeTipText

        public String attributeRangeTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setVariance

        public void setVariance​(double value)
        Sets the variance.
        Parameters:
        value - the variance
      • getVariance

        public double getVariance()
        Returns the variance.
        Returns:
        the variance
      • varianceTipText

        public String varianceTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setMaxAttributes

        public void setMaxAttributes​(int value)
        Sets the maximum attributes.
        Parameters:
        value - the maximum
      • getMaxAttributes

        public int getMaxAttributes()
        Returns the maximum attributes.
        Returns:
        the maximum
      • maxAttributesTipText

        public String maxAttributesTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setMaxAttributeNames

        public void setMaxAttributeNames​(int value)
        Sets the maximum number of attribute names.
        Parameters:
        value - the maximum
      • getMaxAttributeNames

        public int getMaxAttributeNames()
        Returns the maximum number of attribute names.
        Returns:
        the maximum
      • maxAttributeNamesTipText

        public String maxAttributeNamesTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • setSkipNominal

        public void setSkipNominal​(boolean value)
        Sets whether to skip NOMINAL attributes from the PCA process by turning them into STRING attributes.
        Parameters:
        value - true if to skip
      • getSkipNominal

        public boolean getSkipNominal()
        Returns whether to skip NOMINAL attributes from the PCA process by turning them into STRING attributes.
        Returns:
        true if to skip
      • skipNominalTipText

        public String skipNominalTipText()
        Returns the tip text for this property.
        Returns:
        tip text for this property suitable for displaying in the GUI or for listing the options.
      • check

        protected void check​(weka.core.Instances data)
        Hook method for checks.
        Overrides:
        check in class adams.data.analysis.AbstractAnalysis<weka.core.Instances>
        Parameters:
        data - the data to check
      • extractLoadings

        protected adams.data.spreadsheet.SpreadSheet extractLoadings​(weka.core.Instances data,
                                                                     ArrayList<ArrayList<Double>> coeff)
        Create a spreadsheet to output from the coefficients 2D array
        Parameters:
        data - the underlying dataset
        coeff - The coefficients from the principal components analysis
        Returns:
        A spreadsheet containing the components
      • doAnalyze

        protected String doAnalyze​(weka.core.Instances data)
                            throws Exception
        Performs the actual analysis.
        Specified by:
        doAnalyze in class adams.data.analysis.AbstractAnalysis<weka.core.Instances>
        Parameters:
        data - the data to analyze
        Returns:
        null if successful, otherwise error message
        Throws:
        Exception - if analysis fails
      • getLoadings

        public adams.data.spreadsheet.SpreadSheet getLoadings()
        Returns the loadings.
        Returns:
        the loadings, null if not available
      • getScores

        public adams.data.spreadsheet.SpreadSheet getScores()
        Returns the scores.
        Returns:
        the scores, null if not available