NicolasHug / Surprise

A Python scikit for building and analyzing recommender systems
http://surpriselib.com
BSD 3-Clause "New" or "Revised" License
6.34k stars 1.01k forks source link

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

Open alpermisirli opened 2 years ago

alpermisirli commented 2 years ago

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.

NicolasHug commented 2 years ago

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 ?