机器学习中的数学公式第二次上课
第一次作业
习题1 定义无向网络.
Definition: A undirected net is a tuple G = ( V , w ) G=(\mathbf{V}, w) G=(V,w), where
- V \mathbf{V} V is the set of nodes;
-
w
w
w :
V
×
V
→
R
\mathbf{V}\times\mathbf{V}\to\mathbb{R}
V×V→R is the weight function where
- w ( ⟨ v i , v j ⟩ ) w(\lang v_i,v_j\rang) w(⟨vi,vj⟩) is the weight of the arc ⟨ v i , v j ⟩ \lang v_i,v_j\rang ⟨vi,vj⟩
- w ( ⟨ v i , v j ⟩ ) = w ( ⟨ v j , v i ⟩ ) w(\lang v_i,v_j\rang) = w(\lang v_j,v_i\rang) w(⟨vi,vj⟩)=w(⟨vj,vi⟩).
习题2. 自己画一棵树, 将其元组各部分写出来 (特别是函数
p
p
p).
T
=
(
V
,
r
,
p
)
T=(\mathbf{V},r,p)
T=(V,r,p)
V
=
{
v
0
,
v
1
,
…
,
v
4
}
V=\{v_0,v_1,\dots,v_4\}
V={v0,v1,…,v4}
r
=
v
0
r=v_0
r=v0
p
(
v
0
)
=
ϕ
p(v_0)=\phi
p(v0)=ϕ
p
(
v
1
)
=
v
0
p_(v_1)=v_0
p(v1)=v0
p
(
v
2
)
=
v
0
p_(v_2)=v_0
p(v2)=v0
p
(
v
3
)
=
v
1
p_(v_3)=v_1
p(v3)=v1
p
(
v
4
)
=
v
2
p_(v_4)=v_2
p(v4)=v2
- 针对该树, 将代码中的变量值写出来 (特别是 parent 数组).
原文章中的代码:
public class Tree {
/**
* 节点数. 表示节点 v_0 至 v_{n-1}.
*/
int n;
/**
* 根节点. 0 至 n-1.
*/
int root;
/**
* 父节点.
*/
int[] parent;
/**
* 构造一棵树, 第一个节点为根节点, 其余节点均为其直接子节点, 也均为叶节点.
*/
public Tree(int paraN) {
n = paraN;
parent = new int[n];
parent[0] = -1; // -1 即 \phi
}// Of the constructor
}//Of class Tree
变量值如下:
n = 5;
root = 0;
parent = {-1, 0, 0, 1, 2}
习题3 画一棵三叉树, 并写出它的 child 数组.
child数组:
{
{
1
,
2
,
−
1
}
,
{
3
,
4
,
5
}
,
{
−
1
,
−
1
,
−
1
}
,
{
−
1
,
−
1
,
−
1
}
,
{
−
1
,
−
1
,
−
1
}
,
{
−
1
,
−
1
,
−
1
}
}
\{\{1,2,-1\}, \{3,4,5\},\{-1,-1,-1\},\{-1,-1,-1\},\{-1,-1,-1\},\{-1,-1,-1\}\}
{{1,2,−1},{3,4,5},{−1,−1,−1},{−1,−1,−1},{−1,−1,−1},{−1,−1,−1}}
- 按照本贴风格, 重新定义树. 提示: 还是应该定义 parent 函数, 字母表里面只有一个元素.
Let ϕ \phi ϕ be the empty node, a tree is a quadruple T = ( V , r , Σ , p ) T=(\mathbf{V},r,\Sigma,p) T=(V,r,Σ,p) where
- V ≠ ∅ \mathbf{V} \neq \emptyset V=∅ is the set of nodes;
- r ∈ V r\in \mathbf{V} r∈V is the root node;
- Σ = { t o p } \Sigma=\{\mathrm{top}\} Σ={top};
-
p
:
V
→
V
∪
{
ϕ
}
p:\mathbf{V}\to\mathbf{V}\cup\{\phi\}
p:V→V∪{ϕ} is the parent mapping satisfying
- when v = r v=r v=r, ∃ ! s ∈ Σ \exists!s\in \Sigma ∃!s∈Σ , st. p ( r , s ) = ϕ p(r,s)=\phi p(r,s)=ϕ;
- ∀ v ∈ V , ∃ ! n ≥ 0 \forall v\in \mathbf{V},\exists!n\geq 0 ∀v∈V,∃!n≥0 and ! s ∈ Σ !s\in \Sigma !s∈Σ, st. p ( n ) ( v , s ) = r p^{(n)}(v,s)=r p(n)(v,s)=r.
说明:
- 根据图、树、 m m m-叉树的学习, 谈谈你对元组的理解.
我认为元组实际上就是数据与数据关系的一个组合体。
第二次作业
习题1 定义一个标签分布系统, 即各标签的值不是 0/1, 而是 [ 0 , 1 ] [0,1] [0,1] 区间的实数, 且同一对象的标签和为 1.
Definition. A label distribution system is a tuple S = ( X , Y ) S = (\mathbf{X},\mathbf{Y}) S=(X,Y) where
- X = [ x i j ] n × m ∈ R n × m \mathbf{X} = [x_{ij}]_{n\times m} \in \mathbb{R}^{n\times m} X=[xij]n×m∈Rn×m is the data matrix;
-
Y
=
[
y
i
k
]
n
×
l
∈
[
0
,
1
]
n
×
l
\mathbf{Y} = [y_{ik}]_{n\times l}\in [0,1]^{n\times l}
Y=[yik]n×l∈[0,1]n×l is the label matrix, satisfying
- ∀ y i ∈ Y \forall y_i \in \mathbf{Y} ∀yi∈Y, st. ∑ k = 1 l y i k = 1 \sum_{k=1}^{l} y_{ik}=1 ∑k=1lyik=1
- n n n is the number of instances;
- m m m is the number of features;
- l l l is the number of labels,