sklearn的make_circles和make_moons生成数据

关于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() 

sklearn的make_circles和make_moons生成数据_第1张图片

你可能感兴趣的:(sklearn)