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()
from sklearn.datasets import make_circles
feature,target = make_circles(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:'green',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()
有make_moons 和 make_cricles ,他们最终展示的图形样式不一样。但是实际应用中是用来做什么的?
LYY202012
2021-03-22
就假设有5个字段吧,找不回来了。 x是个数据框的意思是什么呢
LYY202012
2021-03-22
问:set this to C:\nltk_data (Windows)
老师,请问这个是什么意思?
答:也就是说,你应该在下载过程中,根据自己电脑的操作系统情况比如你是windows,将下载路径指定为他说的C:\nltk_data
如果你的nltk.download()没有严格按照要求执行,后面的语句wnl.lemmatize('countries')运行时就会提示没有资源,就像你发到帖子上的错误提示那样:Resource wordnet not found.
fs陈晓亮
2021-03-22
你的dataframe是几个字段?可以截图下吗,你那个匿名函数里面的x是一个数据框
LYY202012
2021-03-21
过抽样前混淆矩阵
train
confusion_matrix
[[18875 131]
[ 1 193]]
classification report
precision recall f1-score support
0 1.00 0.99 1.00 19006
1 0.60 0.99 0.75 194
accuracy 0.99 19200
macro avg 0.80 0.99 0.87 19200
weighted avg 1.00 0.99 0.99 19200
test
confusion_matrix
[[4722 30]
[ 41 7]]
classification report
precision recall f1-score support
0 0.99 0.99 0.99 4752
1 0.19 0.15 0.16 48
accuracy 0.99 4800
macro avg 0.59 0.57 0.58 4800
weighted avg 0.98 0.99 0.98 4800过抽样后混淆矩阵
train
confusion_matrix
[[18674 332]
[ 29 18977]]
classification report
precision recall f1-score support
0 1.00 0.98 0.99 19006
1 0.98 1.00 0.99 19006
accuracy 0.99 38012
macro avg 0.99 0.99 0.99 38012
weighted avg 0.99 0.99 0.99 38012
test
confusion_matrix
[[4644 108]
[ 40 4712]]
classification report
precision recall f1-score support
0 0.99 0.98 0.98 4752
1 0.98 0.99 0.98 4752
accuracy 0.98 9504
macro avg 0.98 0.98 0.98 9504
weighted avg 0.98 0.98 0.98 9504fs陈晓亮
2021-03-19
从混淆矩阵看,你的模型对数据的拟和程度是比较高的。然后你把这个估计好的模型用于你测试集数据,然后把混淆矩阵给我贴一下,不用贴其他的,只需要贴混淆矩阵,我看下测试集预测效果
fs陈晓亮
2021-03-19
图一为过抽样前的f1值和auc,图二为过抽样,0和1的比例为1:1,图三为过抽样后的f1值和auc,图四为用新数据预测的1的数量。模型为随机森林,RandomForestClassifier(random_state=0,class_weight='balanced'),其余参数未调整。
fs陈晓亮
2021-03-19