cosanlab / neighbors

A package to perform collaborative filtering on emotion datasets.
https://cosanlab.github.io/neighbors
MIT License
10 stars 8 forks source link

Make sure optimization actually stops when threshold is achieved #21

Closed ljchang closed 3 years ago

ljchang commented 6 years ago

Might only be working with number of iterations.

ngreenstein commented 5 years ago

For NNMF_multiplicative:

Based on the existing code, I'm assuming the threshold in question is fit_residual falling below fit_error_limit. 128c7bf implements this.

For NNMF_sgd:

Currently, nothing analogous to fit_error_limit exists, although the docstring suggests that it should. That's easy to add, but (assuming this is the goal), we'd also have to add a step that computes something analogous to fit_residual. I think that requires calling predict() after each iteration, which would have a performance cost.

Do you think it's worth implementing this for NNMF_sgd? Happy to do it if so, just wanted to check if it makes sense.

ljchang commented 5 years ago

I think the pattern that might make more sense is to loop over iterations and then break of residual is lower than the tolerance.

Check out some of the sklearn algorithms, such as NNMF https://github.com/scikit-learn/scikit-learn/blob/master/sklearn/decomposition/nmf.py

ngreenstein commented 5 years ago

Sure, can definitely do that. It probably also makes sense to check every 10 iterations, as sklearn does, instead of each time.

One question on the math: sklearn is calculating error by comparing current error to the initial error from before fitting began. With multiplicative updating, (previous error - current error) / initial error (link), and with coordinate descent, current error / initial error (link).

Should we do the same?

ljchang commented 5 years ago

Here are some quick thoughts

1) Let's go with percent error threshold 2) Let's add a rate of change threshold 3) let's try to match Sci-kit learn's defaults in terms of order of operations.