热线电话:13121318867

登录
2021-03-14 阅读量: 5364
make_moons

from sklearn.datasets import make_moons

feature,target = make_moons(n_samples=100,noise=0.05)


from matplotlib import pyplot

from pandas import DataFrame

df = DataFrame(dict(x=feature[:,0],y=feature[:,1],label=target))

colors={0:'red',1:'blue'}

fig,ax= pyplot.subplots()

grouped = df.groupby('label')

for key,group in grouped:

group.plot(ax=ax,kind='scatter',x='x',y='y',label=key,color=colors[key])

pyplot.show()



df = DataFrame(dict(x=feature[:,0],y=feature[:,1],label=target))

为什么要先做成字典然后用dataframe?做城字典的意义是什么呢?


colors={0:'red',1:'blue'}

为什么要用大括号?


feature,target = make_moons(n_samples=100,noise=0.05)

target 是指代什么值?



fig,ax= pyplot.subplots()

这一句有什么用,尤其是后面没有出现 fig

68.3351
2
关注作者
收藏
评论(2)

发表评论