• This repository has been archived on 18/Oct/2022
  • Stars
    star
    330
  • Rank 126,920 (Top 3 %)
  • Language
    Python
  • Created about 7 years ago
  • Updated over 6 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

📉 金融文本情感分析模型

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]

More Repositories

1

blog

📚 专注Web与算法
Vue
1,372
star
2

webpack-demos

📦 Demos && Courses for Webpack 4
JavaScript
627
star
3

theme-bmw

✋ Smart Voice: Voice for yourself | 微声: 请为自己发声
CSS
375
star
4

theme-ad

🔨 Art design theme for write and show.
CSS
258
star
5

music-api-next

🎵 Music API for search results, songs, comments from QQ, Xiami and Netease.
JavaScript
66
star
6

cloudpress

✍️+☁️ : 基于云开发的开源博客系统
JavaScript
64
star
7

various-codes

个人代码/项目仓库(具体请看子目录下的README.md)。自取请注明出处,尊重原创,O(∩_∩)O谢谢
Python
45
star
8

vuepress-plugin-comment

Comment plugin in vuepress, such as Gitalk, Valine...
JavaScript
37
star
9

node-blockchain

Nodejs实现区块链
JavaScript
31
star
10

page-counter

基于Serverless开发的的极简网页计数器,支持基于Hexo、Jekyll、Octopress、ReactJS、VueJS等框架开发的博客、网站、中后台等任何应用。
JavaScript
31
star
11

pure-virtual-dom

🐝VDom+Diff+Patch的简明实现
JavaScript
23
star
12

onebook

📓 Write local, save github, DISPLAY HERE. Everyone can write one book and show yourself to the world!
JavaScript
14
star
13

vuejs-theme-bmw

Hexo depository is https://github.com/dongyuanxin/hexo-theme-bmw
Vue
12
star
14

play-node-command

玩转nodejs命令行
JavaScript
9
star
15

szu-mooc

深圳大学刷mooc脚本,Thanks♪(・ω・)ノ。
Python
6
star
16

leetcode

Leetcode 解题报告
JavaScript
4
star
17

system-process-schedule

nodejs 实现非抢占式的先到先来优先算法、短作业优先算法、高响应比优先算法以及时间片优先算法
JavaScript
4
star
18

ciy

Code it yourself.
JavaScript
3
star
19

old-dongyuanxin.github.io

HTML
3
star
20

dumall

🏪 商城系统
CSS
3
star
21

html5-drag-drop

HTML5的拖放事件学习与实践
JavaScript
3
star
22

design-pattern-demos

💗 Learn and Code Design Pattern every day based on LOVE.
JavaScript
2
star
23

dongyuanxin

2
star
24

markdown-static

个人博客代码存放
HTML
2
star
25

simple-koa

这是在阅读koa以及相关库时整理文章后,模拟实现的玩具版koa。配合文章做验证使用。
JavaScript
2
star
26

learn-use-gitbook

CSS
2
star
27

git-demos

A demo to learn git deeply.
Python
2
star
28

vuepress-plugin-viewer

Vue
1
star
29

passages

Run step by step
CSS
1
star
30

learn-nodejs

nodejs训练
JavaScript
1
star
31

udacity-ud120

🤖 优达学城 机器学习入门课程
Python
1
star
32

Magic-Square

算法实验大作业:幻方生成和数目求解。时间:2017-12-13。小组:杨汇琛、董沅鑫、刘婉玲
C++
1
star
33

diy-promise

JavaScript
1
star
34

filetree-displayer

清晰地画出目录结构图 | Clearly draw the catalog structure
Python
1
star
35

react16-demo

JavaScript
1
star
36

font-design

我的前端设计学习仓库
JavaScript
1
star
37

wechat

💬 我的个人公众号
JavaScript
1
star