
http://www.ma-xy.com
1.1 机器学习基本模型 第一章 神经网络
因变量 y 可能的分布有许多种,如果 y 取值为实数,可以假定其分布为正态分布,如果 y
取值为 0, 1, 2, ... 非负整数,可以假定其分布为 poisson 分布,如果 y 取值为正数,可以假定其分
布为逆高斯分布或者 gamma 分布,如果 y 取值为 0, 1,或者 0, 1, 2, 3(即分类型数据),则可以假
定其分布为二项分布。对于不同的分布,我们可以设置不同的 link(链接) 函数 f ,即便对于同一
种分布,也可以设置不同的链接函数。MATLAB 中支持的因变量分布类型如表 (1.1) 所示
表 1.1: 因变量类型及假设分布
Response(y) Data Type Suggested Model Distribution Type
Any real number ’normal’
Any positive number ’gamma’ or ’inverse gaussian’
Any nonnegative integer ’poisson’
Integer from 0 to n ’binomial’
对不同的假设分布类型,可选用的 link 函数如表 (1.2) 所示
表
1.2:
假设分布及链接函数
Value Description
’comploglog’ log(–log((1–µ))) = Xb
’identity’, default for the distribution ’normal’ µ = Xb
’log’, default for the distribution ’poisson’ log(µ) = Xb
’logit’, default for the distribution ’binomial’ log(µ/(1–µ)) = Xb
’loglog’ log(–log(µ)) = Xb
’probit’ Φ
–1
(µ) = Xb,Φ 是正态分布函数
’reciprocal’, default for the distribution ’gamma’ µ
–1
= Xb
p (a number), default for the distribution ’inverse gaus-
sian’ (with p = –2)
µ
p
= Xb
MATLAB 示例如下
1 x = [2100 2300 2500 2700 2900 . . .
2 3100 3300 3500 3700 3900 4100 4 3 00 ] ’ ;
3 n = [ 4 8 42 31 34 31 21 23 23 21 16 17 2 1 ] ’ ;
4 y = [ 1 2 0 3 8 8 14 17 19 15 17 2 1 ] ’ ;
5 % 构 建 pro b i t 回 归
6 g = f i t gl m (x , [ y n ] , . . .
7 ’ l in ea r ’ , ’ d is tr ’ , ’ binomial ’ , . . .
8 ’ l i nk ’ , ’ pr o b it ’ )
9 % 自 定 义 p r o bit 回 归 的 链 接 l i nk 函 数 s
10 s = {@norminv ,@(x ) 1. / normpdf (norminv (x) ) , @normcdf };
11 g = f i t gl m (x , [ y n ] , . . .
12 ’ l in ea r ’ , ’ d is tr ’ , ’ binomial ’ , ’ l i nk ’ , s )
13
http://www.ma-xy.com 14 http://www.ma-xy.com