tfidf_matrix = TfidfVectorizermax_df=095 min_df=2 max_features=n_features stop_words=english dtype=npfloat32fit_transformdocs_cleanda_model = gensimmodelsldamodelLdaModeltfidf_matrix num_topics=8 id2w
将n_features定义为一个整数值,例如:
n_features = 1000 # 设定为1000个最大特征值 tfidf_matrix = TfidfVectorizer(max_df=0.95, min_df=2, max_features=n_features, stop_words='english', dtype=np.float32).fit_transform(docs_clean) da_model = gensim.models.ldamodel.LdaModel(tfidf_matrix, num_topics=8, id2word=dict(enumerate(feature_names)), passes=10)
原文地址: https://www.cveoy.top/t/topic/dx61 著作权归作者所有。请勿转载和采集!