Linear Regression

Linear Regression

Is a linear model used in Machine Learning belongs to Supervised Learning .

  • Sometimes also called Linear Score Functions
  • Given a labeled/classified data set:
    • Each data point linear_regression_4c331405047e31fa129009cf7a41fc1688f2f613.svg is associated with some label/classificaion linear_regression_f5070d542b71a98d2a255b7b0292f9fff1c832ff.svg
    • linear_regression_f5070d542b71a98d2a255b7b0292f9fff1c832ff.svg is the desired quantity that we want to predict for new data
  • Training a linear regression model creates a linear function linear_regression_a95e375878ca51267b82ae561e3f2a37724360fa.svg as part of the Model Parameter linear_regression_0dd984b3c17df1a79975e491d01fb734faac15d9.svg
  • Testing (validating) takes a new data point and the trained model to produce an estimate linear_regression_6b11ee15d70ff5784a0cbfd27af0d54da9b6e173.svg

Training the model #

  • The Loss Function for the linear regression: linear_regression_0e9ca18cbe7aa42c5dbd96e1c6a15d3f31048521.svg

  • linear_regression_0176537a53cdfd34584536538bba104999077f27.svg to be independent on the number of samples

  • So the optimization problem becomes linear_regression_aaf1f2b236c72f3dba3baf9be70d1134379bc6ab.svg

  • This is linear least squares

  • To find the minimum: linear_regression_9ea04ece617196e94be6914171ba48c441aa7fe8.svg

  • Therefore: linear_regression_bf7b50013ec31c098fa89c70d2c106ca66afd5b6.svg

Training in in 2D #

linear_regression_ad5581ff1f87925c02348b32636bc0b50e1e674d.svg

Is the Least Squares Estimate the best estimate? #

  • Yes because the resulting model is the same as one derived with the Maximum Likelihood Estimate . (Assuming the independence of the samples and the normal distribution)

Proof #

  • We take the MLE model:

    linear_regression_07ad078ef703ebe6b01309cca277df04907e3f2a.svg
  • since linear_regression_ae3953112e0b00ed723a2ed0bd03ac2298373b93.svg is monotonically increasing, the below expression optimizes for the same linear_regression_0dd984b3c17df1a79975e491d01fb734faac15d9.svg as the previous one, but is easier to work with linear_regression_9591b5f80a1d3009ea754dff9e81b09d6ca00acd.svg ()

  • Next, assume linear_regression_a93809a28b67b280eca76520bdced76835ef1385.svg is a Normal Distribution :

    linear_regression_139f09b8449ce84ef4d44e8025f56e9828ab2c8d.svg
  • Therefore

    linear_regression_da08a169d9aaa3fbd79e710efa26e696684cfedd.svg
  • Substituting this back into (2 ): linear_regression_424f13dd1c0297ddee61ee26078767bcc6e41920.svg ()

  • Simplifying linear_regression_14d3a0cb3fc2729f2ed4618e8e54ef5139eab1bc.svg

  • Substituting this back into (5 ):

    linear_regression_528477c729819ad0d59ee0a2886150695f5fa18a.svg
  • Finally we are interested in the linear_regression_0dd984b3c17df1a79975e491d01fb734faac15d9.svg to maximize the expression, so we partially derive with respect to linear_regression_0dd984b3c17df1a79975e491d01fb734faac15d9.svg to find the extremum

    linear_regression_4f94eb5ab0f7822e5c025747cbf6b9a3e401f882.svg
  • Therefore:

    linear_regression_bf7b50013ec31c098fa89c70d2c106ca66afd5b6.svg

From Linear Regression to a Neural Network #

Linear regression will always result in a linear Decision Boundary , which are often not flexible enough.

Until now the linear score function looks like linear_regression_606a31a0d61fc38862bb938661d39ef7b564bbb8.svg

  • with linear_regression_21d0c303da4bd236a2d4d9a73e41a7fcc4ad5b76.svg being the weight matrix.

Even with additional weight matrices, the result would still be linear, since the matrices could be collapsed into one, since matrix multiplication is associative.

The solution then is to make use of a non linear part similar as the Logistic Regression does:

2 layer NN
linear_regression_c24dea0392ae39539ccc911a5b78e3d992843527.svg
3 layer NN
linear_regression_59983f77b93f5699aa9c0bcdb154db2839e3d11b.svg

and so on

where linear_regression_65c6fe1d0748ac787c9ee527feeff767d1b9c4ae.svg is a non-linear function, like Sigmoid Functions , linear_regression_5defd14c575fe0f8e212d45f01d02581197ba1c1.svg, linear_regression_c23b64349b8c65f0ff1e5cab125aa8d03a18497d.svg, …

Calendar October 22, 2023