机器学习(六) — 评估模型

Evaluate model

1 test set

  1. split the training set into training set and a test set
  2. the test set is used to evaluate the model

1. linear regression

compute test error

J t e s t ( w ⃗ , b ) = 1 2 m t e s t ∑ i = 1 m t e s t [ ( f ( x t e s t ( i ) ) − y t e s t ( i ) ) 2 ] J_{test}(\vec w, b) = \frac{1}{2m_{test}}\sum_{i=1}^{m_{test}} \left [ (f(x_{test}^{(i)}) - y_{test}^{(i)})^2 \right ] Jtest(w ,b)=2mtest1i=1∑mtest[(f(xtest(i))−ytest(i))2]

2. classification regression

compute test error

J t e s t ( w ⃗ , b ) = − 1 m t e s t ∑ i = 1 m t e s t [ y t e s t ( i ) l o g ( f ( x t e s t ( i ) ) ) + ( 1 − y t e s t ( i ) ) l o g ( 1 − f ( x t e s t ( i ) ) ] J_{test}(\vec w, b) = -\frac{1}{m_{test}}\sum_{i=1}^{m_{test}} \left [ y_{test}^{(i)}log(f(x_{test}^{(i)})) + (1 - y_{test}^{(i)})log(1 - f(x_{test}^{(i)}) \right ] Jtest(w ,b)=−mtest1i=1∑mtest[ytest(i)log(f(xtest(i)))+(1−ytest(i))log(1−f(xtest(i))]

2 cross-validation set

  1. split the training set into training set, cross-validation set and test set
  2. the cross-validation set is used to automatically choose the better model, and the test set is used to evaluate the model that chosed

3 bias and variance

  1. high bias: J t r a i n J_{train} Jtrain and J c v J_{cv} Jcv is both high
  2. high variance: J t r a i n J_{train} Jtrain is low, but J c v J_{cv} Jcv is high
  1. if high bias: get more training set is helpless
  2. if high variance: get more training set is helpful

4 regularization

  1. if λ \lambda λ is too small, it will lead to overfitting(high variance)
  2. if λ \lambda λ is too large, it will lead to underfitting(high bias)

5 method

  1. fix high variance:
    • get more training set
    • try smaller set of features
    • reduce some of the higher-order terms
    • increase λ \lambda λ
  2. fix high bias:
    • get more addtional features
    • add polynomial features
    • decrease λ \lambda λ

6 neural network and bias variance

  1. a bigger network means a more complex model, so it will solve the high bias
  2. more data is helpful to solve high variance
  1. it turns out that a bigger(may be overfitting) and well regularized neural network is better than a small neural network
相关推荐
阿杰学AI几秒前
AI核心知识69——大语言模型之SSM (简洁且通俗易懂版)
人工智能·ai·语言模型·自然语言处理·aigc·ssm·状态空间模型
奔跑草-3 分钟前
【AI日报】每日AI最新消息2026-01-28
人工智能·目标检测·机器学习·计算机视觉·产品经理
罗政5 分钟前
AI提取一批Excel单元格内容(快递信息)数据安全,支持断网提取
人工智能·excel
Serverless 社区6 分钟前
探秘 AgentRun丨动态下发+权限隔离,重构 AI Agent 安全体系
人工智能·安全·重构
光羽隹衡7 分钟前
计算机视觉--Opencv(郁金香图像轮廓提取与多边形逼近)
人工智能·opencv·计算机视觉
星海之恋99210 分钟前
比官方便宜一半以上!Midjourney API 申请及使用
人工智能·midjourney
机器学习算法与Python实战11 分钟前
DeepSeek-OCR-2 本地部署,实测
人工智能·ocr
布谷鸟科技cookoo12 分钟前
布谷鸟科技携AI边缘计算产品线亮相韩国ROSCon KOREA 2026
人工智能·科技·ai·边缘计算·交通物流
小雨青年12 分钟前
鸿蒙 HarmonyOS 6 | AI Kit 集成 CANN Kit 异构计算服务
人工智能·华为·harmonyos
AI浩13 分钟前
Python包离线下载
开发语言·人工智能·python·目标检测