l2约束的最小二乘学习法

简介: ℓ2\ell_{2}constrained least squares In the simple least squares, noisy samples may lead to overfitting learning output. Therefore, it is rational to constrain the space of parameters. We

2constrained least squares
In the simple least squares, noisy samples may lead to overfitting learning output. Therefore, it is rational to constrain the space of parameters.
We will focus on the simplest case - 2 constrained least squares in this note, i.e.

minθJLS(θ),s.t.θ2R

In order to the solve the aforesaid optimal problem, using Lagrangian dual problem, we can utilize the following optimal problem:
maxλminθ[JLS(θ)+λ2(θ2R)]

A brief review of Lagrangian dual problem can be found in the bottom of the note.
However, it is not necessary to define a R to constrained λ, then we can solve the estimated θ as
θ^=argminθ[JLS(θ)+λ2θ2]

where the first term JLS(θ) represents the fitting level which is combined by λ2θ2 to prevent overfitting to some degree.
Taking the partial difference of [JLS(θ)+λ2θ2 and seting it to be zero, we get the solution
θ^=(ΦTΦ+λI)1ΦTy

A more general method involves a regularizer G:
minθJLS(θ)s.t.θTGθR
and
θ^=(ΦTΦ+λG)1ΦTy

Ex: The Guassian Kernal Model

fθ(x)=j=1nθjK(x,xj),K(x,c)=exp(xc22h2)
The MATLAB codes go as follows:
n=50; N=1000;
x=linspace(-3,3,n)'; X=linspace(-3,3,n)';
pix=pi*x; y=sin(pix)./(pix)+0.1*x+0.2*randn(n,1);

x2=x.^2; X2=X.^2; hh=2*0.3^2; l=0.1;
k=exp(-(repmat(x2,1,n)+repmat(x2',n,1)-2*x*x')/hh);
K=exp(-(repmat(X2,1,n)+repmat(x2',N,1)-2*X*x')/hh);
t1=k\y; F1=K*t1; t2=(k^2+l*eye(n))\(k*y); F2=K*t2;

figure(1); clf; hold on; axis([-2.8,2.8,-1,1.5]);
plot(X,F1,'g-');plot(X,F2,'r--');plot(x,y,'bo');
legend('LS','L2-Constrained LS');

Appendix Lagrangian Dual Problem
Given differentiable convex function f:RdR and g:RdRp, a optimal problem can be formulated as

mintf(t),s.t.g(t)0

Let
λ=(λ1,,λp)T
be the Lagrangian multiplier.
Let
L(t,λ)=f(t)+λTg(t)
be the Lagrangian function.
Then the aforementioned optimal problem can be defined as
maxλinftL(t,λ),s.t.λ0

That’s the Lagrangian dual problem. We can get the same t by solving it.
相关文章
|
Python
【Python】已解决:(Python写入Excel表格报错)‘NoneType’ object has no attribute ‘write’
【Python】已解决:(Python写入Excel表格报错)‘NoneType’ object has no attribute ‘write’
970 0
|
存储 安全 Go
深入学习Go语言GMP模型
Go语言作为一门并发编程友好的语言,采用了一种称为GMP模型的并发模型来实现高效的并发执行。GMP模型是Go语言运行时系统的核心组成部分,它负责管理goroutine的创建、调度和执行。本文将深入学习Go语言的GMP模型,包括其原理、组件和调度策略,并通过代码示例和解读来帮助读者更好地理解和应用GMP模型。
872 0
|
存储 安全 Java
泛型+通配符(数学角度)
泛型+通配符(数学角度)
145 0
|
SQL 存储 分布式数据库
实践教程之PolarDB-X分区管理
PolarDB-X 为了方便用户体验,提供了免费的实验环境,您可以在实验环境里体验 PolarDB-X 的安装部署和各种内核特性。除了免费的实验,PolarDB-X 也提供免费的视频课程,手把手教你玩转 PolarDB-X 分布式数据库。本期实验将指导您如何进行PolarDB-X分区管理。
|
测试技术 uml
【总结】UML九种图
【总结】UML九种图
282 0
【总结】UML九种图
|
缓存 网络协议 关系型数据库
max_connect_errors参数
一次ERROR 1129 (HY000): Host 'xxx.xxx.xxx.xxx' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'报错,重新认识max_connect_errors参数。
2408 0