Skip to content

Commit

Permalink
added warning on pickle
Browse files Browse the repository at this point in the history
  • Loading branch information
david-cortes committed Jan 17, 2019
1 parent 824ed08 commit b1e2e37
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,21 +147,19 @@ Documentation is available at readthedocs: [http://hpfrec.readthedocs.io](http:/

It is also internally documented through docstrings (e.g. you can try `help(hpfrec.HPF))`, `help(hpfrec.HPF.fit)`, etc.

## Saving model with pickle
## Serializing (pickling) the model

Using pickle to save an `HPF` object might fail due to problems with lambda functions. The following solves it:
Don't use `pickle` to save an `HPF` object, as it will fail due to problems with lambda functions. Rather, use `dill` instead, which has the same syntax as pickle:

```python
import pickle
import dill
from hpfrec import HPF

h = HPF()
h.step_size = None
pickle.dump(h, open("HPF_obj.p", "wb"))
dill.dump(h, open("HPF_obj.dill", "wb"))
h = dill.load(open("HPF_obj.dill", "rb"))
```

(Be aware though that afterwards it won't be possible to use `partial_fit` or `add_user` with updates to item parameters.)

## Speeding up optimization procedure

For faster fitting and predictions, use SciPy and NumPy libraries compiled against MKL. In Windows, you can find Python wheels (installable with pip after downloading them) of numpy and scipy precompiled with MKL in [Christoph Gohlke's website](https://www.lfd.uci.edu/~gohlke/pythonlibs/). In Linux and Mac, these come by default in Anaconda installations (but are likely to get overwritten if you enable `conda-forge`). In some small experiments from my side, this yields a near 4x speedup compared to using free linear algebra libraries (for AMD cpu's, the speedup might not be as large).
Expand Down

0 comments on commit b1e2e37

Please sign in to comment.