2.5 Local Methods in High Dimensions
curse of dimensionality
- 输入在p维立方体中符合均匀分布,如果需要覆盖比例r的体积,需要每个维度上\(e_p(r)=r^{1/p}\)
\(e_{10}(0.01)=0.63,e_{10}(0.1)=0.8\) - 输入在p维立方体中负荷均匀分布,p=1时,1000个点达到的采样密度
在p=10时,需要\(1000^{10}\)个点才能达到
需要的数据量随维度增加幂增长 - 输入在p维单位球体中符合均匀分布,使用1-nearest neighbor预测0点的値
假设有N个训练数据,则这些点到0点距离的中値为
\(d(p,N)={(1-{(1/2)}^{1/N})}^{1/p}\)
$ d(10, 500) ≈ 0.52$
当维度高,数据量小时,最近邻离预测点往往比较远,所以得到的预测偏差大
证明:
p维,半径为r的球体体积为\(V_p(r)=\frac{\pi^{p/2}}{\Gamma(1+p/2)}r^p\)
N个点都在半径为d的球体外的概率为对应部分体积之比\(p(D>d)={(1-d^p)}^N\)
取\(p(D>d)=1/2\),\(d(p,N)={(1-{(1/2)}^{1/N})}^{1/p}\)
- 1000个训练数据均匀分布在\({[-1,1]}^p\)中,真实\(Y\)和\(X\)的关系,符合以下函数:
\(Y=f(X)=e^{-8{||x||}^2}\),使用1-nearest neighbor预测在0点的値
进行bias–variance decomposition
平均平方误差可以分成在训练集\(\tau\)上的方差,以及模型本身的偏差平方
p = 10时,99%的训练集最近邻离0点的距离都大于0.5
证明:
\(p(D>0.5)={\left(1-\frac{\frac{\pi^{10/2}}{\Gamma(1+10/2)}{0.5}^{10}}{2^{10}}\right)}^{1000}≈0.99757\)
import python
math.pow(1-math.pow(math.pi,5)/120/math.pow(4,10),1000)
figure2.7 **_bais占主要,因为最近邻离的远,函数中有距离项_**
而每次训练集采样,得到的最近邻离0点距离差别不大
figure2.8 将函数换成$f(X)={(X_1+1)}^3/2$,Y値只与第一个维度相关
'''
2.5<Local Methods in High Dimensions>
page 25(figure2.7),26(figure2.8)
function2.7 is f(x)=e^{-8||x||^2}
function2.8 is f(x)=(x_1+1)^3/2
x is uniformally distributed in [-1,1]^p ,p is the dimension
MSE,VARIANCE,BAIS is about f(0)
so for function2.7 f0=1
function2.8 f0=0.5
'''
import numpy as np
import matplotlib.pyplot as plt
def func2_7(X):
return np.array([np.exp(-8*np.dot(i,i)) for i in X])
def func2_8(X):
return np.array([np.power(i[0]+1,3)/2.0 for i in X])
def mse_var_bais(N,T,p,func1,f0):
X = np.zeros((T,p))
for i in range(T):
dt = np.random.uniform(-1,1,N*p).reshape((N,p))
st = [np.dot(j,j) for j in dt]
ind = (st==np.min(st))
#get the nearest neighbor
X[i,:] = dt[ind,:]
arr = func1(X)
mse = np.mean(np.power((arr - f0),2))
var = np.mean(np.power(arr - np.mean(arr),2))
bais = np.power(np.mean(arr)-f0,2)
return mse,var,bais
def getMSE_VAR_BAIS(N,T,f0,func1):
VAR = []
BAIS = []
MSE = []
for i in range(10):
mse,var,bais=mse_var_bais(N,T,i+1,func1,f0)
MSE.append(mse)
VAR.append(var)
BAIS.append(bais)
print i+1
return MSE,BAIS,VAR
#MSE,BAIS,VAR =getMSE_VAR_BAIS(N=1000,T=1000,f0=1,func1=func2_7)
MSE,BAIS,VAR =getMSE_VAR_BAIS(N=1000,T=1000,f0=0.5,func1=func2_8)
xa=[i+1 for i in range(10)]
plt.plot(xa,MSE,'ro-',label='MSE')
plt.plot(xa,BAIS,'bo-',label='sq. BAIS')
plt.plot(xa,VAR,'go-',label='VAR')
plt.legend(loc='upper left')
plt.show()
2.5 Local Methods in High Dimensions的更多相关文章
- 26 THINGS I LEARNED IN THE DEEP LEARNING SUMMER SCHOOL
26 THINGS I LEARNED IN THE DEEP LEARNING SUMMER SCHOOL In the beginning of August I got the chance t ...
- 反射01 Class类的使用、动态加载类、类类型说明、获取类的信息
0 Java反射机制 反射(Reflection)是 Java 的高级特性之一,是框架实现的基础. 0.1 定义 Java 反射机制是在运行状态中,对于任意一个类,都能够知道这个类的所有属性和方法:对 ...
- Microsoft.AspNet.SignalR 2.2
Nuget :http://www.nuget.org/packages/Microsoft.AspNet.SignalR/ What is SignalR? ASP.NET SignalR is a ...
- Spring Annotation Processing: How It Works--转
找的好辛苦呀 原文地址:https://dzone.com/articles/spring-annotation-processing-how-it-works If you see an annot ...
- REST vs SOAP
REST vs SOAP These information searched from internet most from stackoverflow. Simple explanation ab ...
- ABAP程序执行效率和优化 ABAP Performance Examples
一. SQL Interface1. Select ... Where vs. Select + Check用Select … Where语句效率比Select ...
- Introduction to SignalR -摘自网络
What is SignalR? ASP.NET SignalR is a library for ASP.NET developers that simplifies the process of ...
- Web Services and C# Enums -摘自网络
Web Service Transparency .NET support for web services is excellent in creating illusion of transpar ...
- C#基础拾遗系列之二:C#7.0新增功能点
第一部分: C#是一种通用的,类型安全的,面向对象的编程语言.有如下特点: (1)面向对象:c# 是面向对象的范例的一个丰富实现, 它包括封装.继承和多态性.C#面向对象的行为包括: 统一的类型系统 ...
随机推荐
- WPF笔记(1.4 布局)——Hello,WPF!
原文:WPF笔记(1.4 布局)--Hello,WPF! 这一节只是第2章的引子.布局要使用Panel控件,有四种Panel,如下:DockPanel,就是设置停靠位置布局模型.StackPanel, ...
- Linux系统编程(24)——信号的生命周期
信号生命周期为从信号发送到信号处理函数的执行完毕. 对于一个完整的信号生命周期(从信号发送到相应的处理函数执行完毕)来说,可以分为三个重要的阶段,这三个阶段由四个重要事件来刻画:信号诞生:信号在进程中 ...
- C语言的本质(31)——C语言与汇编之函数调用的本质
我们一段代码来研究函数调用的过程.首先我们写一段简单的小程序: int sum(int c, int d) { inte = c + d; returne; } int func(int a, int ...
- 【转】如何查看linux版本 如何查看LINUX是多少位
原文网址:http://sopace.blog.51cto.com/1227753/670526 如何得知自己正在使用的linux是什么版本呢,下面的几种方法将给你带来答案! 1. 查看内核版本命令: ...
- cf478D Red-Green Towers
D. Red-Green Towers time limit per test 2 seconds memory limit per test 256 megabytes input standard ...
- UESTC_男神的礼物 2015 UESTC Training for Dynamic Programming<Problem A>
A - 男神的礼物 Time Limit: 3000/3000MS (Java/Others) Memory Limit: 65535/65535KB (Java/Others) Submit ...
- A Bug's Life
#include<stdio.h> #include<string.h> ],num[]; int find(int x){ int r=x; while(r!=bug[r]) ...
- HDU 1559 最大子矩阵 (DP)
题目地址:pid=1559">HDU 1559 构造二维前缀和矩阵.即矩阵上的点a[i][j]表示左上方的点为(0,0),右下方的点为(i,j)的矩阵的和.然后枚举每一个矩阵的左上方的 ...
- SQLServer查询逻辑读最高的语句
select top 25 p.name as [SP Name], deps.total_logical_reads as [TotalLogicalReads], deps.total_logic ...
- NTP-ntpdate:no server suitable for synchronization found
NTP-ntpdate 问题处理 解决ntp的错误 no server suitable for synchronization found 当用ntpdate -d 来查询时会发现导致 no ser ...