参考网站:https://www.python-course.eu/dividing_lines_between_classes.php
任何理论都不如自己实践一遍实在,我们现在就学习搭建一个神经网络。我们先学习一下分类,首先在二维坐标系中我们有两个点,分别为(6,2)和(2,6)这两个点我们可以通过一条直线将他们分开,用Python实现:
import matplotlib.pylab as plt
import numpy as np
point1 = (6,2)
point2 = (2,6)
fig, ax = plt.subplots()
ax.plot(point1[0], point1[1], "or",
color = "red",
markersize = 15)
ax.plot(point2[0], point2[1], "oy",
color = "black",
markersize = 15)
point_on_line = (5, 5)
X = np.arange(0,8)
m = point_on_line[1]/point_on_line[0]
ax.plot(X, m * X, "g-", linewidth = 3)
plt.show()
一条直线将两个点分成了两类。