Package adams.data.instancesanalysis
Class PCA
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.data.analysis.AbstractAnalysis<weka.core.Instances>
-
- adams.data.instancesanalysis.AbstractInstancesAnalysis
-
- adams.data.instancesanalysis.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 WekaAttributeRangem_AttributeRangethe range of attributes to work.protected ArrayList<Integer>m_Keptthe indices of the kept attributes.protected adams.data.spreadsheet.SpreadSheetm_Loadingsthe loadings.protected intm_MaxAttributeNamesthe maximum number of attribute names.protected intm_MaxAttributesthe maximum number of attributes.protected intm_NumAttributesthe number of attributes in the data (excl class).protected adams.data.spreadsheet.SpreadSheetm_Scoresthe scores.protected booleanm_SkipNominalwhether to skip nominal attributes (and not apply NominalToBinary).protected gnu.trove.list.TIntListm_Supportedthe supported attributes.protected gnu.trove.list.TIntListm_Unsupportedthe unsupported attributes.protected doublem_Variancethe variance to cover.
-
Constructor Summary
Constructors Constructor Description PCA()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringattributeRangeTipText()Returns the tip text for this property.protected voidcheck(weka.core.Instances data)Hook method for checks.voiddefineOptions()Adds options to the internal list of options.protected StringdoAnalyze(weka.core.Instances data)Performs the actual analysis.protected adams.data.spreadsheet.SpreadSheetextractLoadings(weka.core.Instances data, ArrayList<ArrayList<Double>> coeff)Create a spreadsheet to output from the coefficients 2D arrayWekaAttributeRangegetAttributeRange()Returns the attribute range parameter.adams.data.spreadsheet.SpreadSheetgetLoadings()Returns the loadings.intgetMaxAttributeNames()Returns the maximum number of attribute names.intgetMaxAttributes()Returns the maximum attributes.adams.data.spreadsheet.SpreadSheetgetScores()Returns the scores.booleangetSkipNominal()Returns whether to skip NOMINAL attributes from the PCA process by turning them into STRING attributes.doublegetVariance()Returns the variance.StringglobalInfo()Returns a string describing the object.StringmaxAttributeNamesTipText()Returns the tip text for this property.StringmaxAttributesTipText()Returns the tip text for this property.protected voidreset()Resets the scheme.voidsetAttributeRange(WekaAttributeRange value)Sets the attribute range parameter.voidsetMaxAttributeNames(int value)Sets the maximum number of attribute names.voidsetMaxAttributes(int value)Sets the maximum attributes.voidsetSkipNominal(boolean value)Sets whether to skip NOMINAL attributes from the PCA process by turning them into STRING attributes.voidsetVariance(double value)Sets the variance.StringskipNominalTipText()Returns the tip text for this property.StringvarianceTipText()Returns the tip text for this property.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, initialize, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine, toString
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
-
-
-
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_NumAttributes
protected int m_NumAttributes
the number of attributes in the data (excl class).
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceadams.core.GlobalInfoSupporter- Specified by:
globalInfoin classadams.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:
defineOptionsin interfaceadams.core.option.OptionHandler- Overrides:
defineOptionsin classadams.core.option.AbstractOptionHandler
-
reset
protected void reset()
Resets the scheme.- Overrides:
resetin classadams.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:
checkin classadams.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 datasetcoeff- 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:
doAnalyzein classadams.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
-
-