multiple features(多变量)
x = [ x 0 x 1 x 2 ⋮ x n ] ∈ R n + 1 x=\left[ \begin{matrix} x_0 \\ x_1 \\ x_2 \\ \vdots \\ x_n \end{matrix} \right]\in R^{n+1} x=⎣⎢⎢⎢⎢⎢⎡x0x1x2⋮xn⎦⎥⎥⎥⎥⎥⎤∈Rn+1
h θ ( x ) = θ T x h_\theta(x)=\theta^T x hθ(x)=θTx called multivariate linear regression
gradient descent for multiple variables
feature scaling(特征缩放) on a similar scale − 1 < x i < 1 -1<x_i<1 −1<xi<1 range
mean normalization(均值归一化)
x i − u i s i \frac{x_i-u_i}{s_i} sixi−ui
s i s_i si range (max-min)
learning rate α \alpha α too smalll or too big both is not good
polynomial regression(多项式回归) 要进行特征缩放
normal equation(正规方程)
pinv(x’ * x)*x’ *y 不需要均值归一 复杂度n^3 最多10000 只能用于线性回归
不可逆
1.存在redundant feature 冗余的变量
2.too many features (m<=n) x是m * n+1的矩阵
matlab 总结
pwd print working directory
ls list
load 加载数据
who 显示当前的变量
who 更详细
clear 用来清除变量
save hello.mat v 保存
max 如果是向量 就返回最大值 矩阵 就返回每列的最大值 max两个矩阵,就返回两个之间的最大值
prod 返回乘积的和
flipud 上下矩阵翻转
plot plot(t,y1) 一个是x轴 一个是y轴
hold on 保持原来的图像
xlabel ylabel 对x轴 y轴进行描述
legend 对线段进行描述
subplot 对图像进行分割
axis 改变横坐标 纵坐标的范围
clf clear figure
for i=1:10,
v(i)=2^i;
end;
exit quit 都能退出matlab
matlab 函数可以返回多个值