การแยกตัวประกอบเมทริกซ์
เมทริกซ์ G ถูกกำหนดให้เป็น Pandas dataframe ลองดูว่ามีหน้าตาเป็นอย่างไร จากนั้นพิจารณาเมทริกซ์ตัวประกอบที่เป็นไปได้ ได้แก่ H, I และ J (ซึ่งเป็น Pandas dataframe เช่นกัน) แล้วหาว่าเมทริกซ์สองตัวใดเมื่อคูณกันแล้วจะได้ผลลัพธ์เป็น G
แบบฝึกหัดนี้เป็นส่วนหนึ่งของหลักสูตร
การสร้าง Recommendation Engines ด้วย PySpark
คำแนะนำการฝึกหัด
- ใช้คำสั่ง
printเพื่อดูเมทริกซ์G - ดูเมทริกซ์
H,IและJแล้วพิจารณาว่าคู่ใดเมื่อคูณกันแล้วจะได้G - ใส่คำตอบลงในโค้ด
np.matmul()ที่เตรียมไว้ให้
แบบฝึกหัดเชิงโต้ตอบแบบลงมือทำ
ลองทำแบบฝึกหัดนี้โดยเติมโค้ดตัวอย่างนี้ให้สมบูรณ์
# Take a look at Matrix G using the following print function
print("Matrix G:")
print(____)
# Take a look at the matrices H, I, and J and determine which pair of those matrices will produce G when multiplied together.
print("Matrix H:")
print(____)
print("Matrix I:")
print(____)
print("Matrix J:")
print(____)
# Multiply the two matrices that are factors of the matrix G
prod = np.matmul(____, ____)
print(G == prod)