# 07.4 线性多分类结果可视化

## 7.4 多分类结果可视化⚓︎

### 7.4.1 显示原始数据图⚓︎

def ShowData(X,Y):
for i in range(X.shape[0]):
if Y[i,0] == 1:
plt.plot(X[i,0], X[i,1], '.', c='r')
elif Y[i,0] == 2:
plt.plot(X[i,0], X[i,1], 'x', c='g')
elif Y[i,0] == 3:
plt.plot(X[i,0], X[i,1], '^', c='b')
# end if
# end for
plt.show()


### 7.4.2 显示分类结果分割线图⚓︎

......
epoch=98
98 1385 0.25640040547970516
epoch=99
99 1399 0.2549651316913006
W= [[-1.43299777 -3.57488388  5.00788165]
[ 4.47527075 -2.88799216 -1.58727859]]
B= [[-1.821679    3.66752583 -1.84584683]]
......


x_2 = \frac{w_{12} - w_{11}}{w_{21} - w_{22}}x_1 + \frac{b_2 - b_1}{w_{21} - w_{22}} \tag{1}

b12 = (net.B[0,1] - net.B[0,0])/(net.W[1,0] - net.W[1,1])
w12 = (net.W[0,1] - net.W[0,0])/(net.W[1,0] - net.W[1,1])


x_2 = \frac{w_{13} - w_{11}}{w_{21} - w_{23}} x_1 + \frac{b_3 - b_1}{w_{21} - w_{23}} \tag{2}即：y = W_{13} \cdot x + B_{13}

b13 = (net.B[0,0] - net.B[0,2])/(net.W[1,2] - net.W[1,0])
w13 = (net.W[0,0] - net.W[0,2])/(net.W[1,2] - net.W[1,0])


x_2 = \frac{w_{13} - w_{12}}{w_{22} - w_{23}} x_1 + \frac{b_3 - b_2}{w_{22} - w_{23}} \tag{3}即：y = W_{23} \cdot x + B_{23}

b23 = (net.B[0,2] - net.B[0,1])/(net.W[1,1] - net.W[1,2])
w23 = (net.W[0,2] - net.W[0,1])/(net.W[1,1] - net.W[1,2])


### 7.4.3 理解神经网络的分类方式⚓︎

• 蓝色线是2|3的边界，不考虑第1类
• 绿色线是1|2的边界，不考虑第3类
• 红色线是1|3的边界，不考虑第2类

z_1=z_2，且：z_1=z_3 \tag{4}

ch07, Level2

### 思考与练习⚓︎

1. 使用一对一的方法训练三个二分类器，来解决此问题。