MultivariateLinearRegression Class |
Namespace: Accord.Statistics.Models.Regression.Linear
[SerializableAttribute] public class MultivariateLinearRegression : MultipleTransformBase<double[], double>, ILinearRegression
The MultivariateLinearRegression type exposes the following members.
Name | Description | |
---|---|---|
MultivariateLinearRegression |
Initializes a new instance of the MultivariateLinearRegression class.
| |
MultivariateLinearRegression(Int32, Int32) | Obsolete.
Creates a new Multivariate Linear Regression.
| |
MultivariateLinearRegression(Double, Double, Boolean) | Obsolete.
Creates a new Multivariate Linear Regression.
| |
MultivariateLinearRegression(Double, Double, Boolean) | Obsolete.
Creates a new Multivariate Linear Regression.
| |
MultivariateLinearRegression(Int32, Int32, Boolean) | Obsolete.
Creates a new Multivariate Linear Regression.
|
Name | Description | |
---|---|---|
Coefficients | Obsolete.
Gets the coefficient matrix used by the regression model. Each
column corresponds to the coefficient vector for each of the outputs.
| |
Inputs | Obsolete.
Gets the number of inputs in the model.
| |
Intercepts |
Gets the intercept vector (bias).
| |
NumberOfInputs |
Gets the number of inputs accepted by the model.
(Inherited from TransformBaseTInput, TOutput.) | |
NumberOfOutputs |
Gets the number of outputs generated by the model.
(Inherited from TransformBaseTInput, TOutput.) | |
NumberOfParameters |
Gets the number of parameters in the model (returns
NumberOfInputs * NumberOfOutputs + NumberOfInputs).
| |
Outputs | Obsolete.
Gets the number of outputs in the model.
| |
Weights |
Gets the linear weights matrix.
|
Name | Description | |
---|---|---|
CoefficientOfDetermination(Double, Double, Double) |
Gets the coefficient of determination, as known as R² (r-squared).
| |
CoefficientOfDetermination(Double, Double, Boolean, Double) |
Gets the coefficient of determination, as known as R² (r-squared).
| |
Compute(Double) | Obsolete.
Computes the Multiple Linear Regression output for a given input.
| |
Compute(Double) | Obsolete.
Computes the Multiple Linear Regression output for a given input.
| |
Equals | Determines whether the specified object is equal to the current object. (Inherited from Object.) | |
Finalize | Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.) | |
FromCoefficients | Obsolete.
Creates a new linear regression from the regression coefficients.
| |
FromData |
Creates a new linear regression directly from data points.
| |
GetConfidenceInterval |
Gets the confidence interval for an input point.
| |
GetDegreesOfFreedom |
Gets the degrees of freedom when fitting the regression.
| |
GetHashCode | Serves as the default hash function. (Inherited from Object.) | |
GetPredictionInterval |
Gets the prediction interval for an input point.
| |
GetPredictionStandardError |
Gets the standard error of the prediction for a particular input vector.
| |
GetStandardError(Double, Double) |
Gets the overall regression standard error.
| |
GetStandardError(Double, Double, Double) |
Gets the standard error of the fit for a particular input vector.
| |
GetStandardErrors |
Gets the standard error for each coefficient.
| |
GetType | Gets the Type of the current instance. (Inherited from Object.) | |
Inverse |
Creates the inverse regression, a regression that can recover
the input data given the outputs of this current regression.
| |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
Regress | Obsolete.
Performs the regression using the input vectors and output
vectors, returning the sum of squared errors of the fit.
| |
ToString | Returns a string that represents the current object. (Inherited from Object.) | |
Transform(TInput) |
Applies the transformation to an input, producing an associated output.
(Inherited from MultipleTransformBaseTInput, TOutput.) | |
Transform(TInput) |
Applies the transformation to a set of input vectors,
producing an associated set of output vectors.
(Inherited from MultipleTransformBaseTInput, TOutput.) | |
Transform(TInput, TOutput) |
Applies the transformation to an input, producing an associated output.
(Inherited from MultipleTransformBaseTInput, TOutput.) | |
Transform(Double, Double) |
Applies the transformation to an input, producing an associated output.
(Overrides MultipleTransformBaseTInput, TOutputTransform(TInput, TOutput).) |
Name | Description | |
---|---|---|
HasMethod |
Checks whether an object implements a method with the given name.
(Defined by ExtensionMethods.) | |
IsEqual |
Compares two objects for equality, performing an elementwise
comparison if the elements are vectors or matrices.
(Defined by Matrix.) | |
To(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.) | |
ToT | 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.) |
// The multivariate linear regression is a generalization of // the multiple linear regression. In the multivariate linear // regression, not only the input variables are multivariate, // but also are the output dependent variables. // In the following example, we will perform a regression of // a 2-dimensional output variable over a 3-dimensional input // variable. double[][] inputs = { // variables: x1 x2 x3 new double[] { 1, 1, 1 }, // input sample 1 new double[] { 2, 1, 1 }, // input sample 2 new double[] { 3, 1, 1 }, // input sample 3 }; double[][] outputs = { // variables: y1 y2 new double[] { 2, 3 }, // corresponding output to sample 1 new double[] { 4, 6 }, // corresponding output to sample 2 new double[] { 6, 9 }, // corresponding output to sample 3 }; // With a quick eye inspection, it is possible to see that // the first output variable y1 is always the double of the // first input variable. The second output variable y2 is // always the triple of the first input variable. The other // input variables are unused. Nevertheless, we will fit a // multivariate regression model and confirm the validity // of our impressions: // Use Ordinary Least Squares to create the regression OrdinaryLeastSquares ols = new OrdinaryLeastSquares(); // Now, compute the multivariate linear regression: MultivariateLinearRegression regression = ols.Learn(inputs, outputs); // We can obtain predictions using double[][] predictions = regression.Transform(inputs); // The prediction error is double error = new SquareLoss(outputs).Loss(predictions); // 0 // At this point, the regression error will be 0 (the fit was // perfect). The regression coefficients for the first input // and first output variables will be 2. The coefficient for // the first input and second output variables will be 3. All // others will be 0. // // regression.Coefficients should be the matrix given by // // double[,] coefficients = { // { 2, 3 }, // { 0, 0 }, // { 0, 0 }, // }; // // We can also check the r-squared coefficients of determination: double[] r2 = regression.CoefficientOfDetermination(inputs, outputs);