lenskit.batch.predict

28 views
Skip to first unread message

Márcia Barros

unread,
Feb 20, 2019, 11:00:22 AM2/20/19
to LensKit Recommender Toolkit Development and Support
Hi, 

Would it be possible to provide an example of how to use lenskit.batch.predict? 

I'm using it like this, following the example you have for lenskit.batch.recommend:

def eval_prediction(aname, algo, train, test):


    model
= algo.fit(train)


    pred
= batch.predict(model, test)


   
# add the algorithm
    pred
['Algorithm'] = aname




   
return pred



This is returning a pandas dataframe with user  item  rating  prediction Algorithm, and then I use the prediction and the rating columns to calculate measures such as RMSE and MAE. 
I also use this results to get the topk for each user and to calculate the Precision and Recall. 
However, the results for different algorithms are returning almost the same. 

Example:

itemitem algorithm
precision:  0.6782234173273409
recall:  0.7296116298361521
f-measure:  0.632498476558497
nDCG:  0.7585345378190396
RMSE  0.9011650664582945
MAE  0.7024033793043883

useruser algorithm
precision:  0.6731332794694407
recall:  0.726284079214471
f-measure:  0.6283638681052782
nDCG:  0.7548728363422198
RMSE  0.9279957720764701
MAE  0.723097540584582

Maybe I'm not using the batch predict correctly. 


Best Regards, 
Márcia Barros 


Michael Ekstrand

unread,
Feb 20, 2019, 11:26:29 AM2/20/19
to Márcia Barros, LensKit Recommender Toolkit Development and Support
Márcia,

You are using it correctly for estimating prediction accuracy (e.g. RMSE, MAE). Depending on your data set size, those differences are entirely within what I would expect.

Recommendation, however, needs to use the batch.recommend method. The reason is that we need to score far more than the test items: we need to score and rank a larger set of candidates.

In our documentation updates for 0.6, though, we will add examples to the documentation.

--
You received this message because you are subscribed to the Google Groups "LensKit Recommender Toolkit Development and Support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lenskit-recsy...@googlegroups.com.
To post to this group, send email to lenskit...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lenskit-recsys/6ef1d191-6ec6-4fa5-b7ae-8a033fc483e9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Michael D. Ekstrand — michael...@boisestate.edu https://md.ekstrandom.net
Assistant Professor, Dept. of Computer Science, Boise State University
People and Information Research Team (PIReT)  http://coen.boisestate.edu/piret/

Márcia Barros

unread,
Feb 20, 2019, 11:54:55 AM2/20/19
to LensKit Recommender Toolkit Development and Support
Thanks :)

I'll use batch.recommend.

Best Regards, 
Márcia
Reply all
Reply to author
Forward
0 new messages