Giter Club home page Giter Club logo

news-emotion's Introduction

0.快速开始

  • 挑战杯项目:金融文本情感分析模型 || Challenge Cup Project: Financial Text Emotion Analysis Model
  • 金融领域短文本情感分析
  • 配置要求:python 3.x

1.使用方法

1.0 下载

sudo git clone https://github.com/AsuraDong/news-emotion.git news_emotion
mv -R ./news_emotion/ 你的程序路径/

1.1 文件结构

clean_data/ # 清洗数据
    __init__.py
    clean_html.py # 清洗网页标签
    langconv.py # 简体和繁体转化
    zh_wiki.py # 简体和繁体转化
data/ # 存放训练集和词典
    emdict/ # 存放词典
        material/
            emotion_word.py # 知网情感词典
            stopword.txt # 中文停用词典
            NTUSD_simplified/ # **大学NTUSD情感词典
                ...
        collect_dict.py # 生成之后程序需要的plk和用户词典
    trainset/ # 存放训练集
        ...
model/ # 我们训练好的model模型
    wordfreq_logistic.ml
other/ # 根据具体情况自行添加
    ...
result/ #结果展示
    log/
       best_model/ # 针对最好的模型的详细信息
            PR.json
            error_tag.json
        ml_rate.plk
        logfile.plk
        3plus3arr.plk
    show/ # 组合模型的全部结果
        result.csv
        result.xlsx
    vector/ # 文本翻译后的词向量
        result.csv
        result.xlsx
__init__.py
loocv_model.py # 对组合模型进行留一验证,并且将结果写入csv和excel文件
ml_model.py # 集成sklearn常用的自然语言的机器学习模型
operate_data.py # 将文本处理成词向量,并且保存了logfile.plk
README.md
demo.py # 使用者(非开发者)调用框架的样例
run_best.py # 人工找出loocv_model.py的最好结果后,进行最好模型的更详细分析

1.2 使用方法

请参照demo.py的代码

  1. 打开demo.py

  2. 如果:

    • 直接使用我们训练好的模型,在if __name__=='__main__':里面输入:
    od.loadStopwords()
    od.loadEmotionwords()
    od.loadWords(od.stopList)
    od.loadDocument(od.stopList)
    ##### 单例模式 #####
    predictor = Predictor()
    predictor.load_model()
    predictor.set_mode(mode="wordfreq") # 以上代码是初始化配置,只需要调用一次
    
    ##### 下面的代码可以循环调用 #####
    news = "                                                    《经济通通讯社13日专讯》日股早市偏软,日经225指数报18312跌239点。  美元兑日圆疲软,新报108﹒78╱80。(tt)" # 这是您的新闻样本
    
    predictor.set_news(news=news)
    predictor.trans_vec()
    
    tag = predictor() # 分类结果
    • 需要重新训练模型,那么在配置好1.1的文件后,在if __name__=='__main__':里面输入:
    best_vector = "wordfreq"
    best_model = 1  # linearLogistic
    save_model(best_vector, best_model)
    ##### 单例模式 #####
    predictor = Predictor()
    predictor.load_model()
    predictor.set_mode(mode="wordfreq") # 以上代码是初始化配置,只需要调用一次
    
    ##### 下面的代码可以循环调用 #####
    news = "                                                    《经济通通讯社13日专讯》日股早市偏软,日经225指数报18312跌239点。  美元兑日圆疲软,新报108﹒78╱80。(tt)" # 这是您的新闻样本
    
    predictor.set_news(news=news)
    predictor.trans_vec()
    
    tag = predictor()
  3. 成功后,相信你也差不多理解框架的用法,请尽情使用吧。

2. 联系我

个人网站: YuanXin.me

Email:[email protected]

news-emotion's People

Contributors

dongyuanxin avatar

Stargazers

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

Watchers

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

news-emotion's Issues

关于训练样本的说明

不少朋友Email我询问训练样本的事情,这里统一说明一下。

  1. 来源:wisenews网站。
  2. 分类:属于港股的新闻,数据库目前有80w+的新闻文本。
    database
  3. 训练样本:从以上的80w+的新闻文本中挑选出的最新的1000条新闻,人工打标后交给模型训练。

由于项目需要,所以在公开的仓库没有上传打标的文本,之后会考虑上传训练用的全部文本,供同好使用。

关于准确率的疑问

在不过拟合的前提下,相信样本的打标的准确率是大家最期待的结果。那么,这里公布一下的1000个打标的数据模型,在留一验证后的准确率。

二分类

只是将新闻打标分为正极和负极,各路论文的常见分类。
two-tag

三分类

将新闻文本分为正极、负极和中性三个类别。基本上,所有论文都尽力规避中性分类,但是,在现实中确是存在的问题。当然,在打标上,中性分类的标注也需要斟酌。就目前结果来看,三分类的效果可以接受。
three-tag

一些说明

由于一些问题,这里先取消了tf-idfsvm及相关模型的组合,具体原因请移步bug Issues查看。(上面结果中,会有一行一列均为0)

TF-IDF时间复杂度如何降低

求助:希望提供关于TF-IDF的时间复杂度降低的解决办法。

关于TF-IDF模型的实现在这里:news-emotion/operate_data.pywords2vec方法中。

可以清晰的看到,实现的代码中和其他方法相比,多了一个循环,时间复杂度变成原来的N倍。
由于目前没有相应的集群供我们使用,并且服务器跑1000个训练样本也很慢,所以暂时先取消tf-idf这中词向量的尝试,之后会再重新补上

tf-idf

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.