olsfit
Ordinary Least Squares Linear regression.
Syntax
parameters = olsfit(X,y)
parameters = olsfit(X,y,options)
Inputs
- X
 - Training data.
 - y
 - Target values.
 - options
 - Type: struct
 
Outputs
- parameters
 - Contains all the values passed to olsfit method as options. Additionally it has below key-value pairs.
 
Example
Usage of olsfit with options
X = [1 2 3; 4 5 6; 7 8 9; 10 11 12; 13 14 15; 16 17 18; 19 20 21];
y = [1, 2, 3, 4, 5, 6, 7];
options = struct;
options.to_normalize = true;
parameters = olsfit(X, y, options)
      parameters = struct [
  coef: [Matrix] 3 x 1
  0.66667
  0.66667
  0.66667
  intercept: 4
  n_features: 3
  n_samples: 7
  params: [Matrix] 4 x 1
  4.00000
  0.66667
  0.66667
  0.66667
  scorer: @r2
  to_normalize: 1
] 
    Comments
It performs regression using Ordinary Least Squares method. Once the coefficients are computed, outputs are predicted using olspredict method.