Recommenders: Memoization (Caching)

Created on 4 Apr 2019  路  6Comments  路  Source: microsoft/recommenders

Description

Some of the more computer intensive functions could make use of memoization/caching.
Hashing pandas and numpy arrays is key to this
https://stackoverflow.com/questions/16589791/most-efficient-property-to-hash-for-numpy-array
https://stackoverflow.com/questions/31567401/get-the-same-hash-value-for-a-pandas-dataframe-each-time

Expected behavior with the suggested feature

The memoization/caching function will simply be a dict that uses the hash as a key and returns the item.

computational improvement enhancement

Most helpful comment

addressed in #713

All 6 comments

looks useful, though it seems like this would be difficult to extend to dataframes? with the numpy arrays you can convert the array to a hashable tuple and then convert it back, pd.util.hash_pandas_object wouldn't let you convert back to the unhashed object. is it possible to convert the dataframe differently so that we could undo it, or possibly ignore arguments passed to lru_cache (i.e. pass both the hashed and the unhashed df and ignore the unhashed during caching, but use the unhashed in the function)

Hashing is only used for indexing in the dict the daraframe or other pandas object would be stored as is. What were you thinking of doing @gramhagen ?

oh, are you thinking we can rewrite the underlying hashing approach inside lru_cache?

Yes

addressed in #713

Was this page helpful?
0 / 5 - 0 ratings

Related issues

miguelgfierro picture miguelgfierro  路  5Comments

roalexan picture roalexan  路  4Comments

miguelgfierro picture miguelgfierro  路  3Comments

roalexan picture roalexan  路  6Comments

luiscastro193 picture luiscastro193  路  5Comments