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 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.
-
Constructor Summary
Constructors Constructor Description PCA()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
attributeRangeTipText()
Returns the tip text for this property.protected void
check(weka.core.Instances data)
Hook method for checks.void
defineOptions()
Adds options to the internal list of options.protected String
doAnalyze(weka.core.Instances data)
Performs the actual analysis.protected adams.data.spreadsheet.SpreadSheet
extractLoadings(weka.core.Instances data, ArrayList<ArrayList<Double>> coeff)
Create a spreadsheet to output from the coefficients 2D arrayWekaAttributeRange
getAttributeRange()
Returns the attribute range parameter.adams.data.spreadsheet.SpreadSheet
getLoadings()
Returns the loadings.int
getMaxAttributeNames()
Returns the maximum number of attribute names.int
getMaxAttributes()
Returns the maximum attributes.adams.data.spreadsheet.SpreadSheet
getScores()
Returns the scores.boolean
getSkipNominal()
Returns whether to skip NOMINAL attributes from the PCA process by turning them into STRING attributes.double
getVariance()
Returns the variance.String
globalInfo()
Returns a string describing the object.String
maxAttributeNamesTipText()
Returns the tip text for this property.String
maxAttributesTipText()
Returns the tip text for this property.protected void
reset()
Resets the scheme.void
setAttributeRange(WekaAttributeRange value)
Sets the attribute range parameter.void
setMaxAttributeNames(int value)
Sets the maximum number of attribute names.void
setMaxAttributes(int value)
Sets the maximum attributes.void
setSkipNominal(boolean value)
Sets whether to skip NOMINAL attributes from the PCA process by turning them into STRING attributes.void
setVariance(double value)
Sets the variance.String
skipNominalTipText()
Returns the tip text for this property.String
varianceTipText()
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:
globalInfo
in interfaceadams.core.GlobalInfoSupporter
- Specified by:
globalInfo
in 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:
defineOptions
in interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classadams.core.option.AbstractOptionHandler
-
reset
protected void reset()
Resets the scheme.- Overrides:
reset
in 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:
check
in 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:
doAnalyze
in 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
-
-