fetch_olivetti_faces#

sklearn.datasets.fetch_olivetti_faces(*, data_home=None, shuffle=False, random_state=0, download_if_missing=True, return_X_y=False, n_retries=3, delay=1.0)[源代码]#

从 AT&T 加载 Olivetti faces 数据集(分类)。

Download it if necessary.

类别数

40

样本总数

400

维度

4096

特征值范围

实数,介于 0 和 1 之间

用户指南 中阅读更多内容。

参数:
data_homestr or path-like, default=None

为数据集指定另一个下载和缓存文件夹。默认情况下,所有 scikit-learn 数据都存储在 ‘~/scikit_learn_data’ 子文件夹中。

shufflebool, default=False

如果为 True,则打乱数据集顺序,以避免同一个人的图像被分在一起。

random_stateint, RandomState instance or None, default=0

Determines random number generation for dataset shuffling. Pass an int for reproducible output across multiple function calls. See Glossary.

download_if_missingbool, default=True

If False, raise an OSError if the data is not locally available instead of trying to download the data from the source site.

return_X_ybool, default=False

如果为 True,返回 (data, target) 而不是 Bunch 对象。有关 datatarget 对象的更多信息,请参阅下文。

版本 0.22 新增。

n_retriesint, default=3

Number of retries when HTTP errors are encountered.

1.5 版本新增。

delayfloat, default=1.0

Number of seconds between retries.

1.5 版本新增。

返回:
dataBunch

Dictionary-like object, with the following attributes.

data: ndarray, shape (400, 4096)

每一行对应一张展平后的面部图像,原始尺寸为 64 x 64 像素。

imagesndarray, shape (400, 64, 64)

每一行是对应于数据集中 40 个主体之一的面部图像。

targetndarray, shape (400,)

与每张面部图像关联的标签。这些标签范围从 0 到 39,对应于主体 ID。

DESCRstr

修改后的 Olivetti 人脸数据集说明。

(data, target)元组(如果 return_X_y=True

包含上述 datatarget 对象的元组。

版本 0.22 新增。

示例

>>> from sklearn.datasets import fetch_olivetti_faces
>>> olivetti_faces = fetch_olivetti_faces()
>>> olivetti_faces.data.shape
(400, 4096)
>>> olivetti_faces.target.shape
(400,)
>>> olivetti_faces.images.shape
(400, 64, 64)