当前位置: 首页 > wzjs >正文

网站工程师平均工资自贡网站seo

网站工程师平均工资,自贡网站seo,如保做网站赢利,大连营销型网站建设机器学习核心问题:过拟合 vs 欠拟合 图示作者:Chris Albon 1. 什么是拟合(Fit)? 拟合(Fit)是指模型对数据的学习效果。 理想目标: 在训练集上效果好 在测试集上效果也好 不复杂、…

机器学习核心问题:过拟合 vs 欠拟合

图示作者:Chris Albon


1. 什么是拟合(Fit)?

拟合(Fit)是指模型对数据的学习效果。

理想目标:

  • 在训练集上效果好

  • 在测试集上效果也好

  • 不复杂、不简单,恰到好处


2. 什么是过拟合(Overfitting)?

定义

过拟合是指模型在训练集上表现很好,但在测试集或新数据上效果很差。模型学到了“噪声”或“异常值”的特征。


特征

特征表现
方差很大对数据过度敏感
决策边界复杂曲折、震荡
泛化能力差新数据易失败

图示(来自图片左侧)

特征2 ↑● ○   ○○ ○○ ● ● ○  ← 决策边界很曲折
特征1 →

 


3. 什么是欠拟合(Underfitting)?

定义

欠拟合是指模型太简单,无法捕捉数据的有效规律,无论在训练集还是测试集上效果都不好。


特征

特征表现
偏差很大无法拟合数据规律
决策边界简单接近直线
泛化能力弱无法有效学习

图示(来自图片右侧)

特征2 ↑● ○   ○○ ○○ ● ● ○  ← 决策边界几乎是直线
特征1 →

 


4. 理想拟合(Best Fit)

状态

  • 偏差(Bias)适中

  • 方差(Variance)适中

  • 决策边界恰好捕捉规律

  • 泛化能力强


图示(图片中间)

特征2 ↑● ○   ○○ ○○ ● ● ○  ← 决策边界几乎是直线
特征1 →

 


5. 数学公式:偏差-方差分解(Bias-Variance Tradeoff)

理论公式

机器学习期望误差可以分解为:

名称含义
Bias偏差,模型简单
Variance方差,模型敏感
Irreducible Error无法消除的随机误差

6. Python实操示例

构造数据

import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error# 真实函数
def true_func(x):return np.sin(2 * np.pi * x)np.random.seed(0)
x = np.sort(np.random.rand(30))
y = true_func(x) + np.random.normal(scale=0.3, size=x.shape)x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.3)

 


欠拟合(低阶多项式)

poly1 = PolynomialFeatures(degree=1)
x1_train = poly1.fit_transform(x_train.reshape(-1, 1))
x1_test = poly1.transform(x_test.reshape(-1, 1))model1 = LinearRegression().fit(x1_train, y_train)
print('欠拟合 MSE:', mean_squared_error(y_test, model1.predict(x1_test)))
欠拟合 MSE: 0.418206083278207

 


过拟合(高阶多项式)

poly15 = PolynomialFeatures(degree=15)
x15_train = poly15.fit_transform(x_train.reshape(-1, 1))
x15_test = poly15.transform(x_test.reshape(-1, 1))model15 = LinearRegression().fit(x15_train, y_train)
print('过拟合 MSE:', mean_squared_error(y_test, model15.predict(x15_test)))
过拟合 MSE: 2.732472745353921

 


理想情况(适中阶)

poly4 = PolynomialFeatures(degree=4)
x4_train = poly4.fit_transform(x_train.reshape(-1, 1))
x4_test = poly4.transform(x_test.reshape(-1, 1))model4 = LinearRegression().fit(x4_train, y_train)
print('理想拟合 MSE:', mean_squared_error(y_test, model4.predict(x4_test)))
理想拟合 MSE: 0.1546713133312227

 


7. 如何避免过拟合与欠拟合?

问题类型解决思路
过拟合- 降低模型复杂度
- 增加正则化(L1/L2)
- 增加数据量
- Dropout
- 提前停止
欠拟合- 增加特征
- 增强模型复杂度
- 降低正则化
- 使用更强模型

8. 可视化偏差-方差关系(效果示意)

import numpy as np
import matplotlib.pyplot as plt
from sklearn.model_selection import train_test_split
from sklearn.preprocessing import PolynomialFeatures
from sklearn.linear_model import LinearRegression
from sklearn.metrics import mean_squared_error# 真实函数
def true_func(x):return np.sin(2 * np.pi * x)np.random.seed(0)
x = np.sort(np.random.rand(30))
y = true_func(x) + np.random.normal(scale=0.3, size=x.shape)x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.3)complexity = np.arange(1, 15)
train_errors = []
test_errors = []for d in complexity:poly = PolynomialFeatures(degree=d)x_tr = poly.fit_transform(x_train.reshape(-1, 1))x_te = poly.transform(x_test.reshape(-1, 1))model = LinearRegression().fit(x_tr, y_train)train_errors.append(mean_squared_error(y_train, model.predict(x_tr)))test_errors.append(mean_squared_error(y_test, model.predict(x_te)))plt.plot(complexity, train_errors, label='Train Error')
plt.plot(complexity, test_errors, label='Test Error')
plt.xlabel('Model Complexity (degree)')
plt.ylabel('MSE')
plt.legend()
plt.show()

 

 


9. 总结

项目过拟合欠拟合
决策边界复杂简单
偏差Bias
方差Variance
表现训练好,测试差训练差,测试差

10. 最佳实践

寻找偏差和方差的平衡,是机器学习调参的艺术。
合理的特征工程 + 模型复杂度控制 + 正则化技术,是最佳组合。

 

http://www.dtcms.com/wzjs/364553.html

相关文章:

  • wordpress做成论坛优化seo方案
  • 媒体公司网站模板seo关键词优化公司哪家好
  • 电子商务网站建设的具体内容竞价广告是怎么推广的
  • 手机网站做seo百度一下京东
  • 中山建网站价格网站排名点击工具
  • 淮安市政府门户网站建设的调查报告网站优化排名方案
  • gif动图素材网站收录批量查询工具
  • 泰安网站建设焦点网络自动推广软件免费
  • 哪些网站做彩票预测途径文章推广平台
  • 一台服务器如何做两个网站网站推广营销的步骤
  • 兰州网站seo按天计费百度推广开户代理商
  • web网站开发需要什么18岁以上站长统计
  • 电影html网页模板设计素材百度seo关键词排名价格
  • 猎头自己在哪个网站做单网站seo需要用到哪些工具
  • 佛山百度关键词seo外包武汉seo招聘
  • 虚拟主机和服务器有什么区别网络优化工程师是干什么的
  • 日文网站模板营销自动化工具
  • 网站开发过程前端后端搜索引擎优化排名案例
  • 网站开发网站有哪些企业培训课程推荐
  • 做网站当生日礼物服务器ip域名解析
  • 网站建设与网页设计从入门到精通 pdf最新新闻实时新闻
  • 大连网站流量优化定制磁力吧ciliba
  • 咸阳专业网站建设seo软件推广
  • 建筑工程网上教育平台常用的seo工具
  • 做网站cookie传值萧山seo
  • 网站建设的市场分析阿拉营销网站
  • 怎样做网站设计免费留电话号码的广告
  • 北京网站开发外包网络营销业务流程
  • 做网站后台开发工资seo优化公司排名
  • wordpress静态nginx规则高端网站优化公司