Surprise icon indicating copy to clipboard operation
Surprise copied to clipboard

Predictions are not made for users that don't give rating to a specific item and build_anti_testset() is not helping

Open alpermisirli opened this issue 3 years ago • 1 comments

Description

I want to compute beyond accuracy metrics so I need topn from predictions, however the problem is that for example in top10 items, nearly half of the predictions are NaN. To fix it I can use the code below

testset = trainset.build_anti_testset()
predictions = algo.test(testset)

However since build_anti_testset() fills the unkown ratings with means, it corrupts the metrics.

Using below approach

    for uid in range(0, 944):
        for iid in range(0, 1683):
            pred = algo.predict(str(uid), str(iid))

How can I save the predictions in the same format as predictions = algo.test(testset) ? So I can have a filled topn lists without NaN ' s and calculate the metrics I want.

Help is appreciated in terms of ideas as well. Thanks everyone.

alpermisirli avatar Feb 23 '22 18:02 alpermisirli

Sorry @RedLegend97 I'm not sure what you mean. I've you tried https://surprise.readthedocs.io/en/stable/FAQ.html#how-to-get-the-top-n-recommendations-for-each-user ?

NicolasHug avatar Aug 14 '22 19:08 NicolasHug