关于make_circles and make_moons生成环形形状和月亮形状数据
生成环形数据
转载来源:https://blog.csdn.net/dataningwei/article/details/53649330
make_circles:
sklearn.datasets.make_circles(n_samples=100, shuffle=True, noise=None, random_state=None, factor=0.8)
生成环形数据
factor :外圈与内圈的尺度因子<1
make_moons:
生成半环形图
sklearn.datasets.make_moons(n_samples=100, shuffle=True, noise=None, random_state=None)
from sklearn.datasets import make_circles
from sklearn.datasets import make_moons
import matplotlib.pyplot as plt
import numpy as np
fig=plt.figure(1)
x1,y1=make_circles(n_samples=1000,factor=0.5,noise=0.1)
# datasets.make_circles()专门用来生成圆圈形状的二维样本.factor表示里圈和外圈的距离之比.每圈共有n_samples/2个点,、
# 里圈代表一个类,外圈也代表一个类.noise表示有0.1的点是异常点
plt.subplot(121)
plt.title('make_circles function example')
plt.scatter(x1[:,0],x1[:,1],marker='o',c=y1)
plt.subplot(122)
x1,y1=make_moons(n_samples=1000,noise=0.1)
plt.title('make_moons function example')
plt.scatter(x1[:,0],x1[:,1],marker='o',c=y1)
plt.show()
![](https://i-blog.csdnimg.cn/blog_migrate/64658eadd86a875ec3ff3f2139e4e321.png)