def _build_interaction_matrix(rows, cols, data):
mat = sp.lil_matrix((rows, cols), dtype=np.int32)<EOL>for uid, iid, rating, timestamp in data:<EOL><INDENT>if rating >= <NUM_LIT>:<EOL><INDENT>mat[uid, iid] = <NUM_LIT:1.0><EOL><DEDENT>else:<EOL><INDENT>mat[uid, iid] = -<NUM_LIT:1.0><EOL><DEDENT><DEDENT>return mat.tocoo()<EOL>
Build the training matrix (no_users, no_items),
with ratings >= 4.0 being marked as positive and
the rest as negative.