TfidfVectorizer

1、参数:
https://blog.csdn.net/feng_zhiyu/article/details/81952697
https://cloud.tencent.com/developer/article/1332181
2、
https://www.jianshu.com/p/e2a0aea3630c
https://www.wandouip.com/t5i134289/
https://www.cnblogs.com/Lin-Yi/p/8974108.html
https://www.jianshu.com/p/4bc7fbdafdeb

3、

tv=TfidfVectorizer()
X=tv.fit_transform(list)
weight=tv.fit(list).transform(list)

①X矩阵:
在这里插入图片描述
X.shape[0]是转换的文本总条数,X.shape[1]是转换文本的总词数。
weight矩阵如图所例:
在这里插入图片描述
②nonzero():
例:a=mat([[1,0,0],[1,0,0],[0,0,1]])
nonzero(a)返回值为两个矩阵:
(matrix([[0, 1, 2]], dtype=int32), matrix([[0, 0, 2]], dtype=int32))
分别对应:非零行,非零列。
则:(str(sorted(X[0].nonzero()[1])))返回:X矩阵第一条文本非零的列对应的词。

https://www.jianshu.com/p/e39746ba6d58

画图

https://www.jianshu.com/p/b1dee69767d3
https://www.cnblogs.com/nxld/p/7435930.html
https://www.jianshu.com/p/f868f137dbf3

plt.figure(figsize=(120,90),dpi=80) #面板/画布,大小
plt.title('blabla') #标题
plt.xlim(-2,2) #横轴范围
plt.ylim(-5,3)
plt.xlabel('xxx') #横轴变量名
plt.ylabel('yyy')
plt.xticks([数字],[名称]) #均list形式,名称可省
plt.yticks([数字],[名称])
plt.hlines(y值,x始,x终)
plt.text(x坐标,y坐标,字符串)

ax=plt.subplot(111)
l1,=ax.plot(...)
l2,=ax.plot(...)
plt.legend(handles=[l1,l2,..],labels=['xx','xx',..],loc='lower right') #图例,句柄即曲线名称,显示位置:默认右上角,也可数字:1右上,2左上
plt.show() #显示图像

1、散点图
plt.scatter(x=序列,y=Series,c='red',alpha=1,marker='+', label='pickup',size=20)
size指点的大小,默认20。
https://cloud.tencent.com/developer/ask/134857/answer/239467
2、线图
plt.plot(x,y,color='red',linewidth=1.0,linestyle='--')//颜色,线宽,线样式
plt.subplot(332) //画布分份3*3,在第二块区域画图
plt.plot(xxx,yyy)
3、直方图:
plt.hist(序列Series,bins=list)
https://www.jianshu.com/p/7b5ce14036e0

其它
1、条形图:df.plot.barh(x=列名,y=列名)

seaborn.countplot(x=列名,data=df)
#seaborn.barplot(x=列名,y=列名,data=df) #默认带置信区间(黑条),即ci=True
plt.show()

2、叠加直方图

seaborn.distplot(Series,kde=False,label=列名)
#kde:核密度估计 Kernel Density Estimation
https://blog.csdn.net/unixtch/article/details/78556499

3、散点图:

https://blog.csdn.net/weixin_41990278/article/details/93137009

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值