矩阵分解
这里提供了 Pandas dataframe 形式的矩阵 G。先查看它的结构。再查看可能的因子矩阵 H、I 和 J(同样是 Pandas dataframes),判断哪两个矩阵相乘后会得到矩阵 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)