文本向量化
现在,您将把 volunteer 数据集的 title 列转换为文本向量。在下一个练习中,您将用它来完成预测任务。
本练习是课程的一部分
Python 中的机器学习预处理
练习说明
- 将
volunteer["title"]列保存到名为title_text的变量中。 - 将
TfidfVectorizer实例化为tfidf_vec。 - 使用
tfidf_vec将title_text中的文本转换为 tf-idf 向量。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Take the title text
title_text = ____
# Create the vectorizer method
tfidf_vec = ____
# Transform the text into tf-idf vectors
text_tfidf = tfidf_vec.____(____)