本文整理匯總了Python中sklearn.feature_extraction.text.TfidfVectorizer.__init__方法的典型用法代碼示例。如果您正苦於以下問題:Python TfidfVectorizer.__init__方法的具體用法?Python TfidfVectorizer.__init__怎麽用?Python TfidfVectorizer.__init__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類sklearn.feature_extraction.text.TfidfVectorizer
的用法示例。
在下文中一共展示了TfidfVectorizer.__init__方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: __init__
# 需要導入模塊: from sklearn.feature_extraction.text import TfidfVectorizer [as 別名]
# 或者: from sklearn.feature_extraction.text.TfidfVectorizer import __init__ [as 別名]
def __init__(self, embedding, **kwargs):
"""TODO: to be defined1. """
# list of words in the embedding
if not hasattr(embedding, 'index2word'):
raise ValueError("No `index2word` attribute found."
" Supply the word vectors (`.wv`) instead.")
if not hasattr(embedding, 'vectors'):
raise ValueError("No `vectors` attribute found."
" Supply the word vectors (`.wv`) instead.")
vocabulary = embedding.index2word
self.embedding = embedding
print("Embedding shape:", embedding.vectors.shape)
TfidfVectorizer.__init__(self, vocabulary=vocabulary, **kwargs)
示例2: __init__
# 需要導入模塊: from sklearn.feature_extraction.text import TfidfVectorizer [as 別名]
# 或者: from sklearn.feature_extraction.text.TfidfVectorizer import __init__ [as 別名]
def __init__(self, analyzer='word', use_idf=True):
TfidfVectorizer.__init__(self, analyzer=analyzer, use_idf=use_idf,
norm='l2')
self._fit_X = None