implicit icon indicating copy to clipboard operation
implicit copied to clipboard

How to optimise model parameters?

Open nicolaneo opened this issue 6 years ago • 5 comments

Hi! I'm just starting out so this may be a basic question: I'm using the lastfm dataset to get artist recommendations, with the lastfm.py example. I've removed 20% of each user's top-rated artists from the lastfm360k dataset (set their plays to zero in the plays matrix), and testing to see if they get recommended. I'm assuming I need to optimise the model parameters, since I'm going to train the model on the modified dataset. But I don't know how to optimise these parameters: number of factors, iterations and regularization. Would someone be able to explain how to do this? Also, do I need to also change the b25 weighting parameters, K1 and B, if I'm using ALS? Thanks!

nicolaneo avatar Sep 26 '20 11:09 nicolaneo

It's just like other machine learning models do.

One of easiest approaches is grid-search. Please refer to https://scikit-learn.org/stable/modules/grid_search.html

There're quite many rules-of-thumb for fitting ALS or BPR such that larger confidence values will work better for a more sparse dataset. Yet I can't find a good reference one.

Reading the original papers will be helpful too.

ita9naiwa avatar Oct 01 '20 05:10 ita9naiwa

@nicolaneo

If you want to implement GridSearch like @ita9naiwa mentioned, you should probably take a look at this link: https://gist.github.com/jbochi/2e8ddcc5939e70e5368326aa034a144e

kylemcmearty avatar Oct 08 '20 13:10 kylemcmearty

@nicolaneo - You might find Scikit-Optimize useful too, in particular I've had some success with BayesSearchCV in the past (depending on problem-size).

markdouthwaite avatar Oct 12 '20 18:10 markdouthwaite

@markdouthwaite - thanks for the BayesSearchCV tip. Looks like the Bayes search is as easy as swapping out GridSearch. When you say problem size, what kind of dimensions are we talking? My dataset consists of 1-2m~ transactions per quarter ranging across a few thousand customers and unique items.

kylemcmearty avatar Oct 13 '20 12:10 kylemcmearty

@kmcmearty - I've run BayesSearchCV with at least an order of magnitude more data on a moderately sized machine with no issues. Needed a bit of patience though!

markdouthwaite avatar Oct 14 '20 12:10 markdouthwaite