title: Amazon SageMaker factorisation machine rating matrix and endpoint
body: <p>I am building a recommender system using sagemaker's built-in factorisation machine model.</p>
  
  <p>My desired result is to have a <strong>rating matrix</strong> where I can look up a predicted score by a <strong>user id</strong> and an <strong>item id</strong>.</p>
  
  <p>I understand that there is a <strong>predict API</strong> provided by the model: </p>
  
  <pre><code>result = fm_predictor.predict(X_test[1000:1010].toarray())
  </code></pre>
  
  <p>But I am not sure how I can use it to achieve the desired purpose. If I want to know, say, if user#123 is interested in movie#456, how can I use the above API?</p>
  
  <p>Reference: 
  <a href="https://medium.com/@julsimon/building-a-movie-recommender-with-factorization-machines-on-amazon-sagemaker-cedbfc8c93d8" rel="nofollow noreferrer">https://medium.com/@julsimon/building-a-movie-recommender-with-factorization-machines-on-amazon-sagemaker-cedbfc8c93d8</a></p>
  
  <p><a href="https://www.slideshare.net/AmazonWebServices/building-a-recommender-system-on-aws-aws-summit-sydney-2018" rel="nofollow noreferrer">https://www.slideshare.net/AmazonWebServices/building-a-recommender-system-on-aws-aws-summit-sydney-2018</a> (p.41,43)</p>
  
  <hr>
  
  <p>Updated:</p>
  
  <p>I think I understand how to use the API now, you have to build another one-hot encoded dataset as input, for example:</p>
  
  <pre><code>X_new = lil_matrix((1, nbFeatures)).astype('float32')
  X_new[0, 935] = 1
  X_new[0, 1600] = 1
  
  prediction2 = X_new[0].toarray()
  result2 = fm_predictor.predict(prediction2)
  
  print(result2)
  </code></pre>
  
  <p>But it seems it would be quite inefficient to fill out the recommendation matrix this way. What would be the best practice?</p>