跳到主要内容

京都大学 情報学研究科 知能情報学専攻 2024年8月実施 専門科目 S-2

Author

itsuitsuki

Description

大学公表の原題

We consider a problem of classifying a three-dimensional vector, where a value of each element is either 0 or 1, into either the class 1 or the class 2. Let x=(x(1),x(2),x(3)){0,1}3\boldsymbol{x} = (x(1), x(2), x(3)) \in \{0, 1\}^3 be a vector. Assume that each element of x\boldsymbol{x} of the class y=ky=k (k{1,2}k \in \{1, 2\}) independently follows a Bernoulli distribution, and let p(x(j)=1y=k)=μ(k)(j)p(x(j) = 1 | y = k) = \mu^{(k)}(j) (0μ(k)(j)1, j{1,2,3}0 \le \mu^{(k)}(j) \le 1, \ j \in \{1, 2, 3\}) be the probability of x(j)=1x(j) = 1. Let μ(k)=(μ(k)(1),μ(k)(2),μ(k)(3))\boldsymbol{\mu}^{(k)} = (\mu^{(k)}(1), \mu^{(k)}(2), \mu^{(k)}(3)) be parameters of the class kk.

Let D={(x1,y1),(x2,y2),,(xN,yN)}\mathcal{D} = \{(\boldsymbol{x}_1, y_1), (\boldsymbol{x}_2, y_2), \dots, (\boldsymbol{x}_N, y_N)\} be a data set consisting of NN data. Let xi=(xi(1),xi(2),xi(3))\boldsymbol{x}_i = (x_i(1), x_i(2), x_i(3)) be the vector of the ii-th data, and yiy_i be the class of xi\boldsymbol{x}_i. We assume that xi (i{1,,n})\boldsymbol{x}_i \ (i \in \{1, \dots, n\}) of the class yi=ky_i = k is independently observed from the aforementioned distribution whose parameter is μ(k)\boldsymbol{\mu}^{(k)}.

(1) Let p(y=k)p(y = k) be a prior probability for the class kk. We determine an estimated class y^\hat{y} of x\boldsymbol{x} by comparing the posterior probabilities. Namely, we set y^=1\hat{y} = 1 if p(y=1x)p(y=2x)p(y = 1 | \boldsymbol{x}) \ge p(y = 2 | \boldsymbol{x}); otherwise we set y^=2\hat{y} = 2. Show a rule that assigns x\boldsymbol{x} to an estimated class y^\hat{y} by using p(y=k)p(y = k) and μ(k)(j)\mu^{(k)}(j).

(2) Let D(k)={(xi,yi)Dyi=k} (k{1,2})\mathcal{D}^{(k)} = \{(\boldsymbol{x}_i, y_i) \in \mathcal{D} \mid y_i = k\} \ (k \in \{1, 2\}) be a subset of the data set D\mathcal{D}. By using D(k)\mathcal{D}^{(k)}, derive the maximum likelihood estimate μ^(k)\hat{\boldsymbol{\mu}}^{(k)} of μ(k)\boldsymbol{\mu}^{(k)} from the data set D\mathcal{D}.

(3) Assume that a data set D\mathcal{D} is given in Table 1. Compute the values of the maximum likelihood estimates μ^(k) (k{1,2})\hat{\boldsymbol{\mu}}^{(k)} \ (k \in \{1, 2\}) from Table 1.

Table 1: A data set

iixi\boldsymbol{x}_iyiy_i
1(1,0,0)(1, 0, 0)1
2(1,0,1)(1, 0, 1)1
3(1,1,0)(1, 1, 0)2
4(0,1,0)(0, 1, 0)1
5(0,0,1)(0, 0, 1)2

(4) Let prior probabilities be p(y=1)=35p(y = 1) = \frac{3}{5} and p(y=2)=25p(y = 2) = \frac{2}{5}. Compute the estimated class y^\hat{y} of x=(1,1,1)\boldsymbol{x} = (1, 1, 1) by substituting μ^(k)\hat{\boldsymbol{\mu}}^{(k)} computed in (3) for μ(k)\boldsymbol{\mu}^{(k)} of the rule shown in (1).

(5) Let a prior probability p(y=1)p(y = 1) be q (0q1)q \ (0 \le q \le 1). We classify x=(1,1,1)\boldsymbol{x} = (1, 1, 1) by substituting μ^(k)\hat{\boldsymbol{\mu}}^{(k)} computed in (3) for μ(k)\boldsymbol{\mu}^{(k)} of the rule shown in (1). Explain the relation between qq and an estimated class y^\hat{y}.

题目描述

考虑把三维二元向量 x=(x(1),x(2),x(3))\boldsymbol{x}=(x^{(1)},x^{(2)},x^{(3)}) 分类到类别 y{1,2}y\in\{1,2\} 的问题。给定类别 kk 时,各分量相互独立且服从 Bernoulli 分布:

p(x(j)=1y=k)=μj(k),j=1,2,3.p(x^{(j)}=1\mid y=k)=\mu_j^{(k)},\qquad j=1,2,3.

现有数据集 D={(xi,yi)}\mathcal{D}=\{(\boldsymbol{x}_i,y_i)\},回答下列问题。

  1. 使用类别先验概率以及参数 μ(k)\boldsymbol{\mu}^{(k)},推导比较后验概率的分类规则;若两个类别的后验概率相同,则规定分类为类别 1。

  2. 对每一个类别的样本子集,推导各参数 μj(k)\mu_j^{(k)} 的最大似然估计量。

  3. 对下表数据计算两个类别的参数估计 μ^(1)\hat{\boldsymbol{\mu}}^{(1)}μ^(2)\hat{\boldsymbol{\mu}}^{(2)},并计算第(1)问所需的分类规则:

    iixi\boldsymbol{x}_iyiy_i
    1(1,0,0)(1,0,0)1
    2(1,0,1)(1,0,1)1
    3(1,1,0)(1,1,0)2
    4(0,1,0)(0,1,0)1
    5(0,0,1)(0,0,1)2
  4. 令先验概率 p(y=1)=35p(y=1)=\frac35p(y=2)=25p(y=2)=\frac25,把第(3)问求得的参数估计代入第(1)问的规则,求 x=(1,1,1)\boldsymbol{x}=(1,1,1) 的预测类别 y^\hat y

  5. 改令 p(y=1)=qp(y=1)=q,其中 0q10\leq q\leq1。仍使用第(3)问的参数估计对 x=(1,1,1)\boldsymbol{x}=(1,1,1) 分类,说明 qq 与预测类别 y^\hat y 之间的关系。

Kai

(1)

For k=1,2k=1,2, define the unnormalized posterior score

gk(x)=p(y=k)j=13{μ(k)(j),x(j)=1,1μ(k)(j),x(j)=0.g_k(\boldsymbol x)=p(y=k)\prod_{j=1}^3 \begin{cases} \mu^{(k)}(j),&x(j)=1,\\ 1-\mu^{(k)}(j),&x(j)=0. \end{cases}

When g1+g2>0g_1+g_2>0, Bayes' formula gives p(y=kx)=gk/(g1+g2)p(y=k\mid\boldsymbol x)=g_k/(g_1+g_2). Hence select class 11 if g1g2g_1\ge g_2, and class 22 otherwise. The product formulation also handles parameters 00 or 11 without taking logarithms of zero. If both scores vanish, the observation has zero model probability and its posterior is undefined; a classifier must specify a separate fallback rule.

(2)

Let Nk=D(k)>0N_k=|\mathcal D^{(k)}|>0 and akj=i:yi=kxi(j)a_{kj}=\sum_{i:y_i=k}x_i(j). The class likelihood factors as

Lk=j=13μ(k)(j)akj(1μ(k)(j))Nkakj.L_k=\prod_{j=1}^3\mu^{(k)}(j)^{a_{kj}} (1-\mu^{(k)}(j))^{N_k-a_{kj}}.

Each factor is maximized at

μ^(k)(j)=akjNk.\boxed{\hat\mu^{(k)}(j)=\frac{a_{kj}}{N_k}}.

This follows by differentiating the concave log-likelihood for 0<akj<Nk0<a_{kj}<N_k; all-zero or all-one observations give the endpoint maxima 00 or 11. If Nk=0N_k=0, the likelihood contains no information about that class's parameters, so every parameter vector maximizes it.

(3)

The class-1 samples are rows 1,2,41,2,4 and the class-2 samples are rows 3,53,5, giving

μ^(1)=(2/3,1/3,1/3),μ^(2)=(1/2,1/2,1/2).\boxed{\hat{\boldsymbol\mu}^{(1)}=(2/3,1/3,1/3),\qquad \hat{\boldsymbol\mu}^{(2)}=(1/2,1/2,1/2)}.

(4)

For x=(1,1,1)\boldsymbol x=(1,1,1),

g1=35227=245,g2=2518=120.g_1=\frac35\cdot\frac{2}{27}=\frac2{45}, \qquad g_2=\frac25\cdot\frac18=\frac1{20}.

Since g1<g2g_1<g_2, the answer is y^=2\hat y=2. The normalized posterior probabilities are 8/178/17 and 9/179/17.

(5)

The score comparison is

2q271q8q2743.\frac{2q}{27}\ge\frac{1-q}{8} \quad\Longleftrightarrow\quad q\ge\frac{27}{43}.

Thus y^=1\hat y=1 for 27/43q127/43\le q\le1, and y^=2\hat y=2 for 0q<27/430\le q<27/43. Equality belongs to class 11 by the specified tie rule.