Giter VIP home page Giter VIP logo

weibosentiment's Introduction

WeiboSentiment

基于各种机器学习和深度学习的中文微博情感分析
语料来源: https://github.com/dengxiuqi/weibo2018

"情感分析"是我本科的毕业设计, 也是我入门并爱上NLP的项目hhh, 把它发出来供大家交流
  • 用FastText在语料库上训练并生成词向量, 该任务语料库较小, 用fastText可以增加n-gram特征, 比传统word2vec要好
  • 训练集10000条语料, 测试集500条语料
  • 分别用SVM, Bayes, DNN, LSTM, Attention+BiLSTM, XGBoost等多种模型搭建并训练正负情感二分类器
    • SVM其实不太适合做NLP, 只是当年我还很菜所以选了SVM(尬笑), 出于情怀就贴上来了
    • Bayes速度快, 效果好。可能是因为该任务语料规模较小,在大规模语料任务上性能会下降,而且磁带模型丢失了语序信息,可拓展性不强(2020.2.13更新)
    • DNN效果不好, 不过现在也很少有直接用DNN做NLP的, 所以这里仅作为从机器学习到深度学习的过渡模型了
    • LSTM用到了上游训练的FastText词向量, 并且考虑了语序信息, 效果有明显提升
    • Attention+BiLSTM效果很好, 但相比纯LSTM提升没那么明显,主要是因为该任务相对简单且语料少。迁移至更复杂任务后注意力的强大会越来越明显
    • XGBoost真是机器学习界的一大杀器, 在这种简单的NLP任务上真是又快又好(2020.6.4更新)
  • 对不同话题下的100条微博进行简单的舆情分析(正负情感微博比例)

实验结果

各种分类器在测试集上的测试结果

模型 准确率
XGBoost 0.874
Attention+BiLSTM 0.86
Naive Bayes 0.856
LSTM 0.854
SVM 0.82
DNN 0.81

舆情分析

数据来自于2018年6月的微博

主题 正面:负面
特朗普 55:44
周杰伦 88:12
好莱坞 79:21
人工智能 79:21
毕业 78:22

工程结构

WeiboSentiment   
├── 00.FastText.ipynb `生成FastText词向量`  
├── 01.SVM.ipynb `SVM分类器`  
├── 02.Bayes.ipynb `朴素贝叶斯`  
├── 03.DNN.ipynb `神经网络分类器`  
├── 04.LSTM.ipynb `LSTM分类器`  
├── 05.Attention+BiLSTM.ipynb `Attention+BiLSTM分类器`  
├── 06.XGBoost.ipynb `XGBoost分类器`   
├── SentimentAnlysis.ipynb `验证集分析`  
├── stopwords.txt `停用词典`      
├── utils.py  `工具函数`  
├── model `各种模型`   
│  ├── model_100.txt `维度为100的FastText词向量`   
│  ├── attention `Attention+LSTM模型`   
│  ├── lstm `LSTM模型`    
│  └── nn `神经网络模型`   
└── weibo2018 `微博语料数据`   
   ├── topics `未标注情感的不同主题微博语料`   
   ├── train.txt `训练集`   
   └── test.txt `测试集`  

weibosentiment's People

Contributors

dengxiuqi avatar

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.