fetch_file#

sklearn.datasets.fetch_file(url,folder=None,local_filename=None,sha256=None,n_retries=3,delay=1)[source]#

Fetch a file from the web if not already present in the local folder.

If the file already exists locally (and the SHA256 checksums match whenprovided), the path to the local file is returned without re-downloading.

Added in version 1.6.

Parameters:
urlstr

URL of the file to download.

folderstr or Path, default=None

Directory to save the file to. If None, the file is downloaded in afolder with a name derived from the URL host name and path underscikit-learn data home folder.

local_filenamestr, default=None

Name of the file to save. If None, the filename is inferred from theURL.

sha256str, default=None

SHA256 checksum of the file. If None, no checksum is verified.

n_retriesint, default=3

Number of retries when HTTP errors are encountered.

delayint, default=1

Number of seconds between retries.

Returns:
file_pathPath

Full path of the downloaded file.

Gallery examples#

Lagged features for time series forecasting

Lagged features for time series forecasting