public class PrincipalComponents extends UnsupervisedAttributeEvaluator implements AttributeTransformer, OptionHandler
-C Center (rather than standardize) the data and compute PCA using the covariance (rather than the correlation) matrix.
-R Retain enough PC attributes to account for this proportion of variance in the original data. (default = 0.95)
-O Transform through the PC space and back to the original space.
-A Maximum number of attributes to include in transformed attribute names. (-1 = include all)
Constructor and Description |
---|
PrincipalComponents() |
Modifier and Type | Method and Description |
---|---|
void |
buildEvaluator(Instances data)
Initializes principal components and performs the analysis
|
java.lang.String |
centerDataTipText()
Returns the tip text for this property
|
Instance |
convertInstance(Instance instance)
Transform an instance in original (unormalized) format.
|
double |
evaluateAttribute(int att)
Evaluates the merit of a transformed attribute.
|
Capabilities |
getCapabilities()
Returns the capabilities of this evaluator.
|
boolean |
getCenterData()
Get whether to center (rather than standardize) the data.
|
double[][] |
getCorrelationMatrix()
Return the correlation/covariance matrix
|
double[] |
getEigenValues()
Return the eigenvalues corresponding to the eigenvectors
|
Instances |
getFilteredInputFormat()
Return the header of the training data after all filtering - i.e missing
values and nominal to binary.
|
int |
getMaximumAttributeNames()
Gets maximum number of attributes to include in transformed attribute
names.
|
java.lang.String[] |
getOptions()
Gets the current settings of PrincipalComponents
|
java.lang.String |
getRevision()
Returns the revision string.
|
boolean |
getTransformBackToOriginal()
Gets whether the data is to be transformed back to the original space.
|
double[][] |
getUnsortedEigenVectors()
Return the unsorted eigenvectors
|
double |
getVarianceCovered()
Gets the proportion of total variance to account for when retaining
principal components
|
java.lang.String |
globalInfo()
Returns a string describing this attribute transformer
|
void |
initializeAndComputeMatrix(Instances data)
Intializes the evaluator, filters the input data and computes the
correlation/covariance matrix.
|
java.util.Enumeration<Option> |
listOptions()
Returns an enumeration describing the available options.
|
static void |
main(java.lang.String[] argv)
Main method for testing this class
|
static java.lang.String |
matrixToString(double[][] matrix)
Return a matrix as a String
|
java.lang.String |
maximumAttributeNamesTipText()
Returns the tip text for this property
|
void |
setCenterData(boolean center)
Set whether to center (rather than standardize) the data.
|
void |
setMaximumAttributeNames(int m)
Sets maximum number of attributes to include in transformed attribute
names.
|
void |
setOptions(java.lang.String[] options)
Parses a given list of options.
|
void |
setTransformBackToOriginal(boolean b)
Sets whether the data should be transformed back to the original space
|
void |
setVarianceCovered(double vc)
Sets the amount of variance to account for when retaining principal
components
|
java.lang.String |
toString()
Returns a description of this attribute transformer
|
java.lang.String |
transformBackToOriginalTipText()
Returns the tip text for this property
|
Instances |
transformedData(Instances data)
Gets the transformed training data.
|
Instances |
transformedHeader()
Returns just the header for the transformed data (ie.
|
java.lang.String |
varianceCoveredTipText()
Returns the tip text for this property
|
clean, doNotCheckCapabilitiesTipText, forName, getDoNotCheckCapabilities, makeCopies, postExecution, postProcess, preExecution, run, runEvaluator, setDoNotCheckCapabilities
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
makeCopy
public java.lang.String globalInfo()
public java.util.Enumeration<Option> listOptions()
listOptions
in interface OptionHandler
listOptions
in class ASEvaluation
public void setOptions(java.lang.String[] options) throws java.lang.Exception
-C Center (rather than standardize) the data and compute PCA using the covariance (rather than the correlation) matrix.
-R Retain enough PC attributes to account for this proportion of variance in the original data. (default = 0.95)
-O Transform through the PC space and back to the original space.
-A Maximum number of attributes to include in transformed attribute names. (-1 = include all)
setOptions
in interface OptionHandler
setOptions
in class ASEvaluation
options
- the list of options as an array of stringsjava.lang.Exception
- if an option is not supportedpublic java.lang.String centerDataTipText()
public void setCenterData(boolean center)
center
- true if the data is to be centered rather than standardizedpublic boolean getCenterData()
public java.lang.String varianceCoveredTipText()
public void setVarianceCovered(double vc)
vc
- the proportion of total variance to account forpublic double getVarianceCovered()
public java.lang.String maximumAttributeNamesTipText()
public void setMaximumAttributeNames(int m)
m
- the maximum number of attributespublic int getMaximumAttributeNames()
public java.lang.String transformBackToOriginalTipText()
public void setTransformBackToOriginal(boolean b)
b
- true if the data should be transformed back to the original spacepublic boolean getTransformBackToOriginal()
public java.lang.String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class ASEvaluation
public Capabilities getCapabilities()
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class ASEvaluation
Capabilities
public void buildEvaluator(Instances data) throws java.lang.Exception
buildEvaluator
in class ASEvaluation
data
- the instances to analyse/transformjava.lang.Exception
- if analysis failspublic void initializeAndComputeMatrix(Instances data) throws java.lang.Exception
data
- the instances to analysejava.lang.Exception
- if a problem occurspublic Instances transformedHeader() throws java.lang.Exception
transformedHeader
in interface AttributeTransformer
java.lang.Exception
- if the header of the transformed data can't be
determined.public Instances getFilteredInputFormat()
public double[][] getCorrelationMatrix()
public double[][] getUnsortedEigenVectors()
public double[] getEigenValues()
public Instances transformedData(Instances data) throws java.lang.Exception
transformedData
in interface AttributeTransformer
java.lang.Exception
- if transformed data can't be returnedpublic double evaluateAttribute(int att) throws java.lang.Exception
evaluateAttribute
in interface AttributeEvaluator
att
- the attribute to be evaluatedjava.lang.Exception
- if attribute can't be evaluatedpublic java.lang.String toString()
toString
in class java.lang.Object
public static java.lang.String matrixToString(double[][] matrix)
matrix
- that is decribed as a stringpublic Instance convertInstance(Instance instance) throws java.lang.Exception
convertInstance
in interface AttributeTransformer
instance
- an instance in the original (unormalized) formatjava.lang.Exception
- if instance cant be transformedpublic java.lang.String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class ASEvaluation
public static void main(java.lang.String[] argv)
argv
- should contain the command line arguments to the
evaluator/transformer (see AttributeSelection)