Import TfidfVectorizer from sklearn.feature_extraction.text. Create a TfidfVectorizer object called tfidf_vectorizer. Wh

动态 未结 0 130
小小草
小小草 LV1 2023年9月23日 23:40 发表
# Import TfidfVectorizer from sklearn.feature_extraction.text import TfidfVectorizer # Initialize a TfidfVectorizer object: tfidf_vectorizer tfidf_vectorizer = TfidfVectorizer(stop_words='english', max_df=0.7) # Transform the training data: tfidf_train tfidf_train = tfidf_vectorizer.fit_transform(X_train) # Transform the test data: tfidf_test tfidf_test = tfidf_vectorizer.transform(X_test) # Print the first 10 features print(tfidf_vectorizer.get_feature_names()[:10]) # Print the first 5 vectors of the tfidf training data print(tfidf_train.A[:5])
收藏(0)  分享
相关标签: 智能问答
问题没解决?让AI助手帮你作答 AI助手
0个回复
  • 消灭零回复