

def test_fm_sgr_ranking():
    (w0, w, V, y, X) = get_test_problem()
    X_test = X.copy()
    X_train = X.copy()
    import itertools
    pairs = [p for p in itertools.combinations(range(len(y)), 2)]
    compares = np.zeros((len(pairs), 2), dtype=np.float64)
    for (i, p) in enumerate(pairs):
        if (fm[p[0]] > y[p[1]]):
            compares[(i, 0)] = p[0]
            compares[(i, 1)] = p[1]
        else:
            compares[(i, 0)] = p[1]
            compares[(i, 1)] = p[0]
    print(compares)
    fm = bpr.FMRecommender(n_iter=2000, init_stdev=0.01, l2_reg_w=0.5, l2_reg_V=0.5, rank=2, step_size=0.002, random_state=11)
    fm.fit(X_train, compares)
    y_pred = fm.predict(X_test)
    y_pred = np.argsort(y_pred)
    print(y)
    print(y_pred)
    print(np.argsort(y))
    assert (utils.kendall_tau(np.argsort(y), y_pred) == 1)

dataset/ETHPy150Open ibayer/fastFM/fastFM/tests/test_ranking.py test_fm_sgr_ranking/VarMisuse@105/121 `y`->`fm`