矩阵乘法
为了更直观地理解矩阵乘法,我们来手动做一些矩阵运算。
本练习是课程的一部分
使用 PySpark 构建推荐引擎
练习说明
- 矩阵
a和b是 Pandas 数据框。请对它们分别使用.head()方法进行查看。 - 请自行计算这两个矩阵的乘积。
- 将矩阵
a与b的乘积结果,按值填入使用np.array()创建的product数组中。 - 使用最后一行代码中的验证来评估您的结果。
.dot()方法用于两个矩阵相乘。
交互式实操练习
通过完成这段示例代码来试试这个练习。
# Use the .head() method to view the contents of matrices a and b
print("Matrix A: ")
print (a.____())
print("Matrix B: ")
print (b.____())
# Complete the matrix with the product of matrices a and b
product = np.array([[____,____], [____,____]])
# Run this validation to see how your estimate performs
product == np.dot(a,b)