the problem of overfitting

本文探讨了机器学习中常见的过拟合与欠拟合问题,并介绍了如何通过减少特征数量或使用正则化来解决这些问题。此外,还详细解释了正则化在逻辑回归和线性回归中的应用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

这里写图片描述

underfitting or high bias—hypothesis function h maps poorly to the trend of the data.
usually caused by a function that is too simple or uses too few features.

overfitting or high variancefits the available data but does not generalize well to predict new data.
usually caused by a complicated function that creates a lot of unnecessary curves and angles unrelated to the data.

to address it:
1) Reduce the number of features:
1. Manually select which features to keep.
2. Use a model selection algorithm .
2) Regularization
1. Keep all the features: but reduce the magnitude of parameters θj.
2. Regularization works well when we have a lot of slightly useful features.

Regularization:
1.regularized linear regression
Without actually getting rid of these features or changing the form of our hypothesis, we can instead modify our cost function:

minθ12m[i=1m(hθ(x(i))y(i))2+λj=1nθ2j]

The λ, is the regularization parameter.
If λ is chosen to be too large, it may smooth out the function too much and cause underfitting.
这里写图片描述
As a result, we see that the new hypothesis (depicted by the pink curve) looks like a quadratic function but fits the data better due to the extra small terms θ

这里写图片描述
actually,(1αλm)<1
so it shrink the parameter a little bit before do the same thing as previous.
这里写图片描述
Using regularization also takes care of any non-invertibility issues of the X transpose X matrix as well.
这里写图片描述
if m ≤ n, then XTX is non-invertible. However, when we add the term λ⋅L, then XTX+λL becomes invertible.

2.regularized logistic regression
这里写图片描述
这里写图片描述
the θ vector is indexed from 0 to n (holding n+1 values, θ0 through θn), and this sum explicitly skips θ0

b.t.w Because regularization causes J(θ) to no longer be convex, gradient descent may not always converge to the global minimum (when λ>0, and when using an appropriate learning rate α).

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值