public class PLSFilter extends SimpleBatchFilter implements SupervisedFilter, TechnicalInformationHandler
@book{Naes2002, author = {Tormod Naes and Tomas Isaksson and Tom Fearn and Tony Davies}, publisher = {NIR Publications}, title = {A User Friendly Guide to Multivariate Calibration and Classification}, year = {2002}, ISBN = {0-9528666-2-5} } @misc{missing_id, author = {StatSoft, Inc.}, booktitle = {Electronic Textbook StatSoft}, title = {Partial Least Squares (PLS)}, HTTP = {http://www.statsoft.com/textbook/stpls.html} } @misc{missing_id, author = {Bent Jorgensen and Yuri Goegebeur}, booktitle = {ST02: Multivariate Data Analysis and Chemometrics}, title = {Module 7: Partial least squares regression I}, HTTP = {http://statmaster.sdu.dk/courses/ST02/module07/} } @article{Jong1993, author = {S. de Jong}, journal = {Chemometrics and Intelligent Laboratory Systems}, pages = {251-263}, title = {SIMPLS: an alternative approach to partial least squares regression}, volume = {18}, year = {1993} }Valid options are:
-D Turns on output of debugging information.
-C <num> The number of components to compute. (default: 20)
-U Updates the class attribute as well. (default: off)
-M Turns replacing of missing values on. (default: off)
-A <SIMPLS|PLS1> The algorithm to use. (default: PLS1)
-P <none|center|standardize> The type of preprocessing that is applied to the data. (default: center)
Modifier and Type | Field and Description |
---|---|
static int |
ALGORITHM_PLS1
the type of algorithm: PLS1
|
static int |
ALGORITHM_SIMPLS
the type of algorithm: SIMPLS
|
protected int |
m_Algorithm
the type of algorithm
|
protected double |
m_ClassMean
the mean of the class
|
protected double |
m_ClassStdDev
the standard deviation of the class
|
protected Filter |
m_Filter
for centering the data
|
protected Filter |
m_Missing
for replacing missing values
|
protected int |
m_NumComponents
the maximum number of components to generate
|
protected boolean |
m_PerformPrediction
whether to include the prediction, i.e., modifying the class attribute
|
protected Matrix |
m_PLS1_b_hat
the b-hat vector for PLS1
|
protected Matrix |
m_PLS1_P
the P matrix for PLS1
|
protected Matrix |
m_PLS1_RegVector
the regression vector "r-hat" for PLS1
|
protected Matrix |
m_PLS1_W
the W matrix for PLS1
|
protected int |
m_Preprocessing
the type of preprocessing
|
protected boolean |
m_ReplaceMissing
whether to replace missing values
|
protected Matrix |
m_SIMPLS_B
the B matrix for SIMPLS (used for prediction)
|
protected Matrix |
m_SIMPLS_W
the W matrix for SIMPLS
|
static int |
PREPROCESSING_CENTER
the type of preprocessing: Center
|
static int |
PREPROCESSING_NONE
the type of preprocessing: None
|
static int |
PREPROCESSING_STANDARDIZE
the type of preprocessing: Standardize
|
static Tag[] |
TAGS_ALGORITHM
the types of algorithm
|
static Tag[] |
TAGS_PREPROCESSING
the types of preprocessing
|
m_Debug
m_FirstBatchDone, m_InputRelAtts, m_InputStringAtts, m_NewBatch, m_OutputRelAtts, m_OutputStringAtts
Constructor and Description |
---|
PLSFilter()
default constructor
|
Modifier and Type | Method and Description |
---|---|
String |
algorithmTipText()
Returns the tip text for this property
|
protected Matrix |
columnAsVector(Matrix m,
int columnIndex)
returns the given column as a vector (actually a n x 1 matrix)
|
protected Instances |
determineOutputFormat(Instances inputFormat)
Determines the output format based on the input format and returns
this.
|
SelectedTag |
getAlgorithm()
Gets the type of algorithm to use
|
Capabilities |
getCapabilities()
Returns the Capabilities of this filter.
|
protected Matrix |
getDominantEigenVector(Matrix m)
determines the dominant eigenvector for the given matrix and returns it
|
int |
getNumComponents()
returns the maximum number of attributes to use.
|
String[] |
getOptions()
returns the options of the current setup
|
boolean |
getPerformPrediction()
Gets whether the class attribute is updated with the predicted value.
|
SelectedTag |
getPreprocessing()
Gets the type of preprocessing to use
|
boolean |
getReplaceMissing()
Gets whether missing values are replace.
|
String |
getRevision()
Returns the revision string.
|
TechnicalInformation |
getTechnicalInformation()
Returns an instance of a TechnicalInformation object, containing
detailed information about the technical background of this class,
e.g., paper reference or book this class is based on.
|
protected Matrix |
getVector(Matrix m,
int columnIndex)
returns the (column) vector of the matrix at the specified index
|
protected Matrix |
getX(Instance instance)
returns the data minus the class column as matrix
|
protected Matrix |
getX(Instances instances)
returns the data minus the class column as matrix
|
protected Matrix |
getY(Instance instance)
returns the data class column as matrix
|
protected Matrix |
getY(Instances instances)
returns the data class column as matrix
|
String |
globalInfo()
Returns a string describing this classifier.
|
Enumeration |
listOptions()
Gets an enumeration describing the available options.
|
static void |
main(String[] args)
runs the filter with the given arguments.
|
protected void |
normalizeVector(Matrix v)
normalizes the given vector (inplace)
|
String |
numComponentsTipText()
Returns the tip text for this property
|
String |
performPredictionTipText()
Returns the tip text for this property
|
String |
preprocessingTipText()
Returns the tip text for this property
|
protected Instances |
process(Instances instances)
Processes the given data (may change the provided dataset) and returns
the modified version.
|
protected Instances |
processPLS1(Instances instances)
processes the instances using the PLS1 algorithm
|
protected Instances |
processSIMPLS(Instances instances)
processes the instances using the SIMPLS algorithm
|
String |
replaceMissingTipText()
Returns the tip text for this property
|
void |
setAlgorithm(SelectedTag value)
Sets the type of algorithm to use
|
void |
setNumComponents(int value)
sets the maximum number of attributes to use.
|
void |
setOptions(String[] options)
Parses the options for this object.
|
void |
setPerformPrediction(boolean value)
Sets whether to update the class attribute with the predicted value.
|
void |
setPreprocessing(SelectedTag value)
Sets the type of preprocessing to use
|
void |
setReplaceMissing(boolean value)
Sets whether to replace missing values.
|
protected void |
setVector(Matrix v,
Matrix m,
int columnIndex)
stores the data from the (column) vector in the matrix at the specified
index
|
protected Instances |
toInstances(Instances header,
Matrix x,
Matrix y)
returns the X and Y matrix again as Instances object, based on the given
header (must have a class attribute set).
|
batchFinished, hasImmediateOutputFormat, input
debugTipText, getDebug, reset, setDebug, setInputFormat
batchFilterFile, bufferInput, copyValues, copyValues, filterFile, flushInput, getCapabilities, getInputFormat, getOutputFormat, initInputLocators, initOutputLocators, inputFormatPeek, isFirstBatchDone, isNewBatch, isOutputFormatDefined, makeCopies, makeCopy, numPendingOutput, output, outputFormatPeek, outputPeek, push, resetQueue, runFilter, setOutputFormat, testInputFormat, toString, useFilter, wekaStaticWrapper
public static final int ALGORITHM_SIMPLS
public static final int ALGORITHM_PLS1
public static final Tag[] TAGS_ALGORITHM
public static final int PREPROCESSING_NONE
public static final int PREPROCESSING_CENTER
public static final int PREPROCESSING_STANDARDIZE
public static final Tag[] TAGS_PREPROCESSING
protected int m_NumComponents
protected int m_Algorithm
protected Matrix m_PLS1_RegVector
protected Matrix m_PLS1_P
protected Matrix m_PLS1_W
protected Matrix m_PLS1_b_hat
protected Matrix m_SIMPLS_W
protected Matrix m_SIMPLS_B
protected boolean m_PerformPrediction
protected Filter m_Missing
protected boolean m_ReplaceMissing
protected Filter m_Filter
protected int m_Preprocessing
protected double m_ClassMean
protected double m_ClassStdDev
public String globalInfo()
globalInfo
in class SimpleFilter
public TechnicalInformation getTechnicalInformation()
getTechnicalInformation
in interface TechnicalInformationHandler
public Enumeration listOptions()
listOptions
in interface OptionHandler
listOptions
in class SimpleFilter
public String[] getOptions()
getOptions
in interface OptionHandler
getOptions
in class SimpleFilter
public void setOptions(String[] options) throws Exception
-D Turns on output of debugging information.
-C <num> The number of components to compute. (default: 20)
-U Updates the class attribute as well. (default: off)
-M Turns replacing of missing values on. (default: off)
-A <SIMPLS|PLS1> The algorithm to use. (default: PLS1)
-P <none|center|standardize> The type of preprocessing that is applied to the data. (default: center)
setOptions
in interface OptionHandler
setOptions
in class SimpleFilter
options
- the options to useException
- if the option setting failsSimpleFilter.reset()
public String numComponentsTipText()
public void setNumComponents(int value)
value
- the maximum number of attributespublic int getNumComponents()
public String performPredictionTipText()
public void setPerformPrediction(boolean value)
value
- if true the class value will be replaced by the
predicted value.public boolean getPerformPrediction()
public String algorithmTipText()
public void setAlgorithm(SelectedTag value)
value
- the algorithm typepublic SelectedTag getAlgorithm()
public String replaceMissingTipText()
public void setReplaceMissing(boolean value)
value
- if true missing values are replaced with the
ReplaceMissingValues filter.public boolean getReplaceMissing()
public String preprocessingTipText()
public void setPreprocessing(SelectedTag value)
value
- the preprocessing typepublic SelectedTag getPreprocessing()
protected Instances determineOutputFormat(Instances inputFormat) throws Exception
determineOutputFormat
in class SimpleFilter
inputFormat
- the input format to base the output format onException
- in case the determination goes wrongSimpleBatchFilter.hasImmediateOutputFormat()
,
SimpleBatchFilter.batchFinished()
protected Matrix getX(Instances instances)
instances
- the data to work onprotected Matrix getX(Instance instance)
instance
- the instance to work onprotected Matrix getY(Instances instances)
instances
- the data to work onprotected Matrix getY(Instance instance)
instance
- the instance to work onprotected Instances toInstances(Instances header, Matrix x, Matrix y)
header
- the format of the instance objectx
- the X matrix (data)y
- the Y matrix (class)protected Matrix columnAsVector(Matrix m, int columnIndex)
m
- the matrix to work oncolumnIndex
- the column to returnprotected void setVector(Matrix v, Matrix m, int columnIndex)
v
- the vector to store in the matrixm
- the receiving matrixcolumnIndex
- the column to store the values inprotected Matrix getVector(Matrix m, int columnIndex)
m
- the matrix to work oncolumnIndex
- the column to get the values fromprotected Matrix getDominantEigenVector(Matrix m)
m
- the matrix to determine the dominant eigenvector forprotected void normalizeVector(Matrix v)
v
- the vector to normalizeprotected Instances processPLS1(Instances instances) throws Exception
instances
- the data to processException
- in case the processing goes wrongprotected Instances processSIMPLS(Instances instances) throws Exception
instances
- the data to processException
- in case the processing goes wrongpublic Capabilities getCapabilities()
getCapabilities
in interface CapabilitiesHandler
getCapabilities
in class Filter
Capabilities
protected Instances process(Instances instances) throws Exception
process
in class SimpleFilter
instances
- the data to processException
- in case the processing goes wrongSimpleBatchFilter.batchFinished()
public String getRevision()
getRevision
in interface RevisionHandler
getRevision
in class Filter
public static void main(String[] args)
args
- the commandline argumentsCopyright © 2015 University of Waikato, Hamilton, NZ. All rights reserved.