Giter Site home page Giter Site logo

weiboemotionanalyzer's Introduction

WeiboEmotionAnalyzer

微博内容爬取并训练支持向量机进行情感分析,原创的部分不多,主要是将他人成果进行了串联,形成了完整流程,修复了一些小问题

环境为 Anaconda (Python 3.7.1 64-bit)

相关

jieba

pandas

word2vec

svm

sklearn

gensim

参考内容

  1. 爬虫部分主要参考 https://github.com/Python3Spiders/WeiboSuperSpider

  2. word2Vec 和支持向量机训练的部分主要参考 https://m-zhoujie2.gitbooks.io/python-introductory-and-advanced-data-analysis/chapter9.html

  3. 以及查找了其他关于 Python 读写 csv、xml 等内容

脚本文件说明

getWords.py

使用 jieba 分词将训练数据集转化为词组

getWordVec.py

将训练数据集词组结果转为向量

getSVM.py

使用训练数据集训练支持向量机

getWeibo.py

根据话题从微博爬取博文内容

getPredict.py

对爬取到的微博数据进行预测

数据文件说明

DataSet

爬取结果,同时也是预测所用到的测试集

Result

预测结果

SVM

通过训练集学习得到的支持向量机模型

TrainingSet

训练集,以及一些中间产物。其中pos和neg分别表示积极和消极内容

ipad3 训练集来自于《2012年CCF自然语言处理与中文计算会议:中文微博情感分析测评数据》

http://tcci.ccf.org.cn/conference/2012/pages/page10_dl.html

普通训练集(neg.xls & pos.xls)来自于参考内容2中提及的语料库,该语料库整合了书籍、计算机等 7个领域的评论数据。

须知

上述两个训练集都有比较大的局限性,因此训练出的支持向量机对于新数据的预测效果不尽如人意

因此上述训练数据集目前还只能用于参考和练习,并不能得出比较好的学习模型。

2020-02-17 补充

根据普通训练集训练出的支持向量机对 ipad3 数据集(DataSet/ipad3.csv)进行预测的结果为(Result/prediction_ipad3.csv):

TP: 25 FN: 16

FP: 19 TN: 40

分类准确率 Accuracy = 0.65

查准率(精确率) Precision = 0.57

查全率(召回率) Recall = 0.6

计算时排除了 ipad3 数据集中标记为非态度性的内容,即只考虑了 opinionated = Y 的数据。

weiboemotionanalyzer's People

Contributors

cheereus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

weiboemotionanalyzer's Issues

运行getPredict的报错

# 读取 Word2Vec 并对新输入进行词向量计算 def average_vec(words): # 读取 Word2Vec 模型 w2v = Word2Vec.load('TrainingSet/w2v_model.pkl') vec = np.zeros(300).reshape((1, 300)) for word in words: try: vec += w2v[word].reshape((1, 300)) except KeyError: continue return vec
在这段里执行到vec += w2v[word].reshape((1, 300))时报错TypeError: 'Word2Vec' object is not subscriptable,若将w2v强制转换为列表又报错TypeError: 'Word2Vec' object is not iterable,我实在找不到解决方法,请问要如何解决这个问题呢?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.