開始使用免費開始

文字向量化

你現在要把 volunteer 資料集的 title 欄位轉換成文字向量,並在下一個練習中用於預測任務。

本練習屬於課程

Python 的 Machine Learning 前處理

檢視課程

練習說明

  • volunteer["title"] 欄位存入名為 title_text 的變數。
  • tfidf_vec 為名稱建立一個 TfidfVectorizer 物件。
  • 使用 tfidf_vectitle_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.____(____)
編輯並執行程式碼