8月3日课后作业
1.写出本例中的 U,C,D和V\mathbf{U}, \mathbf{C}, \mathbf{D}和 \mathbf{V}U,C,D和V。注: 最后两个属性为决策属性
答:U={x1,x2,x3,x4,x5,x6,x7}\mathbf{U}=\{x_1,x_2,x_3,x_4,x_5,x_6,x_7 \}U={x1,x2,x3,x4,x5,x6,x7} is the set of instances;
C=\mathbf{C}=C={\{{Yes, No, High, Normal, LOw}\}} is the set of conditions attributes;
D=\mathbf{D}=D={\{{ Normal, Abnormal, Yes, No}\}} is the set of decisional attributes;
V=⋃a∈C∪DVa\mathbf{V}=\bigcup_{a\in \mathbf{C}\cup\mathbf{D}}\mathbf{V}_aV=⋃a∈C∪DVa
Va\mathbf{V}_aVa is the domain of a∈C∪Da \in \mathbf{C} \cup \mathbf{D}a∈C∪D
2.定义一个标签分布系统, 即各标签的值不是 0/1, 而是 [0,1][0, 1][0,1]区间的实数, 且同一对象的标签和为 1.
答:Definition 1. A label distribution system is a tuple S=(X,Y),whereS=(\mathbf{X},\mathbf{Y}),whereS=(X,Y),where
- X=[xij]n×m∈Rn×m\mathbf{X}=[x_{ij}]_{n\times m}\in \R^{n \times m}X=[xij]n×m∈Rn×mis the data matrix;
- Y=[yik]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
- ∀yi⊂Y,∑t=1lyit=1\forall y_i \subset \mathbf{Y},\sum_{t=1}^l y_{it}=1∀yi⊂Y,∑t=1lyit=1
- nnn is the number of instances;
- mmm is the number of features;
- lll is the number of distribution labels.
8月2日课后作业
作业一
1.写出该无向图的邻接矩阵.
答:E=[0111101011011010]\mathbf{E}= \left[ \begin{matrix}0 &1&1&1\\ 1&0&1&0\\ 1&1&0&1\\ 1&0&1&0\end{matrix}\right]E=⎣⎢⎢⎡0111101011011010⎦⎥⎥⎤
2.定义无向网络.
答:Definition 1. An undirected net is a tuple G=(V,w),G=(\mathbf{V},w),G=(V,w),where
- V≠∅\mathbf{V} \neq \emptysetV=∅ is the set of nodes,
- w:V×V→Rw:\mathbf{V} \times \mathbf{V} \to \Rw:V×V→R is the weight function where w(vi,vj)w(v_i,v_j)w(vi,vj)is the weight of the arc⟨vi,vj⟩\lang v_i,v_j\rang⟨vi,vj⟩ satisfying
- ∀(vi,vj)∈V×V,w(vi,vj)=w(vj,vi).\forall(v_i,v_j)\in \mathbf{V} \times \mathbf{V}, w(v_i,v_j)=w(v_j,v_i).∀(vi,vj)∈V×V,w(vi,vj)=w(vj,vi).
作业二
1.自己画一棵树, 将其元组各部分写出来 (特别是函数 ppp).
答:let ϕ\phiϕ be the empty node, the tree is a tripe T=(V,r,p)T = (\mathbf{V},r,p)T=(V,r,p) where
- V={v0,v1,v2,v3,v4,v5,v6,v7}\mathbf{V}=\{ v_0,v_1,v_2, v_3,v_4,v_5,v_6,v_7\}V={v0,v1,v2,v3,v4,v5,v6,v7} is the set of nodes;
- r=v0r=v_0r=v0 is the root node;
- p(v0)=ϕ,p(v1)=v0,p(v2)=v0,p(v3)=v1,p(v4)=v1,p(v5)=v1,p(v6)=v2,p(v7)=v4;p(v_0)=\phi, p(v_1)=v_0, p(v_2)=v_0,p(v_3)=v_1, p(v_4)=v_1, p(v_5)=v_1,p(v_6)=v_2, p(v_7)=v_4;p(v0)=ϕ,p(v1)=v0,p(v2)=v0,p(v3)=v1,p(v4)=v1,p(v5)=v1,p(v6)=v2,p(v7)=v4;
2.针对该树, 将代码中的变量值写出来 (特别是 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 = 7;
root = 0;
parent = [-1,0,0,1,1,1,2,4]
作业三
1.画一棵三叉树, 并写出它的 child 数组.
答:child[9][3] = [1−12345−1−16−1−1−1−17−1−1−1−18−1−1−1−1−1−1−1−1]\left[\begin{matrix}1&-1&2\\ 3&4&5\\ -1&-1&6\\ -1&-1&-1\\ -1&7&-1\\ -1&-1&-1\\ 8&-1&-1\\ -1&-1&-1\\ -1&-1&-1\end{matrix}\right]⎣⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎢⎡13−1−1−1−18−1−1−14−1−17−1−1−1−1256−1−1−1−1−1−1⎦⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎥⎤
2.按照本贴风格, 重新定义树. 提示: 还是应该定义 parent 函数, 字母表里面只有一个元素.
答:Definition2. let ϕ\phiϕ be the empty node, a tree is a tripe G=(V,r,Σ,p)G=(\mathbf{V},r,\Sigma,p)G=(V,r,Σ,p)where
- V\mathbf{V}Vis the set of nodes;
- r∈Vr\in \mathbf{V}r∈Vis the root node;
- Σ={a}\Sigma=\{a\}Σ={a} is the alphabet;
- p:(V∪{ϕ})×Σ∗→V∪{ϕ}p:(\mathbf{V}\cup\{\phi\})\times \Sigma^*\to \mathbf{V}\cup\{\phi\}p:(V∪{ϕ})×Σ∗→V∪{ϕ} satisfying
- ∀v∈V,∃1s∈Σ∗,st.p(v,s)=r\forall v \in \mathbf{V},\exist 1 s\in\Sigma^*,st.p(v,s)=r∀v∈V,∃1s∈Σ∗,st.p(v,s)=r
3.根据图、树、m mm-叉树的学习, 谈谈你对元组的理解.
答:元组由元组明和元组中的元素组成,图 (Graph) 是最经典的元组。G=(V,E),其中G时元组名,V,E是其中的元素。元组中的元素可以是数组,可以是矩阵,可以是任何东西,然后这些元素之间也可能存在某种联系。有点像面向对象里面的类,里面有类的变量,也有这些变量的一些方法。