【问题标题】:Text data using logistic regression使用逻辑回归的文本数据
【发布时间】:2020-12-09 23:06:02
【问题描述】:

我正在对这些数据进行预处理:

Name   Nickname   Age    Country    Reg_Date     Text 
Matt   LeBron    63     Canada     24-12-2008   I'm in a happy mood today. I go to beach
Chris  Severine  54     U.S.       15-07-2009   I stand in solidarity with #ows
Lucas  Daly      47     Ireland    01-05-2020   Trump is working for next politician...
Clash  Lynch     24     U.S.       13-11-2008   What a wonderful day!
...

在将我的数据集拆分为训练集和测试集并将其用于逻辑回归之前,我需要使用词袋或其他特征表示。

目前我试图从上面的原始数据集中获取其他信息(推文中的字符数;标点符号的使用等):

Name   Nickname   Age    Country    Reg_Date     Text 
Matt   LeBron    63     Canada     24-12-2008   I'm in a happy mood today. I go to beach
Chris  Severine  54     U.S.       15-07-2009   I stand in solidarity with #ows
Lucas  Daly      47     Ireland    01-05-2020   Trump is working with Putin... 
Clash  Lynch     24     U.S.       13-11-2008   What a wonderful day!
...
Lulu   Lulu22    18     Poland     02-09-2019   I hate Maths!!!! >(


Punctuation   Positive Words     Negative Words
[.]          [happy]              []
[#]          [solidarity]         []
[...]        []                   []
[!]          [wonderful]          []
[>,(]        []                   [hate]

现在,我真的很想了解如何以模型“可读”的方式(例如在逻辑回归模型中)转换标点符号信息、肯定词、否定词、文本。

如果您能给我一些有用的提示或提供示例,我将不胜感激。

【问题讨论】:

    标签: python nlp logistic-regression


    【解决方案1】:

    使用One hot encodingword embedding

    有关一般 nlp 的更多信息,您可以阅读来自Stanford's cs224N course 的注释。更具体地说this

    【讨论】:

    • 嗨@YukiShriorii,感谢您的回答和推荐。我已经开始阅读斯坦福的文件。拥有一个混合了文本数据和数字数据的数据集,我如何使用一种热编码或词嵌入将所有文本数据视为数字变量?例如,我有列文本、标点符号和正/负词。在我的分类器中,它们也应该被考虑,因为我可以找到一个很好的预测积极词的数量,或者只是在文本中使用
    • 你想预测什么?
    • 我想预测文本的情绪,但使用分类器(例如逻辑回归或 svm)。我觉得我在理解步骤方面遗漏了一些东西。我还确定了 one-gram、bi-gram 和 3-gram 的词频……但我不明白如何在分类器中使用这些信息
    • 可以查看this
    • 例如,您的数据由 [“i hat sand”、“i love you”] -> 总共 5 个不同的词(i、hate、love、sand、you)组成 -> 应用一个热门-> [ (1, 1, 0, 1, 0), (1, 0, 1, 0, 1)] -> 输入到模型中,它应该知道带有单词 hat 或 love 的数据属于 neg/positive分别标注
    猜你喜欢
    • 1970-01-01
    • 2015-06-30
    • 2019-03-02
    • 2019-01-21
    • 2016-09-13
    • 1970-01-01
    • 2014-04-02
    • 1970-01-01
    • 2020-05-08
    相关资源
    最近更新 更多