跳到主要内容

東京大学 情報理工学系研究科 創造情報学専攻 2017年8月実施 筆記試験 第1問

Author

tomfluff, 祭音Myyura, itsuitsuki

Description

A data set SS including eight data is given as in Figure 1. Each datum is in the form of (x1,x2,x3,x4,y){0,1}5(x_1, x_2, x_3, x_4, y) \in \{0, 1\}^5. Below we consider how to construct a rule from SS for classifying x=(x1,x2,x3,x4)\boldsymbol{x} = (x_1, x_2, x_3, x_4) into y=1y = 1 or y=0y = 0. Answer the following questions.

Figure 1: Data set

ttx1x_1x2x_2x3x_3x4x_4yy
110011
211001
310111
401101
500110
600100
700010
811100

(1) Let us consider the code-length required for encoding a binary string z=z1,,znz = z_1, \dots, z_n of length nn (zi{0,1},i=1,,nz_i \in \{0, 1\}, i = 1, \dots, n). In general, for a finite set GG, the code-length required for encoding one element gGg \in G is given by logG\log |G| (bit), where the logarithm is to the base 2. Show that, for a binary string zz of length nn in which the number of occurrences of 11 is kk, the code-length required for encoding zz and kk itself is at most:

log(n+1)+log nCk (bit),\begin{align} \log(n + 1) + \log \ _nC_k \text{ (bit),} \tag{1} \end{align}

where the value of the number nn is given in advance and the code-length can be non-integer valued.

Below the value of Eq.(1) for zz is denoted as L(z)L(z).

(2) Let the probability of y=1y = 1 for a datum with x1=1x_1 = 1 be θ\theta. Then calculate the least squares estimate of θ\theta from Figure 1. The least squares estimate of θ\theta is the value of θ\theta that minimizes t:x1=1(y(t)θ)2\sum_{t:x_1=1} (y(t) - \theta)^2 where y(t)y(t) denotes the value of yy for the tt-th datum and t:x1=1\sum_{t:x_1=1} denotes the sum taken over all the data such that x1=1x_1 = 1.

(3) Let yy be a binary string obtained by concatenating the values of yy for all the data in SS in Figure 1. Let y1(i)y^{(i)}_1 be a binary string obtained by concatenating the values of yy for all the data in SS such that xi=1x_i = 1 and let y0(i)y^{(i)}_0 be a binary string obtained by concatenating the values of yy for all the data in SS such that xi=0x_i = 0 (i=1,2,3,4i = 1, 2, 3, 4). For example, the indexes of data in SS such that x1=1x_1 = 1 are 11, 22, 33, 88, so the binary string obtained by concatenating the values of yy corresponding to them is y1(1)=1110y^{(1)}_1 = 1110. We define the measure of goodness of classifying data by partitioning SS based on whether xi=1x_i = 1 or xi=0x_i = 0 as follows:

Δ(iy)=defL(y1(i))+L(y0(i))(i=1,2,3,4).\begin{align} \Delta(i|y) \overset{\text{def}}{=} L(y^{(i)}_1) + L(y^{(i)}_0) \quad (i = 1, 2, 3, 4). \tag{2} \end{align}

We consider that the smaller the value of Eq.(2) is, the more the value of xix_i contributes to the classification of yy. Find ii that minimizes Δ(iy)\Delta(i|y). Hereinafter, when there are more than one xix_i’s that minimize the value of Eq.(2), one is chosen randomly from among them.

(4) Let the value of ii obtained in Question (3) be ii^*. SS is partitioned into two sets according to whether xi=1x_{i^*} = 1 or xi=0x_{i^*} = 0, then yy is also partitioned into two strings: y1(i)y^{(i^*)}_1 and y0(i)y^{(i^*)}_0. It can be represented using a tree structure as shown in Figure 2. We call it a partitioning tree. We call y1(i)y^{(i^*)}_1 and y0(i)y^{(i^*)}_0 partitioned strings. We further partition each of y1(i)y^{(i^*)}_1 and y0(i)y^{(i^*)}_0, by finding i (i)i \ (\neq i^*) minimizing Δ(iy1(i))\Delta(i|y^{(i^*)}_1) and minimizing Δ(iy0(i))\Delta(i|y^{(i^*)}_0), respectively. Let this partitioning of a leaf be repeated until the following stopping rule is fulfilled: The depth of a leaf (the number of partitionings from the root to the leaf) is two, or the partitioned string arriving at a leaf is all y=1y = 1 or all y=0y = 0. Find the partitioning tree that is finally obtained.

(5) For the resulting partitioning tree, for a partitioned string arriving at each leaf, we assign y=1y = 1 to the leaf if the number of occurrences of y=1y = 1 in this string is larger than that of y=0y = 0, and assign y=0y = 0 to the leaf if the number of occurrences of y=1y = 1 is smaller than that of y=0y = 0. When the number of occurrences of y=1y = 1 is the same as that of y=0y = 0, we assign randomly y=1y = 1 or y=0y = 0 to the leaf. This tree can be used for predicting the value of yy for any new datum. That is, when (x1,x2,x3,x4)(x_1, x_2, x_3, x_4) in the new datum is given
and arrives at a leaf, the tree predicts the value of its corresponding yy as the value of yy assigned to the leaf. Here, even if we change the stopping rule in Question (4) to construct a larger tree from a training data set SS so that the values of yy for data reaching at each leaf are all y=1y = 1 or all y=0y = 0, such a tree doesn’t necessarily predict the value of yy for a new datum with higher accuracy. Explain the reason.

(6) Consider a general case where for a positive integer d2d \geq 2, a set SS of multi-dimensional data in the form of (x1,,xd,y){0,1}d+1(x_1, \dots, x_d, y) \in \{0, 1\}^{d+1} and a partitioning tree T\mathcal{T} are given. Let M\mathcal{M} be a set of all subtrees which share the root of T\mathcal{T} and are obtained by pruning T\mathcal{T} starting
from its leaves. We define the following penalized criterion for evaluating the goodness of a subtree MMM \in \mathcal{M} for the given SS:

NL(M)CL+NI(M)CI+uL(yu),\begin{align} N_L(M) C_L + N_I(M) C_I + \sum_u L(y_u), \tag{3} \end{align}

where NL(M)N_L(M) is the total number of leaves in MM and NI(M)N_I(M) is the total number of inner nodes in MM. CLC_L and CIC_I are given positive constants. The sum in the third term in Eq.(3) is taken over all the leaves {u}\{u\} in MM and yuy_u is the binary string obtained by concatenating the values of yy for all the data which reach the leaf uu. The smaller the value of Eq.(3) is, the better MM is. Give an algorithm that finds MM minimizing the criterion Eq.(3) from M\mathcal{M} and SS, and runs as efficiently as possible in computation time.

题目描述

给定含 8 条数据的数据集 SS,每条为 (x1,x2,x3,x4,y){0,1}5(x_1,x_2,x_3,x_4,y)\in\{0,1\}^5,目标是学习把 x=(x1,x2,x3,x4)\boldsymbol x=(x_1,x_2,x_3,x_4) 分类为 y=0y=011 的规则:

ttx1x_1x2x_2x3x_3x4x_4yy
110011
211001
310111
401101
500110
600100
700010
811100
  1. 对长度为 nn 的二进制串 z=z1,,znz=z_1,\ldots,z_n,一般从有限集合 GG 编码一个元素需 log2G\log_2|G| 比特。若 zz 中有 kk 个 1,证明在 nn 已知且码长可非整数时,编码 zz 连同 kk 所需码长至多为

    log(n+1)+log(nk).(1)\log(n+1)+\log {n\choose k}. \tag{1}

    以后把式 (1) 的值记为 L(z)L(z)

  2. 设在 x1=1x_1=1 的数据中 y=1y=1 的概率为 θ\theta。由表中数据求使

    t:x1=1(y(t)θ)2\sum_{t:x_1=1}(y(t)-\theta)^2

    最小的 θ\theta

  3. SS 中所有 yy 依次连接为二进制串 yy。对 i=1,2,3,4i=1,2,3,4,分别把满足 xi=1x_i=1xi=0x_i=0 的数据之 yy 连接为 y1(i),y0(i)y_1^{(i)},y_0^{(i)};例如 x1=1x_1=1 的数据编号是 1、2、3、8,所以 y1(1)=1110y_1^{(1)}=1110。定义按 xix_i 划分的指标

    Δ(iy)=L(y1(i))+L(y0(i)).(2)\Delta(i\mid y)=L(y_1^{(i)})+L(y_0^{(i)}). \tag{2}

    指标越小,认为 xix_i 对分类贡献越大。求使其最小的 ii;如有并列,随机选一个。

  4. 记第 3 问结果为 ii^*,按 xix_{i^*}SSyy 分成两支,形成原文图 2 的划分树。对每个叶中的串,再从 iii\ne i^* 中选择使相应 Δ\Delta 最小的特征继续划分。反复执行,直到叶深度(从根起的划分次数)达到 2,或到达叶的 yy 串全为 1 或全为 0。画最终划分树。

  5. 对每个叶,若其串中 1 多于 0 就赋标签 1,少于则赋 0,相等时随机赋 0 或 1;新样本按特征走到叶后预测该标签。解释为何把停止规则改为继续扩树、直到训练数据每个叶都纯为 0 或纯为 1,并不一定提高新数据预测精度。

  6. 一般地,SS 中数据为 (x1,,xd,y){0,1}d+1(x_1,\ldots,x_d,y)\in\{0,1\}^{d+1}d2d\ge2,给定划分树 T\mathcal T。令 M\mathcal M 为从叶向上剪枝得到且与 T\mathcal T 共根的所有子树。对子树 MM 定义

    NL(M)CL+NI(M)CI+uL(yu),(3)N_L(M)C_L+N_I(M)C_I+\sum_uL(y_u), \tag{3}

    其中 NL,NIN_L,N_I 分别为叶数、内部结点数,CL,CI>0C_L,C_I>0 已知;和遍历所有叶 uuyuy_u 是到达该叶的数据标签串。值越小越好。给出尽可能高效地从 M\mathcal M 中求式 (3) 最小子树的算法。

Kai

(1) - By Myyura

The notation nCk_nC_k usually represents "n choose k".

For a fixed nn and kk, the total number of possible binary strings that satisfy these conditions is given by the binomial coefficient (nk)\binom{n}{k}, i.e. nCk_nC_k.

To uniquely identify any of these strings, we need a code of length:

log(nk)\log \binom{n}{k}

The length nn should be included as part of the encoded message, hence the total encoding length is:

log(n+1)+log(nk) (bit),(1)\log(n + 1) + \log \binom{n}{k} \text{ (bit),} \tag{1}

(2) - By tomfluff

Let us fine a θ\theta such that the least squares is minimized. Let us denote least squares as f(θ)f(\theta ).

f(θ)=t:x1=1(y(t)θ)2f(\theta )=\sum_{t:x_1=1}(y(t) - \theta )^2
f(θ)=(1θ)2+(1θ)2+(1θ)2+(0θ)2f(\theta )=(1 - \theta )^2+(1 - \theta )^2+(1 - \theta )^2+(0 - \theta )^2
f(θ)=3(1θ)2+(θ)2f(\theta )=3(1 - \theta )^2+(- \theta )^2
f(θ)=6+6θ+2θ=0f'(\theta )=-6+6\theta +2\theta = 0
8θ=6θ=34\Rightarrow 8\theta = 6 \Rightarrow \theta=\frac{3}{4}

Therefore, when θ=34\theta = \frac{3}{4} the least squares function is minimized.

(3) - By itsuitsuki

  • Δ(1y)=4+2log5\Delta(1|y)=4+2\log 5
  • Δ(2y)=4+log5+2log3\Delta(2|y)=4+\log 5+2\log 3
  • Δ(3y)=4+log5+2log3\Delta(3|y)=4+\log 5+2\log 3
  • Δ(4y)=2+2log5+2log3\Delta(4|y)=2+2\log 5+2\log 3 Hence i=1i=1 minimizes Δ(iy)\Delta(i|y).

(4) - By tomfluff

Note: Any mistakes here are derived from the issues with (1) mentioned before.

(5)

In machine learning there are the concepts of bias and variance. The bias indicates how much the generated prediction function fits the relationships between the data and the prediction. And variance indicates how much the prediction function fits "new" data (testing data). When the prediction function fits the training data too well it is called "over fitting" and over fitting leads to low bias but high variance. In the mentioned case, extending the tree would result in over fitting the prediction function to the data set. Meaning that on new data the variance will be large and it will not improve the overall prediction.

(6) - by Gemini

The algorithm will work as Cost-Complexity Pruning. Tomfluff (the previous solution provider in this problem) misrecognizes this as a Minimum Error Pruning technique which is different. Similar pruning algorithms include PEP (Pessimistic Error Pruning), etc.

The algorithm is dynamic programming:

  1. Post-order traverse every node;
  2. For each internal node uu, we can choose to
    1. Prune the node into a leaf with contribution to criterion Costprune(u)=CL+L(all data under u)\text{Cost}_{\text{prune}}(u) = C_L + L(\text{all data under }u)
    2. Keep the subtree rooted at uu with contribution $\text{Cost}{\text{keep}}(u) = C_I + \sum{v\in \text{children}(u)} \text{Cost}_{\min}(u)
  3. Choose a minimum-contribution action with Costmin(u)=min(Costprune(u),Costkeep(u))\text{Cost}_{\min}(u) = \min(\text{Cost}_{\text{prune}}(u), \text{Cost}_{\text{keep}}(u)). When pruning, mark this subtree rooted at uu as a leaf.

Since in this DP, all nodes are traversed and computed for at once, the time complexity is O(T)O(|\mathcal T|).