
     h                         d Z ddlmZ ddlmZmZ ddlZddlm	Z	 ddl
Z
ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZmZ  eddd          ZdddddddZdS )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/
    )exists)makedirsremoveN)loadmat   )get_data_home)_fetch_remote)RemoteFileMetadata)_pkl_filepath)
load_descr   )check_random_stateBunchzolivettifaces.matz.https://ndownloader.figshare.com/files/5976027@b612fb967f2dc77c9c62d3e1266e0c73d5fca46a4b8906c18e454d41af987794)filenameurlchecksumFT)	data_homeshufflerandom_statedownload_if_missing
return_X_yc                 H   t          |           } t          |           st          |            t          | d          }t          |          s|st	          d          t          dt          j        d|            t          t          |           }t          |          }t          |           |d         j                                        }t          j        ||d	
           ~nt          j        |          }t!          j        |          }||                                z
  }||                                z  }|                    d                              ddd          }t!          j        d t/          d          D                       }	|rAt1          |          }|                    t5          |                    }
||
         }|	|
         }	|                    t5          |          d          }t7          d          }|r||	fS t9          |||	|          S )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, 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 a IOError 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

    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
    )r   zolivetti.pkzz1Data not found and `download_if_missing` is Falsez downloading Olivetti faces from z to )dirname)	file_namefaces   )compress)  @   r    r   r   r   c                     g | ]}|d z  S )
    ).0is     \/var/www/html/Sam_Eipo/venv/lib/python3.11/site-packages/sklearn/datasets/_olivetti_faces.py
<listcomp>z(fetch_olivetti_faces.<locals>.<listcomp>   s    3331qBw333    r   zolivetti_faces.rst)dataimagestargetDESCR)r   r   r   r   IOError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   filepathmat_pathmfiler   r,   orderfaces_vectorizedfdescrs                r&   fetch_olivetti_facesrF   '   s	   J 	222I) Y77H( &" 	OMNNNEIIIyyQRRR 	:::(+++xg %%''E8a0000EH%% JuEEIIKKE	UYY[[EMM-((221a;;EX33c

33344F ),77((U44e}}SZZ44,--F (''&uV6RRRRr(   )__doc__os.pathr   osr   r   numpyr6   scipy.ior   r3    r   _baser	   r
   r   r   utilsr   r   r0   rF   r#   r(   r&   <module>rO      s8  
 
                                            % % % % % %                   - - - - - - - - 	 8O	 	 	 mS mS mS mS mS mS mSr(   