Esempio n. 1
0
def test__similar_items__bad():
    """ensure the similar_items() method raises an exception for an item not in training data"""

    with pytest.raises(AssertionError):
        model = RankFM(factors=2)
        model.fit(intx_train_pd_int)
        similar = model.similar_items(99, n_items=3)
Esempio n. 2
0
def test__similar_items__good():
    """test the similar_items() method for a valid [item_id]"""

    model = RankFM(factors=2)
    model.fit(intx_train_pd_int)
    similar = model.similar_items(1, n_items=3)

    shape = similar.shape == (3, )
    items = np.isin(similar, intx_train_pd_int['item_id'].unique()).all()
    assert shape and items