Click or drag to resize
Accord.NET (logo)

PartialLeastSquaresAnalysis Class

Partial Least Squares Regression/Analysis (a.k.a Projection To Latent Structures)
Inheritance Hierarchy
SystemObject
  Accord.MachineLearningTransformBaseDouble, Double
    Accord.MachineLearningMultipleTransformBaseDouble, Double
      Accord.Statistics.AnalysisPartialLeastSquaresAnalysis

Namespace:  Accord.Statistics.Analysis
Assembly:  Accord.Statistics (in Accord.Statistics.dll) Version: 3.8.0
Syntax
[SerializableAttribute]
public class PartialLeastSquaresAnalysis : MultipleTransformBase<double[], double>, 
	IMultivariateRegressionAnalysis, IMultivariateAnalysis, IAnalysis, IProjectionAnalysis, ISupervisedLearning<MultivariateLinearRegression, double[], double[]>
Request Example View Source

The PartialLeastSquaresAnalysis type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyAlgorithm
Gets or sets the PLS algorithm used by the analysis.
Public propertyDependents
Gets information about dependent (output) variables.
Public propertyFactors
Gets information about the factors discovered during the analysis in a object-oriented structure which can be data-bound directly to many controls.
Public propertyImportance
Gets the Variable Importance in Projection (VIP).
Public propertyMaximumNumberOfFactors
Gets the maximum number of latent factors that can be considered in this model.
Public propertyMethod
Gets or sets the method used by this analysis.
Public propertyNumberOfInputs
Gets the number of inputs accepted by the model.
(Overrides TransformBaseTInput, TOutputNumberOfInputs.)
Public propertyNumberOfLatentFactors
Gets or sets the number of latent factors that can be considered in this model.
Public propertyNumberOfOutputs
Gets the number of outputs generated by the model.
(Overrides TransformBaseTInput, TOutputNumberOfOutputs.)
Public propertyOutput Obsolete.
Gets the dependent variables' values for each of the source input points.
Public propertyOverwrite
Gets or sets whether calculations will be performed overwriting data in the original source matrix, using less memory.
Public propertyPredictors
Gets information about independent (input) variables.
Public propertySource Obsolete.
Source data used in the analysis.
Public propertyToken
Gets or sets a cancellation token that can be used to stop the learning algorithm while it is running.
Public propertyWeights
Gets the Weight matrix obtained during the analysis. For the NIPALS algorithm this is the W matrix. For the SIMPLS algorithm this is the R matrix.
Top
Methods
  NameDescription
Protected methodAdjust(Double, Double, Double, Boolean)
Adjusts a data matrix, centering and standardizing its values using the already computed column's means and standard deviations.
Protected methodAdjust(Double, Double, Double, Boolean)
Adjusts a data matrix, centering and standardizing its values using the already computed column's means and standard deviations.
Public methodCompute Obsolete.
Computes the Partial Least Squares Analysis.
Public methodCompute(Int32) Obsolete.
Computes the Partial Least Squares Analysis.
Protected methodComputeVariableImportanceInProjection
Computes the variable importance in projection (VIP).
Public methodCreateRegression
Creates a Multivariate Linear Regression model using coefficients obtained by the Partial Least Squares.
Public methodCreateRegression(Int32)
Creates a Multivariate Linear Regression model using coefficients obtained by the Partial Least Squares.
Public methodEquals
Determines whether the specified object is equal to the current object.
(Inherited from Object.)
Protected methodFinalize
Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object.)
Public methodGetHashCode
Serves as the default hash function.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodLearn
Learns a model that can map the given inputs to the given outputs.
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Public methodTransform(TInput)
Applies the transformation to an input, producing an associated output.
(Inherited from MultipleTransformBaseTInput, TOutput.)
Public methodTransform(TInput)
Applies the transformation to a set of input vectors, producing an associated set of output vectors.
(Inherited from MultipleTransformBaseTInput, TOutput.)
Public methodTransform(Double) Obsolete.
Projects a given set of inputs into latent space.
Public methodTransform(TInput, TOutput)
Applies the transformation to an input, producing an associated output.
(Inherited from MultipleTransformBaseTInput, TOutput.)
Public methodTransform(Double, Int32) Obsolete.
Projects a given set of inputs into latent space.
Public methodTransform(Double, Double)
Applies the transformation to an input, producing an associated output.
(Overrides MultipleTransformBaseTInput, TOutputTransform(TInput, TOutput).)
Public methodTransformOutput(Double) Obsolete.
Projects a given set of outputs into latent space.
Public methodTransformOutput(Double)
Projects a given set of outputs into latent space.
Public methodTransformOutput(Double, Int32) Obsolete.
Projects a given set of outputs into latent space.
Public methodTransformOutput(Double, Int32)
Projects a given set of outputs into latent space.
Top
Extension Methods
  NameDescription
Public Extension MethodHasMethod
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.)
Public Extension MethodIsEqual
Compares two objects for equality, performing an elementwise comparison if the elements are vectors or matrices.
(Defined by Matrix.)
Public Extension MethodTo(Type)Overloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Public Extension MethodToTOverloaded.
Converts an object into another type, irrespective of whether the conversion can be done at compile time or not. This can be used to convert generic types to numeric types during runtime.
(Defined by ExtensionMethods.)
Top
Remarks

Partial least squares regression (PLS-regression) is a statistical method that bears some relation to principal components regression; instead of finding hyperplanes of maximum variance between the response and independent variables, it finds a linear regression model by projecting the predicted variables and the observable variables to a new space. Because both the X and Y data are projected to new spaces, the PLS family of methods are known as bilinear factor models.

References:

  • Abdi, H. (2010). Partial least square regression, projection on latent structure regression, PLS-Regression. Wiley Interdisciplinary Reviews: Computational Statistics, 2, 97-106. Available in: http://www.utdallas.edu/~herve/abdi-wireCS-PLS2010.pdf
  • Abdi, H. (2007). Partial least square regression (PLS regression). In N.J. Salkind (Ed.): Encyclopedia of Measurement and Statistics. Thousand Oaks (CA): Sage. pp. 740-744. Resource available online in: http://www.utdallas.edu/~herve/Abdi-PLS-pretty.pdf
  • Martin Anderson, "A comparison of nine PLS1 algorithms". Available on: http://onlinelibrary.wiley.com/doi/10.1002/cem.1248/pdf
  • Mevik, B-H. Wehrens, R. (2007). The pls Package: Principal Component and Partial Least Squares Regression in R. Journal of Statistical Software, Volume 18, Issue 2. Resource available online in: http://www.jstatsoft.org/v18/i02/paper
  • Garson, D. Partial Least Squares Regression (PLS). http://faculty.chass.ncsu.edu/garson/PA765/pls.htm
  • De Jong, S. (1993). SIMPLS: an alternative approach to partial least squares regression. Chemometrics and Intelligent Laboratory Systems, 18: 251–263. http://dx.doi.org/10.1016/0169-7439(93)85002-X
  • Rosipal, Roman and Nicole Kramer. (2006). Overview and Recent Advances in Partial Least Squares, in Subspace, Latent Structure and Feature Selection Techniques, pp 34–51. http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.85.7735
  • Yi Cao. (2008). Partial Least-Squares and Discriminant Analysis: A tutorial and tool using PLS for discriminant analysis.
  • Wikipedia contributors. Partial least squares regression. Wikipedia, The Free Encyclopedia; 2009. Available from: http://en.wikipedia.org/wiki/Partial_least_squares_regression.

Examples
// References: http://www.utdallas.edu/~herve/Abdi-PLSR2007-pretty.pdf

// Following the small example by Hervé Abdi (Hervé Abdi, Partial Least Square Regression),
// we will create a simple example where the goal is to predict the subjective evaluation of
// a set of 5 wines. The dependent variables that we want to predict for each wine are its 
// likeability, and how well it goes with meat, or dessert (as rated by a panel of experts).
// The predictors are the price, the sugar, alcohol, and acidity content of each wine.


// Here we will list the inputs, or characteristics we would like to use in order to infer
// information from our wines. Each row denotes a different wine and lists its corresponding
// observable characteristics. The inputs are usually denoted by X in the literature.

inputs = new double[][]
{
    //      Wine | Price | Sugar | Alcohol | Acidity
    new double[] {   7,     7,      13,        7 },
    new double[] {   4,     3,      14,        7 },
    new double[] {  10,     5,      12,        5 },
    new double[] {  16,     7,      11,        3 },
    new double[] {  13,     3,      10,        3 },
};


// Here we will list our dependent variables. Dependent variables are the outputs, or what we
// would like to infer or predict from our available data, given a new observation. The outputs
// are usually denotes as Y in the literature.

outputs = new double[][]
{
    //             Wine | Hedonic | Goes with meat | Goes with dessert
    new double[] {           14,          7,                 8 },
    new double[] {           10,          7,                 6 },
    new double[] {            8,          5,                 5 },
    new double[] {            2,          4,                 7 },
    new double[] {            6,          2,                 4 },
};


// Next, we will create our Partial Least Squares Analysis passing the inputs (values for 
// predictor variables) and the associated outputs (values for dependent variables).

// We will also be using the using the Covariance Matrix/Center method (data will only
// be mean centered but not normalized) and the NIPALS algorithm. 
var pls = new PartialLeastSquaresAnalysis()
{
    Method = AnalysisMethod.Center,
    Algorithm = PartialLeastSquaresAlgorithm.SIMPLS
};

// Compute the analysis with all factors. The number of factors
// could also have been specified in a overload of this method.

var regression = pls.Learn(inputs, outputs);

// After the regression has been created, we will be able to classify new instances. 
// For example, we will compute the outputs for the first input sample:

double[] y = regression.Transform(new double[] { 7, 7, 13, 7 });

// The y output will be very close to the corresponding output used as reference.
// In this case, y is a vector of length 3 with values { 14.00, 7.00, 7.75 }.
See Also