Updating model

14 views
Skip to first unread message

Martijn- Augment KU Leuven

unread,
Jan 17, 2019, 5:39:23 AM1/17/19
to LensKit Recommender Toolkit Development and Support
Hello

I implemented an ALS matrix factorisation recommender system with LensKit for my user study (see attachment)
Regarding this script I have 2 questions:

1) I wanted to use the recommend function to generate recommendations for only one user
I tried this in my script
algoAls = als.BiasedMF(6)
fittableALS = util.clone(algoAls)
modelAls = fittableALS.fit(train)
rec = Recommender.adapt(modelAls)
recs = rec.recommend(firstUser, 10) #Gives error

But this was not working. Can anyone explain why?
(I solved the problem by using batch.recommend)

2) What is the best way to update the model if a new user enters?
    Do I fit the model again or are there more efficient ways to update only the user-feature matrix?
 
Thanks for the help!

Martijn
ALS.py

Michael Ekstrand

unread,
Jan 17, 2019, 10:28:00 AM1/17/19
to Martijn- Augment KU Leuven, LensKit Recommender Toolkit Development and Support
Martijn,

Could you provide the complete error message you are receiving? The code looks roughly correct, but the exact error message will shed light on the subject.

Right now ALS does not support any incremental retraining. In principle that is not difficult to do with ALS, but we haven't added thee code to do so. I will open an issue in the tracker to track this, in case anyone wants to add it :)

--
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/60377542-4217-48e7-860e-d886508e2f16%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/

Martijn- Augment KU Leuven

unread,
Jan 17, 2019, 11:14:55 AM1/17/19
to LensKit Recommender Toolkit Development and Support

Screen Shot 2019-01-17 at 5.11.38 PM.png

If I use an int64 as input of the userId I got this error message:

Traceback (most recent call last):
  File "/Users/martijn/Documents/Doctoraat/Lenskit/WebRec/ALS.py", line 61, in <module>
    recs = rec.recommend(first, 10) #Gives error
  File "/Users/martijn/anaconda3/envs/condaEnv/lib/python3.7/site-packages/lenskit/algorithms/basic.py", line 281, in recommend
    scores = self.predictor.predict_for_user(user, candidates, ratings)
  File "/Users/martijn/anaconda3/envs/condaEnv/lib/python3.7/site-packages/lenskit/algorithms/als.py", line 227, in predict_for_user
    return self.score_by_ids(user, items)
  File "/Users/martijn/anaconda3/envs/condaEnv/lib/python3.7/site-packages/lenskit/algorithms/mf_common.py", line 102, in score_by_ids
    iidx = self.lookup_items(items)
  File "/Users/martijn/anaconda3/envs/condaEnv/lib/python3.7/site-packages/lenskit/algorithms/mf_common.py", line 68, in lookup_items
    return self.item_index_.get_indexer(items)
  File "/Users/martijn/anaconda3/envs/condaEnv/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 3239, in get_indexer
    target = target.astype(object)
  File "/Users/martijn/anaconda3/envs/condaEnv/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 1286, in astype
    return self.copy() if copy else self
  File "/Users/martijn/anaconda3/envs/condaEnv/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 978, in copy
    new_index = self._shallow_copy()
  File "/Users/martijn/anaconda3/envs/condaEnv/lib/python3.7/site-packages/pandas/core/indexes/base.py", line 516, in _shallow_copy
    if not len(values) and 'dtype' not in kwargs:
TypeError: len() of unsized object




Michael Ekstrand

unread,
Jan 18, 2019, 12:50:29 PM1/18/19
to Martijn- Augment KU Leuven, LensKit Recommender Toolkit Development and Support
I suspect that the problem is a lack of a 'candidates' set, and the MF algorithms cannot currently produce a candidate list.


--
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.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages