sklearn.utils
.Memory¶
-
class
sklearn.utils.
Memory
(location=None, backend='local', cachedir=None, mmap_mode=None, compress=False, verbose=1, bytes_limit=None, backend_options=None)[source]¶ A context object for caching a function’s return value each time it is called with the same input arguments.
All values are cached on the filesystem, in a deep directory structure.
Read more in the User Guide.
Parameters: location: str or None
The path of the base directory to use as a data store or None. If None is given, no caching is done and the Memory object is completely transparent. This option replaces cachedir since version 0.12.
backend: str, optional
Type of store backend for reading/writing cache files. Default: ‘local’. The ‘local’ backend is using regular filesystem operations to manipulate data (open, mv, etc) in the backend.
cachedir: str or None, optional
mmap_mode: {None, ‘r+’, ‘r’, ‘w+’, ‘c’}, optional
The memmapping mode used when loading from cache numpy arrays. See numpy.load for the meaning of the arguments.
compress: boolean, or integer, optional
Whether to zip the stored data on disk. If an integer is given, it should be between 1 and 9, and sets the amount of compression. Note that compressed arrays cannot be read by memmapping.
verbose: int, optional
Verbosity flag, controls the debug messages that are issued as functions are evaluated.
bytes_limit: int, optional
Limit in bytes of the size of the cache.
backend_options: dict, optional
Contains a dictionnary of named parameters used to configure the store backend.
Attributes
cachedir
Methods
cache
([func, ignore, verbose, mmap_mode])Decorates the given function func to only compute its return value for input arguments not cached on disk. clear
([warn])Erase the complete cache directory. debug
(msg)eval
(func, *args, **kwargs)Eval function func with arguments *args and **kwargs, in the context of the memory. format
(obj[, indent])Return the formatted representation of the object. reduce_size
()Remove cache elements to make cache size fit in bytes_limit
.warn
(msg)-
__init__
(location=None, backend='local', cachedir=None, mmap_mode=None, compress=False, verbose=1, bytes_limit=None, backend_options=None)[source]¶
-
cache
(func=None, ignore=None, verbose=None, mmap_mode=False)[source]¶ Decorates the given function func to only compute its return value for input arguments not cached on disk.
Parameters: func: callable, optional
The function to be decorated
ignore: list of strings
A list of arguments name to ignore in the hashing
verbose: integer, optional
The verbosity mode of the function. By default that of the memory object is used.
mmap_mode: {None, ‘r+’, ‘r’, ‘w+’, ‘c’}, optional
The memmapping mode used when loading from cache numpy arrays. See numpy.load for the meaning of the arguments. By default that of the memory object is used.
Returns: decorated_func: MemorizedFunc object
The returned object is a MemorizedFunc object, that is callable (behaves like a function), but offers extra methods for cache lookup and management. See the documentation for
joblib.memory.MemorizedFunc
.
-