開始使用免費開始

分析評論的情感傾向

你的團隊正在打造一個工具,用來監測產品評論中的顧客情感。第一步,你要用預先訓練好的 pipeline 來測試單篇評論的情感傾向。

本練習屬於課程

Python 的 Natural Language Processing(NLP)

檢視課程

練習說明

  • 使用 "distilbert-base-uncased-finetuned-sst-2-english" 模型,初始化一個 sentiment-analysispipeline
  • 使用該 pipeline 來分類 review_text 的情感。

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

from transformers import pipeline

# Define the sentiment analysis pipeline
classifier = ____

review_text = "The new update made the app much faster and easier to use!"

# Get sentiment prediction
result = ____

print(result)
編輯並執行程式碼