Ë
    êÿæi·  ã                   ó&  — d Z ddlmZmZ ddlmZmZ ddlmZ ddl	Z	ddl
ZddlmZ ddlmZ ddlmZmZmZmZ dd	lmZmZ dd
lmZmZ  eddd¬«      Z eeedgdgdgdgdg eeddd¬«      g eeddd¬«      gdœd¬«      ddddddddœd„«       Zy)a  Modified Olivetti faces dataset.

The original database was available from (now defunct)

    https://www.cl.cam.ac.uk/research/dtg/attarchive/facedatabase.html

The version retrieved here comes in MATLAB format from the personal
web page of Sam Roweis:

    https://cs.nyu.edu/~roweis/
é    )ÚIntegralÚReal)ÚPathLikeÚremove)ÚexistsN)Úloadmat)Úget_data_home)ÚRemoteFileMetadataÚ_fetch_remoteÚ_pkl_filepathÚ
load_descr)ÚBunchÚcheck_random_state)ÚIntervalÚvalidate_paramszolivettifaces.matz.https://ndownloader.figshare.com/files/5976027Ú@b612fb967f2dc77c9c62d3e1266e0c73d5fca46a4b8906c18e454d41af987794)ÚfilenameÚurlÚchecksumÚbooleanÚrandom_stateé   Úleft)Úclosedg        Úneither)Ú	data_homeÚshuffler   Údownload_if_missingÚ
return_X_yÚ	n_retriesÚdelayT)Úprefer_skip_nested_validationFé   g      ð?c                 ó†  — t        | ¬«      } t        | d«      }t        |«      s�|st        d«      ‚t	        dt
        j                  ›d| ›�«       t        t
        | ||¬«      }t        |¬«      }	t        |«       |	d   j                  j                  «       }
t        j                  |
|d	¬
«       ~	nt        j                  |«      }
t        j                   |
«      }
|
|
j#                  «       z
  }
|
|
j%                  «       z  }
|
j'                  d«      j)                  ddd«      }
t        j*                  t-        d«      D �cg c]  }|dz  ‘Œ	 c}«      }|r/t/        |«      }|j1                  t3        |
«      «      }|
|   }
||   }|
j'                  t3        |
«      d«      }t5        d«      }|r||fS t7        ||
||¬«      S c c}w )a  Load the Olivetti faces data-set from AT&T (classification).

    Download it if necessary.

    =================   =====================
    Classes                                40
    Samples total                         400
    Dimensionality                       4096
    Features            real, between 0 and 1
    =================   =====================

    Read more in the :ref:`User Guide <olivetti_faces_dataset>`.

    Parameters
    ----------
    data_home : str or path-like, default=None
        Specify another download and cache folder for the datasets. By default
        all scikit-learn data is stored in '~/scikit_learn_data' subfolders.

    shuffle : bool, default=False
        If True the order of the dataset is shuffled to avoid having
        images of the same person grouped.

    random_state : int, RandomState instance or None, default=0
        Determines random number generation for dataset shuffling. Pass an int
        for reproducible output across multiple function calls.
        See :term:`Glossary <random_state>`.

    download_if_missing : bool, 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_y : bool, default=False
        If True, returns `(data, target)` instead of a `Bunch` object. See
        below for more information about the `data` and `target` object.

        .. versionadded:: 0.22

    n_retries : int, default=3
        Number of retries when HTTP errors are encountered.

        .. versionadded:: 1.5

    delay : float, default=1.0
        Number of seconds between retries.

        .. versionadded:: 1.5

    Returns
    -------
    data : :class:`~sklearn.utils.Bunch`
        Dictionary-like object, with the following attributes.

        data: ndarray, shape (400, 4096)
            Each row corresponds to a ravelled
            face image of original size 64 x 64 pixels.
        images : ndarray, shape (400, 64, 64)
            Each row is a face image
            corresponding to one of the 40 subjects of the dataset.
        target : ndarray, shape (400,)
            Labels associated to each face image.
            Those labels are ranging from 0-39 and correspond to the
            Subject IDs.
        DESCR : str
            Description of the modified Olivetti Faces Dataset.

    (data, target) : tuple if `return_X_y=True`
        Tuple with the `data` and `target` objects described above.

        .. versionadded:: 0.22

    Examples
    --------
    >>> 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)
    )r   zolivetti.pkzz1Data not found and `download_if_missing` is Falsez downloading Olivetti faces from z to )Údirnamer    r!   )Ú	file_nameÚfacesé   )Úcompress)é�  é@   r+   r   é   r   r*   é
   éÿÿÿÿzolivetti_faces.rst)ÚdataÚimagesÚtargetÚDESCR)r	   r   r   ÚOSErrorÚprintÚFACESr   r   r   r   ÚTÚcopyÚjoblibÚdumpÚloadÚnpÚfloat32ÚminÚmaxÚreshapeÚ	transposeÚarrayÚranger   ÚpermutationÚlenr   r   )r   r   r   r   r   r    r!   ÚfilepathÚmat_pathÚmfiler'   Úir1   ÚorderÚfaces_vectorizedÚfdescrs                   úu/Volumes/fast/ai/experiments/voice-extract-mac/.venv/lib/python3.12/site-packages/sklearn/datasets/_olivetti_faces.pyÚfetch_olivetti_facesrM   +   s�  € ôP ¨	Ô2€IÜ˜Y¨Ó7€HÜ�(ÔÙ"ÜÐMÓNÐNå¼E¿I»IÁyÐQÔRÜ Ü˜9°	Àô
ˆô  (Ô+ˆäˆxÔà�g‘× Ñ ×%Ñ%Ó'ˆÜ�‰�E˜8¨aÕ0Ùä—‘˜HÓ%ˆô �J‰J�uÓ€EØ�E—I‘I“KÑ€EØ	ˆU�Y‰Y‹[Ñ€EØ�M‰M˜-Ó(×2Ñ2°1°a¸Ó;€Eä�X‰X¬¨c¬
Ó3©
 1�q˜B“w¨
Ñ3Ó4€FÙÜ)¨,Ó7ˆØ×(Ñ(¬¨U«Ó4ˆØ�e‘ˆØ˜‘ˆØ—}‘}¤S¨£Z°Ó4ÐäÐ,Ó-€FáØ Ð'Ð'äÐ&¨u¸VÈ6ÔRÐRùò 4s   Ä?F>)Ú__doc__Únumbersr   r   Úosr   r   Úos.pathr   r8   Únumpyr;   Úscipy.ior   Úsklearn.datasetsr	   Úsklearn.datasets._baser
   r   r   r   Úsklearn.utilsr   r   Úsklearn.utils._param_validationr   r   r5   ÚstrrM   © ó    rL   Ú<module>r[      sÇ   ðñ
÷ #ß Ý ã Û Ý å *÷ó ÷ 4ß Eñ 	Ø Ø8ØOô	€ñ à˜8 TÐ*Ø�;Ø'Ð(Ø )˜{Ø �kÙ˜x¨¨D¸Ô@ÐAÙ˜4  d°9Ô=Ð>ñð #'ôð ØØØØØØ
óDSóñDSrZ   