行列の積
行列の掛け算を直感的に理解するために、いくつかの行列演算を手でやってみましょう。
この演習はコースの一部です
PySpark で作る Recommendation Engines
演習の手順
- 行列
aとbは Pandas のデータフレームです。各データフレームに対して.head()メソッドを使って中身を確認しましょう。 - これら2つの行列の積を自分で計算してください。
- 行列
aとbの積の値を、np.array()を使って作成したproduct配列に入力します。 - 最後の行の検証コードで、計算結果を評価しましょう。
.dot()メソッドは2つの行列を掛け算します。
実践的なインタラクティブ演習
このサンプルコードを完成させて、この演習に挑戦してみましょう。
# 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)