行列因子分解
行列 G は Pandas のデータフレームとして用意されています。まずは表示して形を確認しましょう。候補の因子行列 H、I、J(いずれも Pandas データフレーム)を見て、どの2つを掛け合わせると行列 G が得られるかを判断してください。
この演習はコースの一部です
PySpark で作る Recommendation Engines
演習の手順
printコマンドで行列Gを確認しましょう。- 行列
H、I、Jを確認し、どの2つを掛け合わせると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)