檢視 Tf-idf 數值
建立 Tf-idf 特徵後,你通常會想知道在每個語料中分數最高的字詞是哪些。做法是先擷取你要檢視的那一列,然後將分數由高到低排序。
上一個練習產生的 DataFrame(tv_df)已經在你的工作環境中。
本練習屬於課程
Feature Engineering for Machine Learning in Python
練習說明
- 將
tv_df的第一列指定給sample_row。 sample_row現在是一組對字詞指派的權重。請將這些數值排序,並印出前 5 個分數最高的字詞。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Isolate the row to be examined
sample_row = tv_df.____
# Print the top 5 words of the sorted output
print(sample_row.____(ascending=____).____())