然后我们先来看一下上一节的代码首先导包
import numpy as np 导入数学计算包
import matplotlib.pyplot as plt 导入画图包
from sklearn.cluster import KMeans,DBSCAN 导入算法
from sklearn import datasets 导入数据集包
然后我们再去创建数据
X,y = datasets.make_circles(n_samples = 1000,noise=0.05,factor = 0.5)
plt.figure(figsize=(5,5)) 设置一下画布的宽度高度
plt.scatter(X[:,0],X[:,1],c=y)
X1,y1 = datasets.make_blobs(n_samples=500,n_features=2,centers=[(1.5,1.5)],cluster_std=0.2)
plt.figure(figsize = (5,5))
plt.scatter(X1[:,0],X1[:,1],c=y1)