Advertisement

2019 CCCC 大数据预选赛 ---- 短文本情感分类

阅读量:

此次短文本情感分析任务最初参照他人提供的基准方案进行实验,采用LSTM模型实现,线上测试结果约为0.82。随后对模型结构进行了调整,尝试引入双向机制,即Bi-LSTM模型
代码如下:

复制代码
    import numpy as np
    import pandas as pd
    import re
    train = pd.read_csv("C:/Users/Nicht_sehen/Desktop/train.csv", lineterminator='\n')
    test = pd.read_csv("C:/Users/Nicht_sehen/Desktop/test.csv", lineterminator='\n')
    
    # 改label
    train['label'] = train['label'].map({'Negative': 0, 'Positive': 1})
    
    # 清理数据替换掉无词义的符号
    def clean(string):
    string = re.sub(r"\'", "", string)
    string = re.sub(r",", " ", string)
    string = re.sub(r"\t", "", string)
    string = 

全部评论 (0)

还没有任何评论哟~