介于-1和1之间的比例

问题描述 投票:0回答:1

我有一个文本正,负和中性的情感分析百分比的数据框,我正在尝试将此数据缩放为-1(最负数)和1(最正数)之间的数字。确定该分数的最佳公式是什么?数据框示例:数据列(共11列):

 #   Column            Non-Null Count  Dtype
---  ------            --------------  -----  
 0   kind              200 non-null    object
 1   etag              200 non-null    object
 2   id                200 non-null    object
 3   positive          200 non-null    float64
 4   negative          200 non-null    float64
 5   neutral           200 non-null    float64

需要使用适当的公式添加称为得分的新字段。分数示例:正在下载视频编号的评论:49积极情绪:39.37210499227998负面情绪:18.57951621204323中性情绪:42.04837879567679

python pandas dataframe sentiment-analysis
1个回答
0
投票

[我只是将积极情绪设置为1,将消极情绪设置为-1,将中立情绪设置为0。然后根据其百分比缩放每个分数以获得综合得分。

因此,对于上述示例,分数将为

score = positive% * positive_score + neutral % * neutral_score + negative % * negative_score

score = .3937 * 1 + .4205 * 0 + .1858 * -1
score = .2079

直觉上这是有道理的,因为如果我们所有分数均为正,那么我们的最高分数为1。如果所有分数均为负,那么我们的最低分数为-1,中性分数为0。

© www.soinside.com 2019 - 2024. All rights reserved.