矩陣分解
這裡提供了以 Pandas DataFrame 呈現的矩陣 G。先把它顯示出來,了解其外觀。接著檢視可能的因子矩陣 H、I、J(同樣是 Pandas DataFrame),判斷其中哪兩個矩陣相乘會得到矩陣 G。
本練習屬於課程
使用 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)