update book chapters
This commit is contained in:
@@ -1202,7 +1202,7 @@ standard deviation. Most machine learning libraries do this as a default. This m
|
||||
the results may differ.
|
||||
|
||||
The
|
||||
"Standadscaler":"https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.StandardScaler.html"
|
||||
"Standardscaler":"https://scikit-learn.org/stable/modules/generated/sklearn.preprocessing.StandardScaler.html"
|
||||
function in _Scikit-Learn_ does this for us. For the data sets we
|
||||
have been studying in our various examples, the data are in many cases
|
||||
already scaled and there is no need to scale them. You as a user of different machine learning algorithms, should always perform a
|
||||
@@ -1256,12 +1256,16 @@ The cost/loss function for regression is
|
||||
C(\beta_0, \beta_1, ... , \beta_{p-1}) = \frac{1}{n}\sum_{i=0}^{n} \left(y_i - \beta_0 - \sum_{j=1}^{p-1} X_{ij}\beta_j\right)^2,.
|
||||
\]
|
||||
!et
|
||||
Recall also that we use the squared value since this leads to an increase of the penalty for higher differences between predicted and output/target values.
|
||||
|
||||
What we have done is to single out the $\beta_0$ term in the definition of the mean squared error (MSE).
|
||||
The design matrix
|
||||
$X$ does in this case not contain any intercept column.
|
||||
When we take the derivative with respect to $\beta_0$, we want the derivative to obey
|
||||
Recall also that we use the squared value. This expression can lead to an
|
||||
increased penalty for higher differences between predicted and
|
||||
output/target values.
|
||||
|
||||
What we have done is to single out the $\beta_0$ term in the
|
||||
definition of the mean squared error (MSE). The design matrix $X$
|
||||
does in this case not contain any intercept column. When we take the
|
||||
derivative with respect to $\beta_0$, we want the derivative to obey
|
||||
|
||||
!bt
|
||||
\[
|
||||
\frac{\partial C}{\partial \beta_j} = 0,
|
||||
@@ -1282,7 +1286,7 @@ Multiplying away the constant $2/n$, we obtain
|
||||
\]
|
||||
!et
|
||||
|
||||
Let us special first to the case where we have only two parameters $\beta_0$ and $\beta_1$.
|
||||
Let us specialize first to the case where we have only two parameters $\beta_0$ and $\beta_1$.
|
||||
Our result for $\beta_0$ simplifies then to
|
||||
!bt
|
||||
\[
|
||||
@@ -1298,10 +1302,10 @@ We obtain then
|
||||
If we define
|
||||
!bt
|
||||
\[
|
||||
\mu_1=\frac{1}{n}\sum_{i=0}^{n-1} (X_{i1},
|
||||
\mu_{\bm{x}_1}=\frac{1}{n}\sum_{i=0}^{n-1} X_{i1},
|
||||
\]
|
||||
!et
|
||||
and if we define the mean value of the outputs as
|
||||
and the mean value of the outputs as
|
||||
!bt
|
||||
\[
|
||||
\mu_y=\frac{1}{n}\sum_{i=0}^{n-1}y_i,
|
||||
@@ -1310,16 +1314,30 @@ and if we define the mean value of the outputs as
|
||||
we have
|
||||
!bt
|
||||
\[
|
||||
\beta_0 = \mu_y - \beta_1\mu_{1}.
|
||||
\beta_0 = \mu_y - \beta_1\mu_{\bm{x}_1}.
|
||||
\]
|
||||
!et
|
||||
In the general case withmore parameters than $\beta_0$ and $\beta_1$, we have
|
||||
In the general case with more parameters than $\beta_0$ and $\beta_1$, we have
|
||||
!bt
|
||||
\[
|
||||
\beta_0 = \frac{1}{n}\sum_{i=0}^{n-1}y_i - \frac{1}{n}\sum_{i=0}^{n-1}\sum_{j=1}^{p-1} X_{ij}\beta_j.
|
||||
\]
|
||||
!et
|
||||
|
||||
We can rewrite the latter equation as
|
||||
!bt
|
||||
\[
|
||||
\beta_0 = \frac{1}{n}\sum_{i=0}^{n-1}y_i - \sum_{j=1}^{p-1} \mu_{\bm{x}_j}\beta_j,
|
||||
\]
|
||||
!et
|
||||
where we have defined
|
||||
!bt
|
||||
\[
|
||||
\mu_{\bm{x}_j}=\frac{1}{n}\sum_{i=0}^{n-1} X_{ij},
|
||||
\]
|
||||
!et
|
||||
the mean value for all elements of the column vector $\bm{x}_j$.
|
||||
|
||||
|
||||
|
||||
Replacing $y_i$ with $y_i - y_i - \overline{\bm{y}}$ and centering also our design matrix results in a cost function (in vector-matrix disguise)
|
||||
|
||||
Reference in New Issue
Block a user