autogluon.utils

Various built-in utility functions and objects that are used throughout AutoGluon.

Utils

save

Saves an object to local file.

load

Loads an object saved with save() from file.

download

Download files from a given URL.

unzip

Unzips files located at zip_file_path into parent directory specified by root.

check_sha1

Check whether the sha1 hash of the file content matches the expected hash.

mkdir

Make directory at the specified local path with special error handling.

save

autogluon.utils.save(obj, f, pickle_module=<module 'pickle' from '/var/lib/jenkins/miniconda3/envs/autogluon_docs-v0_0_15/lib/python3.7/pickle.py'>, pickle_protocol=2)

Saves an object to local file.

Parameters
objobject

Python object to save.

fstring or file object

A file-like object (has to implement write and flush), or a string containing a file name

pickle_modulepickle

Module used for pickling metadata and objects

pickle_protocolprotocol (optional)

Protocol can be specified to override the default pickle protocol.

Examples

>>> save(scheduler.state_dict(), checkname)

load

autogluon.utils.load(f, map_location=None, pickle_module=<module 'pickle' from '/var/lib/jenkins/miniconda3/envs/autogluon_docs-v0_0_15/lib/python3.7/pickle.py'>, **pickle_load_args)

Loads an object saved with save() from file.

Parameters
f (string or file object): a file-like object (has to implement write and flush)

or a string containing a file name

Examples

>>> scheduler.load_state_dict(load(checkpoint))

download

autogluon.utils.download(url, path=None, overwrite=False, sha1_hash=None)

Download files from a given URL.

Parameters
urlstr

URL where file is located

pathstr, optional

Destination path to store downloaded file. By default stores to the current directory with same name as in url.

overwritebool, optional

Whether to overwrite destination file if one already exists at this location.

sha1_hashstr, optional

Expected sha1 hash in hexadecimal digits (will ignore existing file when hash is specified but doesn’t match).

Returns
str

The file path of the downloaded file.

unzip

autogluon.utils.unzip(zip_file_path, root='./')

Unzips files located at zip_file_path into parent directory specified by root.

check_sha1

autogluon.utils.check_sha1(filename, sha1_hash)

Check whether the sha1 hash of the file content matches the expected hash.

Parameters
filenamestr

Path to the file.

sha1_hashstr

Expected sha1 hash in hexadecimal digits.

Returns
bool

Whether the file content matches the expected hash.

mkdir

autogluon.utils.mkdir(path)

Make directory at the specified local path with special error handling.