吴恩达机器学习六

评估假设

将数据集分为两部分,一部分为训练集70%,另一部分为测试集30%。选择时最好保证其随机性

典型算法

  • 首先使用训练集训练出结果
  • 使用测试集对结果进行测试。
    • 回归问题:Jtest(θ)=12mtesti=1mtest(hθ(xtesti)ytesti)2J_{test}(\theta)=\frac{1}{2m_{test}}\sum^{m_{test}}_{i=1}(h_\theta(x^i_{test})-y^i_{test})^2
    • 分类问题:Jtest(θ)=1mtesti=1mtest(ytestilog(hθ(xtesti))+(1ytesti)log(hθ(xtesti)))J_{test}(\theta)=-\frac{1}{m_{test}}\sum^{m_{test}}_{i=1}(y^i_{test}log(h_\theta(x^i_{test}))+(1-y^i_{test})log(h_\theta(x^i_{test})))