"LinearRegression" (Machine Learning Method)
- Method for Predict.
- Predict values using a linear combination of features.
Details & Suboptions
- The linear regression predicts the numerical output y using a linear combination of numerical features
. The conditional probability
is modeled according to
, with
.
- The estimation of the parameter vector θ is done by minimizing the loss function
, where m is the number of examples and n is the number of numerical features.
- The following suboptions can be given:
-
"L1Regularization" 0 value of in the loss function
"L2Regularization" Automatic value of iin the loss function
"OptimizationMethod" Automatic what optimization method to use - Possible settings for the "OptimizationMethod" option include:
-
"NormalEquation" linear algebra method "StochasticGradientDescent" stochastic gradient method "OrthantWiseQuasiNewton" orthant-wise quasi-Newton method - For this method, Information[PredictorFunction[…],"Function"] gives a simple expression to compute the predicted value from the features.
Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Train a predictor on labeled examples:

https://wolfram.com/xid/0bqb5x3dcmnm-wxc5bs

Look at the Information:

https://wolfram.com/xid/0bqb5x3dcmnm-3656v8


https://wolfram.com/xid/0bqb5x3dcmnm-tgze8s

Generate two-dimensional data:

https://wolfram.com/xid/0bqb5x3dcmnm-ef76x2

Train a predictor function on it:

https://wolfram.com/xid/0bqb5x3dcmnm-fj7crm

Compare the data with the predicted values and look at the standard deviation:

https://wolfram.com/xid/0bqb5x3dcmnm-bcq515

Options (5)Common values & functionality for each option
"L1Regularization" (2)
Use the "L1Regularization" option to train a predictor:

https://wolfram.com/xid/0bqb5x3dcmnm-8d3hj3

Generate a training set and visualize it:

https://wolfram.com/xid/0bqb5x3dcmnm-z6fnrr

Train two predictors by using different values of the "L1Regularization" option:

https://wolfram.com/xid/0bqb5x3dcmnm-qm6f1x


https://wolfram.com/xid/0bqb5x3dcmnm-718tom

Look at the predictor function to see how the larger L1 regularization has forced one parameter to be zero:

https://wolfram.com/xid/0bqb5x3dcmnm-hs69mo


https://wolfram.com/xid/0bqb5x3dcmnm-psj2uv

"L2Regularization" (2)
Use the "L2Regularization" option to train a predictor:

https://wolfram.com/xid/0bqb5x3dcmnm-zbcx6b

Generate a training set and visualize it:

https://wolfram.com/xid/0bqb5x3dcmnm-zfni0z

Train two predictors by using different values of the "L2Regularization" option:

https://wolfram.com/xid/0bqb5x3dcmnm-6md8tb


https://wolfram.com/xid/0bqb5x3dcmnm-z9k0eu

Look at the predictor functions to see how the L2 regularization has reduced the norm of the parameter vector:

https://wolfram.com/xid/0bqb5x3dcmnm-8l4sma


https://wolfram.com/xid/0bqb5x3dcmnm-chnthl

"OptimizationMethod" (1)
Generate a large training set:

https://wolfram.com/xid/0bqb5x3dcmnm-9l9jxc
Train predictors with different optimization methods and compare their training times:

https://wolfram.com/xid/0bqb5x3dcmnm-wvgecx


https://wolfram.com/xid/0bqb5x3dcmnm-ch9ek5
