【机器学习】sklearn之生成环形和半环型数据,python

python使用sklearn生成环形和半环型数据,代码传送门:

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)
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://www.cnblogs.com/wj-1314/p/10179741.html

posted @ 2020-03-03 14:08  HelenLee01  阅读(349)  评论(0编辑  收藏  举报