【问题标题】:Is Sklearn TFIDF vectorizer thread safe?Sklearn TFIDF 矢量化线程安全吗?
【发布时间】:2018-07-02 23:48:54
【问题描述】:

我已经构建了一个 TfidfVectorizer 并将其拟合到我的数据集

tfidf = TfidfVectorizer(tokenizer=ner_tokenizer, stop_words='english')
tfidf.fit(documents)

我现在想在多个线程中执行tfidf.transform()。这样做安全吗?

【问题讨论】:

    标签: python scikit-learn tfidfvectorizer


    【解决方案1】:

    据我所知transform 只读取self 但不会修改它,所以它应该是线程安全的。

    transform() 调用TfidfTransformer.transform()CountVectorizer.transform()check_is_fitted() 并间接调用CountVectorizer._validate_vocabulary()CountVectorizer._check_vocabulary()CountVectorizer._count_vocab()normalize() 以及一些更深层次的不修改。可能还有一些魔法在发生,但我找不到任何东西。

    【讨论】:

      猜你喜欢
      • 2020-05-07
      • 2015-04-08
      • 2018-06-04
      • 2017-12-11
      • 2019-06-09
      • 2017-05-03
      • 2018-08-19
      • 2019-12-23
      • 1970-01-01
      相关资源
      最近更新 更多