def test__similar_users__bad(): """ensure the similar_users() method raises an exception for an user not in training data""" with pytest.raises(AssertionError): model = RankFM(factors=2) model.fit(intx_train_pd_int) similar = model.similar_users(9, n_users=1)
def test__similar_users__good(): """test the similar_users() method for a valid [user_id]""" model = RankFM(factors=2) model.fit(intx_train_pd_int) similar = model.similar_users(1, n_users=2) shape = similar.shape == (2, ) users = np.isin(similar, intx_train_pd_int['user_id'].unique()).all() assert shape and users