1. Nauka
  2. /
  3. Kursy
  4. /
  5. Unsupervised Learning ใน Python

Connected

ćwiczenie

NMF กับบทความ Wikipedia

ในวิดีโอ คุณได้เห็นการนำ NMF ไปใช้กับ array ความถี่ของคำแบบง่าย ถึงตาคุณบ้างแล้ว — คราวนี้จะนำ NMF ไปใช้กับ tf-idf word-frequency array ของบทความ Wikipedia ซึ่งอยู่ในรูป csr matrix ชื่อ articles ให้ fit โมเดลและ transform บทความดังกล่าว แล้วในแบบฝึกหัดถัดไปจะได้สำรวจผลลัพธ์ที่ได้

Instrukcje

100 XP
  • Import NMF จาก sklearn.decomposition
  • สร้าง instance ของ NMF ชื่อ model โดยกำหนดให้มี 6 components
  • Fit โมเดลกับข้อมูลจำนวนคำ articles
  • ใช้ method .transform() ของ model เพื่อ transform articles แล้วเก็บผลลัพธ์ไว้ในตัวแปร nmf_features
  • แสดงผล nmf_features เพื่อดูภาพรวมเบื้องต้น (.round(2) จะปัดค่าให้เหลือทศนิยม 2 ตำแหน่ง)