机器学习基本术语
# 机器学习基本术语图例
import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
# 显示plt.show()的图片,如若不使用jupyter,请注释
%matplotlib inline
# 中文字体设置,找到与之对应的中文字体路径
font = FontProperties(fname='/Library/Fonts/Heiti.ttc')# 样本
plt.text(1, 70, s='{身高(180),体重(70),年龄(19),五官(精致)',fontproperties=font, fontsize=13, color='g')
plt.annotate(text='样本', xytext=(90, 70), xy=(78, 71), ha='center', arrowprops=dict(arrowstyle="<-", color='b'), fontproperties=font, fontsize=15, color='r')
plt.annotate(text='特征', xytext=(30, 90), xy=(10, 73), ha='center', arrowprops=dict(arrowstyle="<-", color='b'), fontproperties=font, fontsize=15, color='r')
plt.annotate(text='', xytext=(30, 90), xy=(30, 73), ha='center', arrowprops=dict(arrowstyle="<-", color='b'), fontproperties=font, fontsize=15, color='r')
plt.annotate(text='', xytext=(30, 90), xy=(50, 73), ha='center', arrowprops=dict(arrowstyle="<-", color='b'), fontproperties=font, fontsize=15, color='r')
plt.annotate(text='', xytext=(30, 90), xy=(70, 73), ha='center', arrowprops=dict(arrowstyle="<-", color='b'), fontproperties=font, fontsize=15, color='r')plt.hlines(67, 0, 100, linestyle='--', color='gray')# 特征
plt.text(1, 40, s='{身高(180),体重(70),年龄(19),五官(精致),帅}',fontproperties=font, fontsize=10, color='g')
plt.annotate(text='样例(实例)', xytext=(90, 40), xy=(70, 41), ha='center', arrowprops=dict(arrowstyle="<-", color='b'), fontproperties=font, fontsize=15, color='r')
plt.annotate(text='特征', xytext=(30, 60), xy=(8, 43), ha='center', arrowprops=dict(arrowstyle="<-", color='b'), fontproperties=font, fontsize=15, color='r')
plt.annotate(text='', xytext=(30, 60), xy=(23, 43), ha='center', arrowprops=dict(arrowstyle="<-", color='b'), fontproperties=font, fontsize=15, color='r')
plt.annotate(text='', xytext=(30, 60), xy=(38, 43), ha='center', arrowprops=dict(arrowstyle="<-", color='b'), fontproperties=font, fontsize=15, color='r')
plt.annotate(text='', xytext=(30, 60), xy=(53, 43), ha='center', arrowprops=dict(arrowstyle="<-", color='b'), fontproperties=font, fontsize=15, color='r')
plt.annotate(text='标记', xytext=(67, 60), xy=(67, 43), ha='center', arrowprops=dict(arrowstyle="<-", color='b'), fontproperties=font, fontsize=15, color='r')plt.hlines(37, 0, 100, linestyle='--', color='gray')# 特征空间
plt.text(1, 30, s='$\{(x_1^{(1)},x_1^{(2)},\cdots,x_1^{(n)}),(x_2^{(1)},x_2^{(2)},\cdots,x_2^{(n)}),\cdots,(x_m^{(1)},x_m^{(2)},\cdots,x_m^{(n)})\}$',fontproperties=font, fontsize=10, color='g')
plt.annotate(text='特征空间($m$个样本)', xytext=(90, 15), xy=(92, 30), ha='center', arrowprops=dict(arrowstyle="<-", color='b'), fontproperties=font, fontsize=15, color='r')
plt.annotate(text='特征向量($n$维特征)', xytext=(15, 15), xy=(15, 28), ha='center', arrowprops=dict(arrowstyle="<-", color='b'), fontproperties=font, fontsize=15, color='r')plt.xlim(0, 100)
plt.ylim(10, 100)
plt.title('机器学习基本术语图例', fontproperties=font, fontsize=20)
plt.show()
通过上图,我们可以习得以下机器学习的基本术语:
- 特征(feature):描述一件事物的特性,如一个人的身高、体重、年龄和五官。
- 样本(sample):由一个人的特征组成的数据,如${180,70,19,精致}$。
- 标记(label):描述一件事物的特性,如一个人帅或丑、一个人的财富数量。注:特征和标记没有明确的划分,由于问题的不同可能导致A问题的特征是B问题的标记,B问题的标记是A问题的特征。
- 样例(example):由一个人的特征和标记组成的数据,如${180,70,19,精致,帅}$。
- 特征空间(feature space):由${x{(1)},x,\cdots,x^{(n)}}$这n个特征张成的n维空间,如以身高张成的一维空间(线);以身高和体重张成的二维空间(面);以身高、体重和年龄张成的三维空间(体)。
- 特征向量(feature vector):特征空间内的某一个具体的向量,即特种空间中的某一个具体的点,
$$
\{x_i^{(1)},x_i^{(2)},\cdots,x_i^{(n)}\},\,i\in{R}
$$
其中$x_m^{(n)}$表示第m个人的第n个特征。如身高、体重、年龄张成的三维空间中的某一个具体的点$(180,70,19)$。