任务如上图
from sklearn.datasets import make_circles
from sklearn.datasets import make_moons
import matplotlib.pyplot as plt
import numpy as np
"""
************
cir_x:400个点(400,2)
cir_y:每个cir_x对应的标签0/1
"""
cir_x, cir_y =make_circles(n_samples=400 ,factor=0 ,noise=0.1)#factor-内外圆的比例因子 noise-点的杂乱程度
fig =plt.figure(1)#创建第一个画板
plt.subplot(1,2,1) #一行两列两列的排版,第一张图的位置在第一行第一列 可以简化为(121)
plt.title('make_circles ')
plt.scatter(cir_x[:, 0], cir_x[:, 1],marker='o', c=cir_y)#每个二维数组的第一列和第二列的数,作为坐标
#print(cir_y)#输出的标签为0、1,代表内圆和外圆上的点
#print(cir_x)
plt.subplot(1,2,2)
moon_x, moon_y = make_moons(n_samples=400, noise=0.1)
plt.title('make_moons')
plt.scatter(moon_x[:, 0], moon_x[:, 1], marker='o', c=moon_y)
plt.show()
运行结果: