Python 中 SentimentIntensityAnalyzer() 的奇怪结果

问题描述

虽然我从事数据分析工作有一段时间了,但我是 Python 的新手。我尝试使用 Python 脚本和 twitter api 导入在 PowerBI 中测试情绪分析以获取一些推文。

我基本上让一切正常工作,但是,情绪分析的结果超出了图表 - 与它们应有的相比。据我所知,函数 SentimentIntensityAnalyzer() 应该给出 -4 到 4 之间的结果。当我运行我的代码时,我得到成百上千的结果——我不知道如何解释——而且很可能这些结果是错误的。

我正在使用以下脚本:

import pandas as pd
from nltk.sentiment.vader import SentimentIntensityAnalyzer

#load in the sentiment analyzer
sia=SentimentIntensityAnalyzer()

#apply the analyzer over each comment
dataset['neg'] = dataset['Tweet Text'].apply(lambda x:sia.polarity_scores(x)['neg'])
dataset['neu'] = dataset['Tweet Text'].apply(lambda x:sia.polarity_scores(x)['neu'])
dataset['pos'] = dataset['Tweet Text'].apply(lambda x:sia.polarity_scores(x)['pos'])
dataset['compound'] = dataset['Tweet Text'].apply(lambda x:sia.polarity_scores(x)['compound'])

我对推文分析的结果如下:

Results in Excel

我真的不知道我在这件事上做错了什么。也许社区中的某个人有线索并可以帮助我。

感谢任何评论

提前致谢...

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)