【问题标题】:How to train machine learning model with FastText output如何使用 FastText 输出训练机器学习模型
【发布时间】:2021-08-22 22:44:44
【问题描述】:

是否有任何 Fasttext 方法可以让我从以下输出中获得以下格式(',其中 67 个存储元素采用压缩稀疏行格式>) Fasttext 或任何我可以训练我的 ML 模型的方法。因为当我使用 TF-IDF 时,我得到了稀疏矩阵并训练了 ML 模型,但现在我想用 FastText 训练模型。

fasttext_out=model_ted.wv.most_similar("The Lemon Drop Kid , a New York City swindler, is illegally touting horses at a Florida racetrack. After several successful hustles, the Kid comes across a beautiful, but gullible, woman intending to bet a lot of money. The Kid convinces her to switch her bet, employing a prefabricated con. Unfortunately for the Kid, the woman belongs to notorious gangster Moose Moran , as does the money. The Kid's choice finishes dead last and a furious Moran demands the Kid provide him with $10,000  by Christmas Eve, or the Kid won't make it to New Year's. The Kid decides to return to New York to try to come up with the money. He first tries his on-again, off-again girlfriend Brainy Baxter . However, when talk of long-term commitment arises, the Kid quickly makes an escape.")

model_ted.wv.most_similar("school")

输出:

[('Psycho-biddy', 0.9323669672012329),
 ('Slasher', 0.8850599527359009),
 ('Demonic child', 0.8805997967720032),
 ('Giallo', 0.8504119515419006),
 ('Road-Horror', 0.821454644203186),
 ('Anthology', 0.8191317915916443),
 ('Czechoslovak New Wave', 0.8187490105628967),
 ('Supernatural', 0.813347339630127),
 ('Psychological thriller', 0.8018383979797363),
 ('Kitchen sink realism', 0.8017964959144592)]

我的主要目的是将输出转换为向量并训练机器学习模型。请确认。

【问题讨论】:

    标签: python machine-learning nlp training-data fasttext


    【解决方案1】:

    我的answer 到您的previous similar question 仍然适用,特别是:

    FastText 本质上只给你词向量:每个词一个向量。如果您想要一个更长的文本向量,比如很多单词,您需要做出更多决定,决定如何将一堆单独的词向量转换成其他东西。

    简单地尝试是一个不错的决定:将所有这些词平均在一起。 (还有许多其他方法可以将较大的文本表示为向量或其他值的袋子。)

    然后您可以尝试将这些平均值作为特征传递给下游分类器。

    另外,正如之前的答案中所指出的那样,如果您像示例代码所示那样传递一个长字符串,您将不会获得一组有意义的 .most_similar() 结果。

    【讨论】:

      猜你喜欢
      • 2019-11-30
      • 1970-01-01
      • 2021-01-14
      • 2018-07-12
      • 2021-03-29
      • 1970-01-01
      • 2017-10-09
      • 2017-09-21
      • 2021-10-01
      相关资源
      最近更新 更多