import numpy as np
import matplotlib.pyplot as plt
points = np.array([[1.9, 1.2],
[1.5, 2.1],
[1.9, 0.5],
[1.5, 0.9],
[0.9, 1.2],
[1.1, 1.7],
[1.4, 1.1]])
points2 = np.array([[3.2, 3.2],
[3.7, 2.9],
[3.2, 2.6],
[1.7, 3.3],
[3.4, 2.6],
[4.1, 2.3],
[3.0, 2.9]])
# 合并为一个数据集
x1_data = np.concatenate((points[:, 0], points2[:, 0])) # 所有的 x1 坐标
x2_data = np.concatenate((points[:, 1], points2[:, 1])) # 所有的 x2 坐标
# 创建标签
y = np.concatenate((np.ones(points.shape[0]), -np.ones(points2.shape[0])))
# 初始化超平面的参数 w1, w2 和偏置 b
w1 = 0.1
w2 = 0.1
b = 0
# 学习率
learning_rate = 0.05
# 数据集的大小
l_data = x1_data.size
# 创建图形和子图
fig, (ax1, ax2) = plt.subplots(2, 1)
# 初始化存储每一步的损失值和迭代步数
step_list