Package weka.classifiers.functions
Class ClassificationViaPLS
- java.lang.Object
-
- weka.classifiers.AbstractClassifier
-
- weka.classifiers.functions.ClassificationViaPLS
-
- All Implemented Interfaces:
Serializable
,Cloneable
,weka.classifiers.Classifier
,weka.core.BatchPredictor
,weka.core.CapabilitiesHandler
,weka.core.CapabilitiesIgnorer
,weka.core.CommandlineRunnable
,weka.core.OptionHandler
,PLSMatrixAccess
,weka.core.RevisionHandler
public class ClassificationViaPLS extends weka.classifiers.AbstractClassifier implements PLSMatrixAccess
Performs ClassificationViaRegression using PLSClassifierWeightedWithLoadings as base classifier, allowing access to the PLS matrices.
Valid options are:
-filter <filter specification> The PLS filter to use. Full classname of filter to include, followed by scheme options. (default: weka.filters.supervised.attribute.PLSFilterWithLoadings)
-label-index <num> The label index (of the class attribute) to return the PLS matrices for. 'first' and 'last' are accepted as well. (default: first)
-label-string <label> The label string (of the class attribute) to return the PLS matrices for. Overrides the '-label-index' option if non-empty. (default: '')
-D If set, classifier is run in debug mode and may output additional info to the console
Options specific to filter weka.filters.supervised.attribute.PLSFilterWithLoadings ('-filter'):
-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)
- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected ClassificationViaRegressionD
m_CVR
theClassificationViaRegression
used internally.protected weka.core.Instances
m_Header
the header of the training set.protected weka.core.SingleIndex
m_LabelIndex
The label index to get the PLS matrices for.protected String
m_LabelString
the label string to get the PLS matrices for (overrides the label index).
-
Constructor Summary
Constructors Constructor Description ClassificationViaPLS()
Initializes the classifier.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
buildClassifier(weka.core.Instances data)
Generates a classifier.double
classifyInstance(weka.core.Instance instance)
Classifies the given test instance.double[]
distributionForInstance(weka.core.Instance instance)
Predicts the class memberships for a given instance.String
filterTipText()
Returns the tip text for this propertyweka.core.Capabilities
getCapabilities()
Returns the Capabilities of this classifier.weka.filters.Filter
getFilter()
Get the PLS filter.String
getLabelIndex()
Get the label index of the class attribute to get the PLS matrices for.String
getLabelString()
Get the class attribute's label to get the PLS matrices for.String[]
getOptions()
returns the options of the current setupweka.core.matrix.Matrix
getPLS1bHat()
Returns the PLS1 b "hat" matrix.weka.core.matrix.Matrix
getPLS1P()
Returns the PLS1 P matrix.weka.core.matrix.Matrix
getPLS1RegVector()
Returns the reg vector.weka.core.matrix.Matrix
getPLS1W()
Returns the PLS1 W matrix.String
getRevision()
Returns the revision string.protected PLSClassifierWeightedWithLoadings
getSelectedClassifier()
Returns the specified base classifier.weka.core.matrix.Matrix
getSimplsB()
Returns the SIMPLS B matrix.weka.core.matrix.Matrix
getSimplsW()
Returns the SIMPLS W matrix.String
globalInfo()
Returns a string describing classifierString
labelIndexTipText()
Returns the tip text for this property.String
labelStringTipText()
Returns the tip text for this property.Enumeration
listOptions()
Gets an enumeration describing the available options.static void
main(String[] args)
Main method for running this class.void
setFilter(weka.filters.Filter value)
Set the PLS filter (only used for setup).void
setLabelIndex(String value)
Set the label index to get the PLS matrices for.void
setLabelString(String value)
Set the class attribute's label to get the PLS matrices for.void
setOptions(String[] options)
Parses the options for this object.String
toString()
Returns a string representation of the built model.-
Methods inherited from class weka.classifiers.AbstractClassifier
batchSizeTipText, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
-
-
-
-
Field Detail
-
m_Header
protected weka.core.Instances m_Header
the header of the training set.
-
m_CVR
protected ClassificationViaRegressionD m_CVR
theClassificationViaRegression
used internally.
-
m_LabelIndex
protected weka.core.SingleIndex m_LabelIndex
The label index to get the PLS matrices for.
-
m_LabelString
protected String m_LabelString
the label string to get the PLS matrices for (overrides the label index).
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing classifier- Returns:
- a description suitable for displaying in the explorer/experimenter gui
-
listOptions
public Enumeration listOptions()
Gets an enumeration describing the available options.- Specified by:
listOptions
in interfaceweka.core.OptionHandler
- Overrides:
listOptions
in classweka.classifiers.AbstractClassifier
- Returns:
- an enumeration of all the available options.
-
getOptions
public String[] getOptions()
returns the options of the current setup- Specified by:
getOptions
in interfaceweka.core.OptionHandler
- Overrides:
getOptions
in classweka.classifiers.AbstractClassifier
- Returns:
- the current options
-
setOptions
public void setOptions(String[] options) throws Exception
Parses the options for this object.
Valid options are:
-filter <filter specification> The PLS filter to use. Full classname of filter to include, followed by scheme options. (default: weka.filters.supervised.attribute.PLSFilterWithLoadings)
-label-index <num> The label index (of the class attribute) to return the PLS matrices for. 'first' and 'last' are accepted as well. (default: first)
-label-string <label> The label string (of the class attribute) to return the PLS matrices for. Overrides the '-label-index' option if non-empty. (default: '')
-D If set, classifier is run in debug mode and may output additional info to the console
Options specific to filter weka.filters.supervised.attribute.PLSFilterWithLoadings ('-filter'):
-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)
- Specified by:
setOptions
in interfaceweka.core.OptionHandler
- Overrides:
setOptions
in classweka.classifiers.AbstractClassifier
- Parameters:
options
- the options to use- Throws:
Exception
- if setting of options fails
-
setFilter
public void setFilter(weka.filters.Filter value) throws Exception
Set the PLS filter (only used for setup).- Parameters:
value
- the kernel filter.- Throws:
Exception
- if not PLSFilter
-
getFilter
public weka.filters.Filter getFilter()
Get the PLS filter.- Returns:
- the PLS filter
-
filterTipText
public String filterTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setLabelIndex
public void setLabelIndex(String value)
Set the label index to get the PLS matrices for.- Parameters:
value
- the label index of the class attribute
-
getLabelIndex
public String getLabelIndex()
Get the label index of the class attribute to get the PLS matrices for.- Returns:
- the label index of the class attribute
-
labelIndexTipText
public String labelIndexTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
setLabelString
public void setLabelString(String value)
Set the class attribute's label to get the PLS matrices for. Overridesm_LabelIndex
if non-empty.- Parameters:
value
- the label string of the class attribute
-
getLabelString
public String getLabelString()
Get the class attribute's label to get the PLS matrices for. Overridesm_LabelIndex
if non-empty.- Returns:
- the label string of the class attribute
-
labelStringTipText
public String labelStringTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getCapabilities
public weka.core.Capabilities getCapabilities()
Returns the Capabilities of this classifier. Maximally permissive capabilities are allowed by default. Derived classifiers should override this method and first disable all capabilities and then enable just those capabilities that make sense for the scheme.- Specified by:
getCapabilities
in interfaceweka.core.CapabilitiesHandler
- Specified by:
getCapabilities
in interfaceweka.classifiers.Classifier
- Overrides:
getCapabilities
in classweka.classifiers.AbstractClassifier
- Returns:
- the capabilities of this object
- See Also:
Capabilities
-
buildClassifier
public void buildClassifier(weka.core.Instances data) throws Exception
Generates a classifier.- Specified by:
buildClassifier
in interfaceweka.classifiers.Classifier
- Parameters:
data
- set of instances serving as training data- Throws:
Exception
- if the classifier has not been generated successfully
-
classifyInstance
public double classifyInstance(weka.core.Instance instance) throws Exception
Classifies the given test instance. The instance has to belong to a dataset when it's being classified.- Specified by:
classifyInstance
in interfaceweka.classifiers.Classifier
- Overrides:
classifyInstance
in classweka.classifiers.AbstractClassifier
- Parameters:
instance
- the instance to be classified- Returns:
- the predicted most likely class for the instance or Instance.missingValue() if no prediction is made
- Throws:
Exception
- if an error occurred during the prediction
-
distributionForInstance
public double[] distributionForInstance(weka.core.Instance instance) throws Exception
Predicts the class memberships for a given instance. If an instance is unclassified, the returned array elements must be all zero. If the class is numeric, the array must consist of only one element, which contains the predicted value.- Specified by:
distributionForInstance
in interfaceweka.classifiers.Classifier
- Overrides:
distributionForInstance
in classweka.classifiers.AbstractClassifier
- Parameters:
instance
- the instance to be classified- Returns:
- an array containing the estimated membership probabilities of the test instance in each class or the numeric prediction
- Throws:
Exception
- if distribution could not be computed successfully
-
getSelectedClassifier
protected PLSClassifierWeightedWithLoadings getSelectedClassifier()
Returns the specified base classifier. Either using the label index or the class label string to identify the classifier.- Returns:
- the specified classifier, the default classifier if failed to locate
-
getPLS1RegVector
public weka.core.matrix.Matrix getPLS1RegVector()
Returns the reg vector.- Specified by:
getPLS1RegVector
in interfacePLSMatrixAccess
- Returns:
- the vector
-
getPLS1P
public weka.core.matrix.Matrix getPLS1P()
Returns the PLS1 P matrix.- Specified by:
getPLS1P
in interfacePLSMatrixAccess
- Returns:
- the matrix
-
getPLS1W
public weka.core.matrix.Matrix getPLS1W()
Returns the PLS1 W matrix.- Specified by:
getPLS1W
in interfacePLSMatrixAccess
- Returns:
- the matrix
-
getPLS1bHat
public weka.core.matrix.Matrix getPLS1bHat()
Returns the PLS1 b "hat" matrix.- Specified by:
getPLS1bHat
in interfacePLSMatrixAccess
- Returns:
- the matrix
-
getSimplsW
public weka.core.matrix.Matrix getSimplsW()
Returns the SIMPLS W matrix.- Specified by:
getSimplsW
in interfacePLSMatrixAccess
- Returns:
- the matrix
-
getSimplsB
public weka.core.matrix.Matrix getSimplsB()
Returns the SIMPLS B matrix.- Specified by:
getSimplsB
in interfacePLSMatrixAccess
- Returns:
- the matrix
-
getRevision
public String getRevision()
Returns the revision string.- Specified by:
getRevision
in interfaceweka.core.RevisionHandler
- Overrides:
getRevision
in classweka.classifiers.AbstractClassifier
- Returns:
- the revision
-
toString
public String toString()
Returns a string representation of the built model.
-
main
public static void main(String[] args)
Main method for running this class.- Parameters:
args
- the commandline parameters
-
-