fetch_mnist_usps#

mlquantify.datasets.fetch_mnist_usps(*, data_home=None, download_if_missing=True, return_X_y=False, as_frame=False, n_retries=3, delay=1.0, protocol=None, n_samples=1000, sample_size=500, random_state=None, domain='mnist', subset='train')[source]#

MNIST -> USPS handwritten digits (image, covariate shift).

Two digit-image datasets selected with domain. mnist: 70000 28x28 grayscale images (60000 train / 10000 test) flattened to 784 features. usps: 9298 16x16 images (7291 train / 2007 test) flattened to 256 features. Both are 10-class; train on one domain, quantify the other for covariate shift.

Quantification: a digit covariate-shift pair (train on MNIST, quantify on USPS).

Samples

70000 (MNIST) / 9298 (USPS)

Features

784 (MNIST) / 256 (USPS)

Classes

10

Source: https://ossci-datasets.s3.amazonaws.com/mnist/ + LIBSVM usps

Parameters:
data_homestr or path-like, default=None

Folder used to cache the downloaded file(s); defaults to _data/ next to the package.

download_if_missingbool, default=True

If False, raise instead of downloading when the cache is empty.

return_X_ybool, default=False

Return (X, y) instead of a Bunch.

as_framebool, default=False

Return .data as a DataFrame, .target as a Series, and a combined .frame (features + a "target" column).

n_retriesint, default=3

Number of download attempts before giving up.

delayfloat, default=1.0

Seconds to wait between attempts.

protocol{None, “app”, “npp”, “upp”, “ppp”} or mlquantify protocol, default=None

If set, draw evaluation sample-bags with an mlquantify protocol; the Bunch then also has .samples (index bags into .data), .prevalences and .protocol.

n_samplesint, default=1000

Number of prevalence points (bags) generated by the protocol.

sample_sizeint, default=500

Instances per bag (the protocol batch_size).

random_stateint or None, default=None

Seed forwarded to the protocol.

domain{‘mnist’, ‘usps’}, default=’mnist’

Which domain to return.

subset{‘train’, ‘test’, ‘all’}, default=’train’

Which split to return.

Returns:
dataBunch

Dictionary-like object. Attributes: data (features), target (labels), feature_names, target_names, DESCR; frame when as_frame=True; and samples / prevalences / protocol when protocol is set.

(X, y)tuple

Returned instead when return_X_y=True.

References

LeCun, Y. et al. (1998); Hull, J. (1994).

Examples

>>> b = fetch_mnist_usps(domain='usps', subset='test'); b.data.shape  
(2007, 256)