title: How to use Python's FastFM library (factorization machines) for recommendation tasks?
body: <p>I have a dataset of <code>&lt;user, item&gt;</code> pairs where each entry records which user bought which item.</p>
  
  <p>e.g. </p>
  
  <pre><code>&lt;u1, i1&gt;
  &lt;u1, i4&gt;
  &lt;u2, i2&gt;
  &lt;u3, i2&gt;...
  </code></pre>
  
  <p>I created an encoded dataset with</p>
  
  <pre><code>no_of_features = no_of_users + no_of_items
  </code></pre>
  
  <p>and have set output variable <code>y</code> to 1, as each of those entries represented the user having bought that particular item.</p>
  
  <p>Note: All y values are 1 in this case.</p>
  
  <p>The encoded dataset looks like this:</p>
  
  <pre><code>user1 user2 user3 .... item1 item2 item3 item4 .... y
    1     0    0    ....   1     0     0     0   .... 1
    1     0    0    ....   0     0     0     1   .... 1
    0     1    0    ....   0     1     0     0   .... 1
    0     0    1    ....   0     1     0     0   .... 1
  </code></pre>
  
  <p>Now, I would like to know how to use <code>fastFM</code> to generate recommendations for cases <code>&lt;x, y&gt;</code> for any user <code>x</code> and any item <code>y</code>?</p>
  
  <p>Clearly <code>regression</code> is out of the picture here. So should I use the <code>classification</code> or <code>ranking</code> approach of <code>fastFM</code>? Also how? e.g. If I use <code>classification</code>, do I need to generate instances with <code>y=0</code>? If I use <code>ranking</code> approach, do I arrange items by the output of ranking approach and recommend those with higher values?</p>