save_joblib¶
- pyhelpers.store.save_joblib(data, path_to_file, verbose=False, **kwargs)[source]¶
Save data to a Joblib file.
- Parameters:
data (Any) – The data to be serialised and saved using joblib.dump().
path_to_file (str | os.PathLike) – The file path where the Joblib file will be saved.
verbose (bool | int) – Whether to print relevant information to the console; defaults to
False
.kwargs – [Optional] Additional parameters for the joblib.dump() function.
Examples:
>>> from pyhelpers.store import save_joblib >>> from pyhelpers.dirs import cd >>> from pyhelpers._cache import example_dataframe >>> import numpy as np >>> joblib_pathname = cd("tests\data", "dat.joblib") >>> # Example 1: >>> joblib_dat = example_dataframe().to_numpy() >>> joblib_dat array([[-0.1276474, 51.5073219], [-1.9026911, 52.4796992], [-2.2451148, 53.4794892], [-1.5437941, 53.7974185]]) >>> save_joblib(joblib_dat, joblib_pathname, verbose=True) Saving "dat.joblib" to "tests\data\" ... Done. >>> # Example 2: >>> np.random.seed(0) >>> joblib_dat = np.random.rand(100, 100) >>> joblib_dat array([[0.5488135 , 0.71518937, 0.60276338, ..., 0.02010755, 0.82894003, 0.00469548], [0.67781654, 0.27000797, 0.73519402, ..., 0.25435648, 0.05802916, 0.43441663], [0.31179588, 0.69634349, 0.37775184, ..., 0.86219152, 0.97291949, 0.96083466], ..., [0.89111234, 0.26867428, 0.84028499, ..., 0.5736796 , 0.73729114, 0.22519844], [0.26969792, 0.73882539, 0.80714479, ..., 0.94836806, 0.88130699, 0.1419334 ], [0.88498232, 0.19701397, 0.56861333, ..., 0.75842952, 0.02378743, 0.81357508]]) >>> save_joblib(joblib_dat, joblib_pathname, verbose=True) Updating "dat.joblib" at "tests\data\" ... Done.
See also
Examples for the function
pyhelpers.store.load_joblib()
.