“ML”的版本间的差异

来自个人维基
跳转至: 导航搜索
Multivariate Linear Regression
Gradient Descent梯度下降
第12行: 第12行:
 
:<math>= \frac{1}{m}\sum_{i=1}^m( (h_&theta;(x_i)-y_i) \frac{&part;}{&part;&theta;_j}h_&theta;(x_i) )  //链式求导法式</math>
 
:<math>= \frac{1}{m}\sum_{i=1}^m( (h_&theta;(x_i)-y_i) \frac{&part;}{&part;&theta;_j}h_&theta;(x_i) )  //链式求导法式</math>
 
:<math>= \frac{1}{m}\sum_{i=1}^m( (h_&theta;(x_i)-y_i) \frac{&part;}{&part;&theta;_j}x_i&theta; ) </math>
 
:<math>= \frac{1}{m}\sum_{i=1}^m( (h_&theta;(x_i)-y_i) \frac{&part;}{&part;&theta;_j}x_i&theta; ) </math>
:<math>= \frac{1}{m}\sum_{i=1}^m( (h_&theta;(x_i)-y_i) \frac{&part;}{&part;&theta;_j}\sum_{k=0}^{n-1}x_{ik}&theta;_k ) </math>
+
:<math>= \frac{1}{m}\sum_{i=1}^m( (h_&theta;(x_i)-y_i) \frac{&part;}{&part;&theta;_j}\sum_{k=0}^{n}x_{ik}&theta;_k ) </math>
 
对于j>=1:
 
对于j>=1:
 
:<math>= \frac{1}{m}\sum_{i=1}^m( (h_&theta;(x_i)-y_i) x_{ij} ) </math>
 
:<math>= \frac{1}{m}\sum_{i=1}^m( (h_&theta;(x_i)-y_i) x_{ij} ) </math>

2018年12月21日 (五) 18:49的版本

目录

Week1

Cost Function损失函数

Squared error function/Mean squared function均方误差: [math]J(θ)=\frac{1}{2m}\sum_{i=1}^m(h_θ(x_i)-y_i)^2[/math]
Cross entropy交叉熵: [math]J(θ)=-\frac{1}{m}\sum_{i=1}^m[y^{(i)}*logh_θ(x^{(i)})+(1-y^{(i)})*log(1-h_θ(x^{(i)}))][/math]

Gradient Descent梯度下降

[math]θ_j:=θ_j+α\frac{∂}{∂θ_j}J(θ)[/math]
对于线性模型,其损失函数为均方误差,故有(这里输入训练数据x为m*n矩阵, 线性参数[math]θ[/math]为n*1,[math]x_i[/math]代表训练矩阵中的第i行,[math]x_{ik}[/math]代表第i行第k列):
[math]\frac{∂}{∂θ_j}J(θ)= \frac{∂}{∂θ_j}(\frac{1}{2m}\sum_{i=1}^m(h_θ(x_i)-y_i)^2)[/math]

[math]= \frac{1}{2m}\frac{∂}{∂θ_j}(\sum_{i=1}^m(h_θ(x_i)-y_i)^2)[/math]
[math]= \frac{1}{2m}\sum_{i=1}^m( \frac{∂}{∂θ_j}(h_θ(x_i)-y_i)^2 )[/math]
[math]= \frac{1}{m}\sum_{i=1}^m( (h_θ(x_i)-y_i) \frac{∂}{∂θ_j}h_θ(x_i) ) //链式求导法式[/math]
[math]= \frac{1}{m}\sum_{i=1}^m( (h_θ(x_i)-y_i) \frac{∂}{∂θ_j}x_iθ ) [/math]
[math]= \frac{1}{m}\sum_{i=1}^m( (h_θ(x_i)-y_i) \frac{∂}{∂θ_j}\sum_{k=0}^{n}x_{ik}θ_k ) [/math]

对于j>=1:

[math]= \frac{1}{m}\sum_{i=1}^m( (h_θ(x_i)-y_i) x_{ij} ) [/math]
[math]= \frac{1}{m} (h_θ(x)-y) x_{j} [/math]

Week2

Multivariate Linear Regression

[math]h_θ(x) = θ_0x_0 + θ_1x_1 + θ_2x_2 + ... + θ_nx_n[/math]

[math] = [θ_0x_0^{(1)}, θ_0x_0^{(2)}, ..., θ_0x_0^{(m)}] + [θ_1x_1^{(1)}, θ_1x_1^{(2)}, ..., θ_1x_1^{(m)}] + ... + [θ_nx_n^{(1)}, θ_nx_n^{(2)}, ..., θ_nx_n^{(m)}] [/math]
[math] = [θ_0x_0^{(1)}+θ_1x_1^{(1)}+...+θ_nx_n^{(1)}, \ \ \ θ_0x_0^{(2)}+θ_1x_1^{(2)}+...+θ_nx_n^{(2)}, \ \ \ θ_0x_0^{(m)}+θ_1x_1^{(m)}+...+θ_nx_n^{(m)}] [/math]
[math] = θ^Tx[/math]

其中,
[math] x=\begin{vmatrix} x_0 \\ x_1 \\ x_2 \\ ... \\ x_n \end{vmatrix} = \begin{vmatrix} x_0^{(1)} & x_0^{(2)} & ... & x_0^{(m)} \\ x_1^{(1)} & x_1^{(2)} & ... & x_1^{(m)} \\ x_2^{(1)} & x_2^{(2)} & ... & x_2^{(m)} \\ ... & ... & ... & ...\\ x_m^{(1)} & x_m^{(2)} & ... & x_n^{(m)} \\ \end{vmatrix} , θ=\begin{vmatrix} θ_0 \\ θ_1\\ θ_2\\ ...\\ θ_n \end{vmatrix} [/math]

m为训练数据组数,n为特征个数(通常,为了方便处理,会令[math]x_0^{(i)}=1, i=1,2,...,m)[/math]

Feature Scaling & Standard Normalization

[math] x_i := \frac{x_i-μ_i}{s_i} [/math]
其中,[math]μ_i[/math]是第i个特征数据x_i的均值,而 [math]s_i[/math]则要视情况而定:

  • Feature Scaling:[math]s_i[/math][math]x_i[/math]中最大值与最小值的差(max-min);
  • Standard Normalization:[math]s_i[/math][math]x_i[/math]中数据标准差(standard deviation)。