始める無料で始める

行列因子分解

行列 G は Pandas のデータフレームとして用意されています。まずは表示して形を確認しましょう。候補の因子行列 HIJ(いずれも Pandas データフレーム)を見て、どの2つを掛け合わせると行列 G が得られるかを判断してください。

この演習はコースの一部です

PySpark で作る Recommendation Engines

コースを見る

演習の手順

  • print コマンドで行列 G を確認しましょう。
  • 行列 HIJ を確認し、どの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)
コードを編集して実行