2021-03-14
閱讀量:
5732
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()
這一句有什么用,尤其是后面沒有出現(xiàn) fig






評論(2)

推薦帖子
0條評論
0條評論
0條評論