Linear Regression Optimization

Ordinary Least Squares Parameters Explained

These are the most commonly adjusted parameters with Ordinary Least Squares (A very popular Linear Regression Model). Let’s take a deeper look at what they are used for and how to change their values:

fit_intercept: (default: True) Concerning intercept values (constants), this parameter can be used to turn intercepts on or off.

True: Intercepts will be applied in calculations.

False: Intercepts won’t be used in calculations.

normalize: (default: False) Only works if fit_intercept parameter True. This parameter allows normalization before linear regression takes place.

False: No normalization will take place.

True: X will be normalized before regression (mean value will be subtracted and result will be divided by l2-norm).

Examples:

linreg = LinearRegression(fit_intercept = True)
linreg = LinearRegression(copy_X = False)
linreg = LinearRegression(normalize = False)
linreg = LinearRegression(n_jobs = -1)

More parameters

More OLS Parameters for fine tuning

Further on, these parameters can be used for further optimization in Ordinary Least Squares Models:

  • n_jobs
  • copy_X

n_jobs

(default: None)

Allows choosing number of processor core units to be run in parallel during regression. Can be useful to speed up the process.

None: Equals 1 and only 1 processor core will be used.

-1: All processors core units will be allowed to run in parallel when available.

int: Processor cores that are allowed to run in parallel will be based on integer value assigned here.

copy_X

(default: True)

True: X will be copied


False: X might get overwritten

Official Scikit Learn Documentation: sklearn.linear_model.LinearRegression