原文地址:https://www.jianshu.com/p/3f7d4aa6a7cf 问题描述 程序实现 # coding: utf-8 import numpy as np import math import matplotlib.pyplot as plt def sign(x): if(x>=0): return 1 else: return -1 def read_data(dataFile): with open(dataFile,'r') as f: lines=f.readli…
一.正则化的假设集合 通过从高次多项式的H退回到低次多项式的H来降低模型复杂度, 以降低过拟合的可能性, 如何退回? 通过加约束条件: 如果加了严格的约束条件, 没有必要从H10退回到H2, 直接使用H2就可以了. 加上松弛点的约束条件, 使得模型比H2复杂, 但到不了H10那么复杂. 二.权重衰减正则化 通过拉格朗日乘子法处理带约束的优化问题, 只看谷的话,需沿着梯度反方向下降到谷底; 只看超球面的话,需沿着垂直于法向量的方向滚; 判断当前W是否是最优解就看它能否在超球面上的同时还能向更接近谷…
原文地址:http://www.jianshu.com/p/5b4a64874650 问题描述 程序实现 # coding: utf-8 import numpy as np import matplotlib.pyplot as plt import time def read_data(dataFile): with open(dataFile, 'r') as file: data_list = [] for line in file.readlines(): line = line.st…
原文地址:http://www.jianshu.com/p/4bc01760ac20 问题描述 程序实现 17-18 # coding: utf-8 import numpy as np import matplotlib.pyplot as plt def sign(n): if(n>0): return 1 else: return -1 def gen_data(): data_X=np.random.uniform(-1,1,(20,1))# [-1,1) data_Y=np.zeros…
原文地址:http://www.jianshu.com/p/311141f2047d 问题描述 程序实现 13-15 # coding: utf-8 import numpy as np import numpy.random as random import matplotlib.pyplot as plt def sign(x): if(x>=0): return 1 else: return -1 def gen_data(): x1=random.uniform(-1,1,1000) x…
一.模型选择问题 如何选择? 视觉上 NO 不是所有资料都能可视化;人脑模型复杂度也得算上. 通过Ein NO 容易过拟合;泛化能力差. 通过Etest NO 能保证好的泛化,不过往往没法提前获得测试资料. 折中: 将样本资料分为两部分,一部分用作训练,一部分用作验证. 二.验证 利用验证集的模型选择: 利用所有训练数据训练所有模型,得出各个模型下的最优假设; 计算验证数据在各个模型最优假设下的代价值,选择最小代价值的模型; 利用全部样本数据训练选出来的模型,得到最优假设. 如何选择K? 通常,…
泛化能力差和过拟合: 引起过拟合的原因: 1)过度VC维(模型复杂度高)------确定性噪声: 2)随机噪声: 3)有限的样本数量N. 具体实验来看模型复杂度Qf/确定性噪声.随机噪声sigma2.样本数量N对过拟合的影响: 尽量避免过拟合: 1)从简单模型开始:降低模型复杂度: 2)data cleaning/data pruning:去noise: 3)data hinting(线索):增加样本数量: 4)regularization:正则化: 5)validation:验证.…
Lecture7 Regularization 正则化 7.1 过拟合问题 The Problem of Overfitting7.2 代价函数 Cost Function7.3 正则化线性回归  Regularized Linear Regression7.4 正则化的逻辑回归模型 Regularized Logistic Regression 7.1 过拟合问题 The Problem of Overfitting 参考视频: 7 - 1 - The Problem of Overfitti…
机器学习分为四步: When Can Machine Learn? Why Can Machine Learn? How Can Machine Learn? How Can Machine Learn Better? 一.What is Machine Learning Q:什么是“学习”? A:学习就是人类通过观察.积累经验,掌握某项技能或能力.就好像我们从小学习识别字母.认识汉字,就是学习的过程. 机器学习(Machine Learning),顾名思义,就是让机器(计算机)也能向人类一样,…