def fetch_gpml_usps_resampled_data(transpose_data=True, data_home=None):
    """
    Fetch the USPS handwritten digits dataset from the internet and parse
    appropriately into python arrays

    >>> usps_resampled = fetch_gpml_usps_resampled_data()

    >>> usps_resampled.train.targets.shape
    (4649,)

    >>> usps_resampled.train.targets # doctest: +ELLIPSIS
    array([6, 0, 1, ..., 9, 2, 7])

    >>> usps_resampled.train.data.shape
    (4649, 256)

    >>> np.all(-1 <= usps_resampled.train.data)
    True

    >>> np.all(usps_resampled.train.data < 1)
    True

    >>> usps_resampled.test.targets.shape
    (4649,)

    >>> usps_resampled.test.data.shape
    (4649, 256)

    >>> usps_resampled = fetch_gpml_usps_resampled_data(transpose_data=False)
    >>> usps_resampled.train.data.shape
    (256, 4649)
    """
    data_home = get_data_home(data_home=data_home)
    data_filename = os.path.join(data_home,
                                 'usps_resampled/usps_resampled.mat')

    if not os.path.exists(data_filename):

        r = requests.get('http://www.gaussianprocess.org/gpml/data/'
                         'usps_resampled.tar.bz2')

        with tarfile.open(fileobj=BytesIO(r.content)) as tar_infile:
            tar_infile.extract('usps_resampled/usps_resampled.mat',
                               path=data_home)

    matlab_dict = loadmat(data_filename)

    train_data = matlab_dict['train_patterns']
    test_data = matlab_dict['test_patterns']

    if transpose_data:
        train_data = train_data.T
        test_data = test_data.T

    train_targets = matlab_dict['train_labels'].T
    train_targets = np.argwhere(train_targets == 1)[:, 1]

    test_targets = matlab_dict['test_labels'].T
    test_targets = np.argwhere(test_targets == 1)[:, 1]

    train_bunch = Bunch(data=train_data,
                        targets=train_targets)

    test_bunch = Bunch(data=test_data,
                       targets=test_targets)

    return Bunch(train=train_bunch, test=test_bunch)
Fetch the USPS handwritten digits dataset from the internet and parse
    appropriately into python arrays

    >>> usps_resampled = fetch_gpml_usps_resampled_data()

    >>> usps_resampled.train.targets.shape
    (4649,)

    >>> usps_resampled.train.targets # doctest: +ELLIPSIS
    array([6, 0, 1, ..., 9, 2, 7])

    >>> usps_resampled.train.data.shape
    (4649, 256)

    >>> np.all(-1 <= usps_resampled.train.data)
    True

    >>> np.all(usps_resampled.train.data < 1)
    True

    >>> usps_resampled.test.targets.shape
    (4649,)

    >>> usps_resampled.test.data.shape
    (4649, 256)

    >>> usps_resampled = fetch_gpml_usps_resampled_data(transpose_data=False)
    >>> usps_resampled.train.data.shape
    (256, 4649)