save_joblib
- pyhelpers.store.save_joblib(joblib_data, path_to_joblib, verbose=False, **kwargs)
Save data to a Joblib file.
- Parameters:
joblib_data (any) – data that could be dumped by joblib.dump
path_to_joblib (str or os.PathLike[str]) – path where a pickle file is saved
verbose (bool or int) – whether to print relevant information in console, defaults to
False
kwargs – [optional] parameters of joblib.dump
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()
.