【机器学习基础】用正则化防止过拟合|Regularization

岭回归|Ridge Regression

  • Main idea: slightly worse fit for training data, better long term predictions. ➡️ A little more bias, significznt drop in variance

  • Definition: Add λ × s l o p o e 2 \lambda\times slopoe^2 λ×slopoe2 in the objective function(Least Squares + Ridge Regression Penalty). λ \lambda λ determines how severe the penalty is.

  • Choose λ \lambda λ with cross validation, to determine which one results in lowest variance

  • Compare the Least Squares line and Ridge regression line

    • Variance: Without the small amount of bias that penalty creates, the least squares has a large amount of variance.
    • Sensitivity to x x x: When the slope of the line is steep, then the prediction for y y y is very sensitive to relatively small changes in x x x. The ridge regression line is less sensitive to changes in x x x.
  • When using a discrete variable to predict a continuous variable, the intercept is the average target value when x = 0 x=0 x=0, the slope is the difference between the averae target in two cases, then intercept + slope is the average target value when x = 1 x=1 x=1.(Predicted value)

  • 需要防止过拟合的场景:特征数多于样本数,用岭回归

    • Improve predictions made for new data(i.e. reduce variance) by making the predictions less sensitive to the training data.

Lasso回归|Lasso Regression

  • The sum of squared residuals(Least Squares) + λ ∣ t h e   s l o p e ∣ \lambda|the\ slope| λthe slope(Absolute value). y-intercept is not included in the slope.

岭回归 vs Lasso回归

  • 共同点

    • Both make the prediction of target variable less sensitive to independent variables.
    • When they shrink parameters, they don’t have to shrink them equally.
    • Set λ > 0 \lambda>0 λ>0 results in a smaller optimal slope in both methods.
  • 不同点

    • Ridge regression can only shrink the slope asymptotically(渐近地) close to 0 while Lasso regression can shrink the slope all the way to 0.

      产生原因(从slope values-objective function value的图角度来看)

      • In Ridge regression, when λ \lambda λ increase, the optimal slopes shifts towards 0, but a nice parabola (抛物线) slope is retained. No matter how large λ \lambda λ is, optimal slope will not be 0.
      • In Lasso regression, when λ \lambda λ increase, the optimal slopes shifts towards 0, but since we have a kink(扭折) at 0, 0 ends up being the optimal slope.

      这导致了二者适用范围的区别

      • Lasso regression can exclude useless variables from equations. Better than ridge regression at reducing the variance in models that contains a lot of useless variables.
      • Ridge regression is better when most variables are useful.
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: 正则化是一种用于限制模型复杂度的正则化技术,它使学习算法更健壮,更稳定,更可靠。它通过向模型添加附加项(正则化项),以降低模型复杂度。正则化项可以是L1正则化(Lasso正则化)或L2正则化(Ridge正则化)等。 ### 回答2: 在机器学习中,正则化是一种通过在模型的损失函数中引入惩罚项来避免过拟合的技术。其原理是通过约束模型的复杂度,使得模型更加简单而具有较好的泛化能力。 正则化主要有两种形式:L1正则化和L2正则化。L1正则化引入了模型参数的绝对值之和作为惩罚项,即通过最小化损失函数和正则化项的和来寻找最优解。L2正则化则引入了模型参数的平方和作为惩罚项,即通过最小化损失函数和正则化项的和来寻找最优解。 正则化的原理是通过对模型参数进行约束,可以使得某些参数趋近于0,从而实现特征选择和降低模型复杂度的目的。L1正则化倾向于产生稀疏解,即只有部分参数非0,从而实现特征选择,有助于模型的解释性。而L2正则化则倾向于参数趋近于0而非完全为0,可以降低模型的复杂度,并避免过拟合正则化可以有效地控制模型的复杂度,在训练过程中通过平衡拟合程度和模型复杂度来选择最优解。当正则化力度较大时,模型会更加关注减小正则化项,从而更加趋向于简单的模型。当正则化力度较小时,模型会更加关注拟合训练数据,可能导致过拟合。 总之,正则化机器学习中用于避免过拟合、提高模型泛化能力的重要技术。通过限制模型的复杂度,正则化可以提高模型的性能和稳定性。 ### 回答3: 机器学习中的正则化是一种通过添加惩罚项来控制模型复杂度的技术。正则化的目的是防止模型过拟合(overfitting),即在训练数据上表现优秀但在新数据上表现较差的情况。 正则化的原理是在模型的损失函数中,加入一个额外的惩罚项,以限制模型参数的取值范围。这个惩罚项可以是L1正则化(L1 regularization)或者L2正则化(L2 regularization)。 L1正则化通过在损失函数中加入模型参数的绝对值之和乘以一个超参数lambda的惩罚项,使得模型参数趋向于稀疏化。通过L1正则化,可以使得模型自动选择重要的特征,并且减少不相关或冗余特征的影响。 L2正则化通过在损失函数中加入模型参数的平方之和乘以一个超参数lambda的惩罚项,使得模型参数的取值更加平滑。通过L2正则化,可以减小模型参数的大小,并且降低模型对训练数据中的噪声的敏感性。 正则化的原理是在训练模型时,通过调整惩罚项的权重,平衡拟合训练数据和控制模型复杂度之间的关系。正则化在一定程度上约束了模型的自由度,使得模型更加稳定、泛化能力更强,从而能够更好地适应新数据。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值