
    0Ph'                     b   d dl Z d dlZd dlZd dlZd dl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mZmZmZmZmZm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 m!Z! d
dl"m#Z# d
dl$m%Z%m&Z&m'Z'm(Z(m)Z) ddl*m+Z+ ddl,m-Z- dgZ.dZ/dZ0dZ1dZ2dZ3dZ4eee5e5f                  Z6eee5e5f                  Z7de5de5de5fdZ8	 dUde5dee5         dee9         defdZ:	 dVd!e;d"e<d#e5defd$Z=	 dWde5dee5         d!e;d"e<fd%Z> G d& d'e?          Z@	 	 dWd#e5d(ee5         dee5         d!e;d"e<defd)ZA	 	 dWd*e5d+ee;e5f         dee5         d!e;d"e<f
d,ZB	 	 dWd-e;dee5         d!e;d"e<dee5ef         f
d.ZC	 	 dWd-e;dee5         d!e;d"e<de7f
d/ZD	 	 dWd-e;dee5         d!e;d"e<de6f
d0ZEd1e6de;fd2ZF	 	 	 dXd#e5dee5         d3e5d4e5d5eGd6ee5         d7ee5         d8eee;e;f                  d9e5d!e;d"e<d:ee         fd;ZHdddd<d#e5d=eIdee5         d>eId5eeG         d?ee5         d@ee5         d8eee;e;f                  d9e5d!e;d"e<d3e5d:ee         fdAZJdB ZKdC ZL e)e5dg e&e%dddDE           e(dFh          g e&e%dddDE          dge5ejM        dge5eNdgeIgeIgeI e(dGh          g e&e%dddDE          g e&e'dHddIE          g e(h dJ          geGdgdKdLM          	 dUdFdddNdLdOdGdddGddPd*ee5         d+ee5e;f         d-ee;         deee5ejM        f                  dQeee5ef                  dReIdSeId>ee5eIf         d!e;d"e<d3e5d:ee         fdT            ZOdS )Y    N)closingwraps)join)TemporaryDirectory)AnyCallableDictListOptionalTupleUnion)	HTTPErrorURLError)Requesturlopen)warn   )Bunch)check_pandas_support)IntegralIntervalReal
StrOptionsvalidate_params   )get_data_home)load_arff_from_gzip_filefetch_openmlzhttps://api.openml.org/z*api/v1/json/data/list/data_name/{}/limit/2zapi/v1/json/data/{}zapi/v1/json/data/features/{}zapi/v1/json/data/qualities/{}zdata/v1/download/{}openml_path	data_homereturnc                 J    t           j                            |d| dz             S )Nz
openml.orgz.gz)ospathr   )r    r!   s     X/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sklearn/datasets/_openml.py_get_local_pathr'   .   s    7<<	<u1DEEE    no_retry_exceptionc                       fd}|S )a!  If the first call to the decorated function fails, the local cached
    file is removed, and the function is called again. If ``data_home`` is
    ``None``, then the function is called once. We can provide a specific
    exception to not retry on using `no_retry_exception` parameter.
    c                 D     t                      fd            }|S )Nc                  R    | i |S 	  | i |S # t           $ r  t          $ r}}t          |          r t          dt                     t                    }t          j                            |          rt          j	        |            | i |cY d }~S d }~ww xY w)Nz!Invalid cache, redownloading file)
r   	Exception
isinstancer   RuntimeWarningr'   r$   r%   existsunlink)argskwexc
local_pathr!   fr)   r    s       r&   wrapperz;_retry_with_clean_cache.<locals>.decorator.<locals>.wrapper>   s     q$~"~~%&q$~"~~%    	& 	& 	&%1j+7 71 8.III,[)DD
7>>*-- *Ij)))q$~"~~%%%%%%	&s    B&A2B!B&!B&r   )r6   r7   r!   r)   r    s   ` r&   	decoratorz*_retry_with_clean_cache.<locals>.decorator=   sC    	q	& 	& 	& 	& 	& 	& 	& 
	&$ r(    )r    r!   r)   r8   s   ``` r&   _retry_with_clean_cacher:   2   s0          , r(            ? 	n_retriesdelayurlc                       fd}|S )aU  If the function call results in a network error, call the function again
    up to ``n_retries`` times with a ``delay`` between each call. If the error
    has a 412 status code, don't call the function again as this is a specific
    OpenML error.
    The url parameter is used to give more information to the user about the
    error.
    c                 D     t                      fd            }|S )Nc                     }	 	  | i |S # t           t          f$ r^}t          |t                    r|j        dk    r |dk    r t          d d           |dz  }t          j                   Y d }~nd }~ww xY w|)NT  r   z+A network error occurred while downloading z. Retrying...r   )r   TimeoutErrorr.   r   coder   timesleep)r2   kwargsretry_counterer?   r6   r>   r@   s       r&   r7   z;_retry_on_network_error.<locals>.decorator.<locals>.wrapperb   s    %M&&1d-f--- ,/ 
& 
& 
&!!Y// AFcMM$))XcXXX   "Q&MJu%%%%%%%%
&&s    A=AA88A=r   )r6   r7   r?   r>   r@   s   ` r&   r8   z*_retry_on_network_error.<locals>.decoratora   sC    	q	& 	& 	& 	& 	& 	& 	& 
	&" r(   r9   )r>   r?   r@   r8   s   ``` r&   _retry_on_network_errorrL   V   s0          * r(   c           
         d }t          t          | z             }|                    dd           |P  t          |||j                  t
                    |          } ||          rt          j        |d          S |S t          | |          }t          j
                            |          \  }}	t          j
                            |          sdt          j        |d           	 t          |	          5 }
t            t          |||j                  t
                    |                    5 } ||          rt           }nt          j        } |t          j
                            |
|	          d
          5 }t%          j        ||           ddd           n# 1 swxY w Y   ddd           n# 1 swxY w Y   t%          j        |j        |           ddd           n# 1 swxY w Y   nB# t,          $ r5 t          j
                            |          rt          j        |            w xY wt          j        |d          S )a  
    Returns a resource from OpenML.org. Caches it to data_home if required.

    Parameters
    ----------
    openml_path : str
        OpenML URL that will be accessed. This will be prefixes with
        _OPENML_PREFIX.

    data_home : str
        Directory to which the files will be cached. If None, no caching will
        be applied.

    n_retries : int, default=3
        Number of retries when HTTP errors are encountered. Error with status
        code 412 won't be retried as they represent OpenML generic errors.

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

    Returns
    -------
    result : stream
        A stream to the OpenML resource.
    c                 Z    |                                                      dd          dk    S )NzContent-Encodingr=   gzip)infoget)_fsrcs    r&   is_gzip_encodedz)_open_openml_url.<locals>.is_gzip_encoded   s&    zz|| 2B776AAr(   zAccept-encodingrO   Nrb)fileobjmodeT)exist_ok)dirwb)r   _OPENML_PREFIX
add_headerrL   full_urlr   rO   GzipFiler'   r$   r%   splitr0   makedirsr   r   openr   shutilcopyfileobjmovenamer-   r1   )r    r!   r>   r?   rS   reqfsrcr5   dir_name	file_nametmpdiropenerfdsts                r&   _open_openml_urlrl   y   s   :B B B .;.
/
/CNN$f---OF&y%FFwOOPSTT?4   	:=D9999 i88J'--
33Hi7>>*%% 
Ht,,,,	
 $111 3VTK+IuclKKGTT   7 &t,, /!%!%VY ? ?FF 7$*46667 7 7 7 7 7 7 7 7 7 7 7 7 7 77 7 7 7 7 7 7 7 7 7 7 7 7 7 7 DIz2223 3 3 3 3 3 3 3 3 3 3 3 3 3 3  	 	 	w~~j)) &	*%%%	 =T***sy   ,G7 <;G+7A
F:F#F:#F''F:*F'+F:.G+:F>	>G+F>	G+G7 +G//G7 2G/3G7 7?H6c                       e Zd ZdZdS )OpenMLErrorzDHTTP 412 is a specific OpenML error code, indicating a generic errorN)__name__
__module____qualname____doc__r9   r(   r&   rn   rn      s        NNDr(   rn   error_messagec                      t                      fd            }	  |            S # t          $ r}|j        dk    r|Y d}~nd}~ww xY wt          |          )a  
    Loads json data from the openml api.

    Parameters
    ----------
    url : str
        The URL to load from. Should be an official OpenML endpoint.

    error_message : str or None
        The error message to raise if an acceptable OpenML error is thrown
        (acceptable error is, e.g., data id not found. Other errors, like 404's
        will throw the native error message).

    data_home : str or None
        Location to cache the response. None if no cache is required.

    n_retries : int, default=3
        Number of retries when HTTP errors are encountered. Error with status
        code 412 won't be retried as they represent OpenML generic errors.

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

    Returns
    -------
    json_data : json
        the json result from the OpenML server if the call was successful.
        An exception otherwise.
    r!   c                      t          t                              5 } t          j        |                                                     d                    cd d d            S # 1 swxY w Y   d S )Nr>   r?   zutf-8)r   rl   jsonloadsreaddecode)responser!   r?   r>   r@   s    r&   
_load_jsonz5_get_json_content_from_openml_api.<locals>._load_json   s    S)yNNN
 
 	?:hmmoo44W==>>	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	? 	?s   9A((A,/A,rD   N)r:   r   rF   rn   )r@   rs   r!   r>   r?   r}   errors   ` ```  r&   !_get_json_content_from_openml_apir      s    J SI666? ? ? ? ? ? ? 76?z||    :K  m
$
$$s   	/ 
AAArd   versionc                    |dk    rt                               |           dz   }d                    |           }t          |||||          }|d         d         }t          |          dk    rT|d         d	         x}	}d
|  d|	 d}
|D ])}|
d|d	          d|d          dz  }
|
d|d          dz  }
*t	          |
           |d         S t           dz                       | |          }	 t          |d|||          }n?# t
          $ r2 |dz  }d                    | |          }t          |||||          }Y nw xY w|d         d         d         S )a?  
    Utilizes the openml dataset listing api to find a dataset by
    name/version
    OpenML api function:
    https://www.openml.org/api_docs#!/data/get_data_list_data_name_data_name

    Parameters
    ----------
    name : str
        name of the dataset

    version : int or str
        If version is an integer, the exact name/version will be obtained from
        OpenML. If version is a string (value: "active") it will take the first
        version from OpenML that is annotated as active. Any other string
        values except "active" are treated as integer.

    data_home : str or None
        Location to cache the response. None if no cache is required.

    n_retries : int, default=3
        Number of retries when HTTP errors are encountered. Error with status
        code 412 won't be retried as they represent OpenML generic errors.

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

    Returns
    -------
    first_dataset : json
        json representation of the first dataset object that adhired to the
        search criteria

    activez/status/active/zNo active dataset {} found.r!   r>   r?   datadatasetr   r   r   z:Multiple active versions of the dataset matching the name zC exist. Versions may be fundamentally different, returning version z. Available versions:
z
- version z
, status: status
z2  url: https://www.openml.org/search?type=data&id=didz/data_version/{}N)rs   r!   r>   r?   z/status/deactivatedz%Dataset {} with version {} not found.)_SEARCH_NAMEformatr   lenr   rn   )rd   r   r!   r>   r?   r@   	error_msg	json_dataresfirst_versionwarning_msgrs               r&   _get_data_info_by_namer     s   R (!!$''*;;188>>	5
 
 
	 	*s88a<<&)!fY&77MG(( (%2( ( (    SAiLSSAhKSSSSU5UUU 1v ,,
4
4T7
C
CC
5
 
 
		  
 
 

 	$$;BB4QQ	5
 
 
			
 VY'**s   )C> >9D:9D:data_idc                     t                               |           }d                    |           }t          |||||          }|d         S )N"Dataset with data_id {} not found.r   data_set_description)
_DATA_INFOr   r   r   r!   r>   r?   r@   rs   r   s          r&   _get_data_description_by_idr   b  s[     

G
$
$C8??HHM1  I +,,r(   c                     t                               |           }d                    |           }t          |||||          }|d         d         S )Nr   r   data_featuresfeature)_DATA_FEATURESr   r   r   s          r&   _get_data_featuresr   u  s_     


(
(C8??HHM1  I _%i00r(   c                     t                               |           }d                    |           }t          |||||          }|                    di                               dg           S )Nr   r   data_qualitiesquality)_DATA_QUALITIESr   r   rQ   r   s          r&   _get_data_qualitiesr     st     
 
 
)
)C8??HHM1  I ==)2..229bAAAr(   r   c                 ~    d}d | D             }t          t          |                    d|                              S )aJ  Get the number of samples from data qualities.

    Parameters
    ----------
    data_qualities : list of dict
        Used to retrieve the number of instances (samples) in the dataset.

    Returns
    -------
    n_samples : int
        The number of samples in the dataset or -1 if data qualities are
        unavailable.
    c                 ,    i | ]}|d          |d         S )rd   valuer9   ).0ds     r&   
<dictcomp>z$_get_num_samples.<locals>.<dictcomp>  s"    ???16AgJ???r(   NumberOfInstances)intfloatrQ   )r   default_n_samples	qualitiess      r&   _get_num_samplesr     sC     ?????IuY]]#68IJJKKLLLr(   parseroutput_typeopenml_columns_infofeature_names_to_selecttarget_names_to_selectshapemd5_checksumread_csv_kwargsc           	         t          | ||	|
          t                    5  t          j                    }t	          fdd          D ]}|                    |           |                                }ddd           n# 1 swxY w Y   ||k    rt          d|  d| d| d          d	 }t          |||||||pi 
          }	  || ||	|
|          \  }}}}ne# t          $ rX}|dk    r ddl
m} t          ||          s |d                             d            || ||	|
|          \  }}}}Y d}~nd}~ww xY w||||fS )a  Load the ARFF data associated with the OpenML URL.

    In addition of loading the data, this function will also check the
    integrity of the downloaded file from OpenML using MD5 checksum.

    Parameters
    ----------
    url : str
        The URL of the ARFF file on OpenML.

    data_home : str
        The location where to cache the data.

    parser : {"liac-arff", "pandas"}
        The parser used to parse the ARFF file.

    output_type : {"numpy", "pandas", "sparse"}
        The type of the arrays that will be returned. The possibilities are:

        - `"numpy"`: both `X` and `y` will be NumPy arrays;
        - `"sparse"`: `X` will be sparse matrix and `y` will be a NumPy array;
        - `"pandas"`: `X` will be a pandas DataFrame and `y` will be either a
          pandas Series or DataFrame.

    openml_columns_info : dict
        The information provided by OpenML regarding the columns of the ARFF
        file.

    feature_names_to_select : list of str
        The list of the features to be selected.

    target_names_to_select : list of str
        The list of the target variables to be selected.

    shape : tuple or None
        With `parser="liac-arff"`, when using a generator to load the data,
        one needs to provide the shape of the data beforehand.

    md5_checksum : str
        The MD5 checksum provided by OpenML to check the data integrity.

    n_retries : int, default=3
        The number of times to retry downloading the data if it fails.

    delay : float, default=1.0
        The delay between two consecutive downloads in seconds.

    read_csv_kwargs : dict, default=None
        Keyword arguments to pass to `pandas.read_csv` when using the pandas parser.
        It allows to overwrite the default options.

        .. versionadded:: 1.3

    Returns
    -------
    X : {ndarray, sparse matrix, dataframe}
        The data matrix.

    y : {ndarray, dataframe, series}
        The target.

    frame : dataframe or None
        A dataframe containing both `X` and `y`. `None` if
        `output_array_type != "pandas"`.

    categories : list of str or None
        The names of the features that are categorical. `None` if
        `output_array_type == "pandas"`.
    rw   c                  .                          d          S )Ni   )rz   )	gzip_files   r&   <lambda>z%_load_arff_response.<locals>.<lambda>
  s    ).."6"6 r(   r(   Nzmd5 checksum of local file for z' does not match description: expected: z	 but got zP. Downloaded file could have been modified / corrupted, clean cache and retry...c                     t          | |||          }t          |          5  t          |fi |cd d d            S # 1 swxY w Y   d S )Nrw   )rl   r   r   )r@   r!   r>   r?   arff_paramsr   s         r&   _open_url_and_load_gzip_filez9_load_arff_response.<locals>._open_url_and_load_gzip_file  s    $S)yPUVVV	Y 	F 	F+IEEEE	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	F 	Fs   =AA)r   r   r   r   r   r   r   pandasr   ParserErrorr   ')	quotechar)rl   r   hashlibmd5iterupdate	hexdigest
ValueErrordictr-   pandas.errorsr   r.   )r@   r!   r   r   r   r   r   r   r   r>   r?   r   r   chunkactual_md5_checksumr   r   Xyframe
categoriesr4   r   r   s                          @r&   _load_arff_responser     sD   f !i9ERRRI			 . .kmm6666<< 	 	EJJu!mmoo	. . . . . . . . . . . . . . . l**c  % 0C  
 
 	
F F F
 / 75'-2  K
">">Iuk#
 #
1eZZ  
 
 
X------#{++ 	
 	%&---<<<">">Iuk#
 #
1eZZZZZZ
" a
""s+   ABB
B	C 
E (AD;;E )r>   r?   r   sparseas_framedata_columnstarget_columnsc       
            d |D             }|rd}n|rd}nd}t          ||           |D ]A}||         }t          |d                   }|dk    rt          d|d          d	| d
          Bd}|dk    rddlm} |}  t          | ||          t                    | |||||||||	|
|          \  }}}}t          ||||||          S )a  Download ARFF data, load it to a specific container and create to Bunch.

    This function has a mechanism to retry/cache/clean the data.

    Parameters
    ----------
    url : str
        The URL of the ARFF file on OpenML.

    sparse : bool
        Whether the dataset is expected to use the sparse ARFF format.

    data_home : str
        The location where to cache the data.

    as_frame : bool
        Whether or not to return the data into a pandas DataFrame.

    openml_columns_info : list of dict
        The information regarding the columns provided by OpenML for the
        ARFF dataset. The information is stored as a list of dictionaries.

    data_columns : list of str
        The list of the features to be selected.

    target_columns : list of str
        The list of the target variables to be selected.

    shape : tuple or None
        With `parser="liac-arff"`, when using a generator to load the data,
        one needs to provide the shape of the data beforehand.

    md5_checksum : str
        The MD5 checksum provided by OpenML to check the data integrity.

    n_retries : int, default=3
        Number of retries when HTTP errors are encountered. Error with status
        code 412 won't be retried as they represent OpenML generic errors.

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

    parser : {"liac-arff", "pandas"}
        The parser used to parse the ARFF file.

    read_csv_kwargs : dict, default=None
        Keyword arguments to pass to `pandas.read_csv` when using the pandas parser.
        It allows to overwrite the default options.

        .. versionadded:: 1.3

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

        X : {ndarray, sparse matrix, dataframe}
            The data matrix.
        y : {ndarray, dataframe, series}
            The target.
        frame : dataframe or None
            A dataframe containing both `X` and `y`. `None` if
            `output_array_type != "pandas"`.
        categories : list of str or None
            The names of the features that are categorical. `None` if
            `output_array_type == "pandas"`.
    c                      i | ]}|d          |S )rd   r9   r   r   s     r&   r   z+_download_data_to_bunch.<locals>.<dictcomp>  s    QQQ'WV_gQQQr(   r   r   numpynumber_of_missing_valuesr   zTarget column 'rd   z' has zE missing values. Missing values are not supported for target columns.Nr   )
r   r   r   r   r   r   r   r>   r?   r   )r   targetr   r   feature_namestarget_names)_verify_target_data_typer   r   r   r   r:   r   r   )r@   r   r!   r   r   r   r   r   r   r>   r?   r   r   features_dictr   rd   column_infon_missing_valuesr)   r   r   r   r   r   s                           r&   _download_data_to_bunchr   <  s   h RQ=PQQQM 	  ]N;;;  #D){+EFGGaO+f"5 O O=M O O O      	.-----( 5Y*   	) ,-!'  Aq%" "#   r(   c                 2   t          |t                    st          dt          |          z            t	                      }|D ]}|| vrt          d| d          | |         d         dk    r |                    t          j                   n|                    t                     | |         d         dk    rt          d| d	           | |         d
         dk    rt          d| d           t          |          dk    rt          d          d S )Nz%target_column should be list, got: %szCould not find target_column='r   	data_typenumeric	is_ignoretrueztarget_column='z' has flag is_ignore.is_row_identifierz' has flag is_row_identifier.r   zgCan only handle homogeneous multi-target datasets, i.e., all targets are either numeric or categorical.)r.   listr   typesetKeyErroraddnpfloat64objectr   r   )r   r   found_typestarget_columns       r&   r   r     sD    nd++ Y@4CWCWWXXX%%K' Q Q--LMLLLMMM'4	AAOOBJ''''OOF### '4>>G=GGGHHH'(;<FFO=OOOPPP
;!
 
 	
 r(   c                     g }| D ]?}|d         |vr3|d         dk    r'|d         dk    r|                     |d                    @|S )Nrd   r   r   r   )append)features_listr   valid_data_column_namesr   s       r&   _valid_data_column_namesr     sh    
 !  < <FO>11$..+,66#**76?;;;""r(   left)closedr   autog        neither>   r   r   	liac-arff)rd   r   r   r!   r   cache
return_X_yr   r>   r?   r   r   T)prefer_skip_nested_validationdefault-targetF)r   r   r!   r   r   r   r   r>   r?   r   r   r   r   r   c                   |du rd}n-t          |          }t          t          |          d          }| V|                                 } |#t	          d                    ||                     t          | ||||	          }|d         }n;|*|dk    r#t	          d	                    ||                    nt	          d
          t          ||          }|d         dk    r6t          d                    |d         |d         |d                              d|v r(t          d                    |d                              d|v r(t          d                    |d                              |d                                         dk    }|dk    r| n|}|
dk    r|rdnd}n|
}|dk    r>	 t          d           n-# t          $ r }|rd}nd|
d}t          |          |d}~ww xY w|r*|rt	          d          |dk    rt	          d|
d          t          ||          }|s3|D ]0}d |d!         |d"         fv r|d#         d$k    rt	          d%          1|d&k    rd' |D             }n t          |t                    r|g}n|g }n|}t          ||          }|s/t          ||          }t          |          t!          |          f}nd}t"                              |d(                   }t%          |||t'          |          |||||d)         ||	||*          }|r|j        |j        fS d+                    |                    d,                    }|                    ||d-                    |          .           |S )/a$  Fetch dataset from openml by name or dataset id.

    Datasets are uniquely identified by either an integer ID or by a
    combination of name and version (i.e. there might be multiple
    versions of the 'iris' dataset). Please give either name or data_id
    (not both). In case a name is given, a version can also be
    provided.

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

    .. versionadded:: 0.20

    .. note:: EXPERIMENTAL

        The API is experimental (particularly the return value structure),
        and might have small backward-incompatible changes without notice
        or warning in future releases.

    Parameters
    ----------
    name : str, default=None
        String identifier of the dataset. Note that OpenML can have multiple
        datasets with the same name.

    version : int or 'active', default='active'
        Version of the dataset. Can only be provided if also ``name`` is given.
        If 'active' the oldest version that's still active is used. Since
        there may be more than one active version of a dataset, and those
        versions may fundamentally be different from one another, setting an
        exact version is highly recommended.

    data_id : int, default=None
        OpenML ID of the dataset. The most specific way of retrieving a
        dataset. If data_id is not given, name (and potential version) are
        used to obtain a dataset.

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

    target_column : str, list or None, default='default-target'
        Specify the column name in the data to use as target. If
        'default-target', the standard target column a stored on the server
        is used. If ``None``, all columns are returned as data and the
        target is ``None``. If list (of strings), all columns with these names
        are returned as multi-target (Note: not all scikit-learn classifiers
        can handle all types of multi-output combinations).

    cache : bool, default=True
        Whether to cache the downloaded datasets into `data_home`.

    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` objects.

    as_frame : bool or 'auto', default='auto'
        If True, the data is a pandas DataFrame including columns with
        appropriate dtypes (numeric, string or categorical). The target is
        a pandas DataFrame or Series depending on the number of target_columns.
        The Bunch will contain a ``frame`` attribute with the target and the
        data. If ``return_X_y`` is True, then ``(data, target)`` will be pandas
        DataFrames or Series as describe above.

        If `as_frame` is 'auto', the data and target will be converted to
        DataFrame or Series as if `as_frame` is set to True, unless the dataset
        is stored in sparse format.

        If `as_frame` is False, the data and target will be NumPy arrays and
        the `data` will only contain numerical values when `parser="liac-arff"`
        where the categories are provided in the attribute `categories` of the
        `Bunch` instance. When `parser="pandas"`, no ordinal encoding is made.

        .. versionchanged:: 0.24
           The default value of `as_frame` changed from `False` to `'auto'`
           in 0.24.

    n_retries : int, default=3
        Number of retries when HTTP errors or network timeouts are encountered.
        Error with status code 412 won't be retried as they represent OpenML
        generic errors.

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

    parser : {"auto", "pandas", "liac-arff"}, default="auto"
        Parser used to load the ARFF file. Two parsers are implemented:

        - `"pandas"`: this is the most efficient parser. However, it requires
          pandas to be installed and can only open dense datasets.
        - `"liac-arff"`: this is a pure Python ARFF parser that is much less
          memory- and CPU-efficient. It deals with sparse ARFF datasets.

        If `"auto"`, the parser is chosen automatically such that `"liac-arff"`
        is selected for sparse ARFF datasets, otherwise `"pandas"` is selected.

        .. versionadded:: 1.2
        .. versionchanged:: 1.4
           The default value of `parser` changes from `"liac-arff"` to
           `"auto"`.

    read_csv_kwargs : dict, default=None
        Keyword arguments passed to :func:`pandas.read_csv` when loading the data
        from a ARFF file and using the pandas parser. It can allow to
        overwrite some default parameters.

        .. versionadded:: 1.3

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

        data : np.array, scipy.sparse.csr_matrix of floats, or pandas DataFrame
            The feature matrix. Categorical features are encoded as ordinals.
        target : np.array, pandas Series or DataFrame
            The regression target or classification labels, if applicable.
            Dtype is float if numeric, and object if categorical. If
            ``as_frame`` is True, ``target`` is a pandas object.
        DESCR : str
            The full description of the dataset.
        feature_names : list
            The names of the dataset columns.
        target_names: list
            The names of the target columns.

        .. versionadded:: 0.22

        categories : dict or None
            Maps each categorical feature name to a list of values, such
            that the value encoded as i is ith in the list. If ``as_frame``
            is True, this is None.
        details : dict
            More metadata from OpenML.
        frame : pandas DataFrame
            Only present when `as_frame=True`. DataFrame with ``data`` and
            ``target``.

    (data, target) : tuple if ``return_X_y`` is True

        .. note:: EXPERIMENTAL

            This interface is **experimental** and subsequent releases may
            change attributes without notice (although there should only be
            minor changes to ``data`` and ``target``).

        Missing values in the 'data' are represented as NaN's. Missing values
        in 'target' are represented as NaN's (numerical target) or None
        (categorical target).

    Notes
    -----
    The `"pandas"` and `"liac-arff"` parsers can lead to different data types
    in the output. The notable differences are the following:

    - The `"liac-arff"` parser always encodes categorical features as `str` objects.
      To the contrary, the `"pandas"` parser instead infers the type while
      reading and numerical categories will be casted into integers whenever
      possible.
    - The `"liac-arff"` parser uses float64 to encode numerical features
      tagged as 'REAL' and 'NUMERICAL' in the metadata. The `"pandas"`
      parser instead infers if these numerical features corresponds
      to integers and uses panda's Integer extension dtype.
    - In particular, classification datasets with integer categories are
      typically loaded as such `(0, 1, ...)` with the `"pandas"` parser while
      `"liac-arff"` will force the use of string encoded class labels such as
      `"0"`, `"1"` and so on.
    - The `"pandas"` parser will not strip single quotes - i.e. `'` - from
      string columns. For instance, a string `'my string'` will be kept as is
      while the `"liac-arff"` parser will strip the single quotes. For
      categorical columns, the single quotes are stripped from the values.

    In addition, when `as_frame=False` is used, the `"liac-arff"` parser
    returns ordinally encoded data where the categories are provided in the
    attribute `categories` of the `Bunch` instance. Instead, `"pandas"` returns
    a NumPy array were the categories are not encoded.

    Examples
    --------
    >>> from sklearn.datasets import fetch_openml
    >>> adult = fetch_openml("adult", version=2)  # doctest: +SKIP
    >>> adult.frame.info()  # doctest: +SKIP
    <class 'pandas.core.frame.DataFrame'>
    RangeIndex: 48842 entries, 0 to 48841
    Data columns (total 15 columns):
     #   Column          Non-Null Count  Dtype
    ---  ------          --------------  -----
     0   age             48842 non-null  int64
     1   workclass       46043 non-null  category
     2   fnlwgt          48842 non-null  int64
     3   education       48842 non-null  category
     4   education-num   48842 non-null  int64
     5   marital-status  48842 non-null  category
     6   occupation      46033 non-null  category
     7   relationship    48842 non-null  category
     8   race            48842 non-null  category
     9   sex             48842 non-null  category
     10  capital-gain    48842 non-null  int64
     11  capital-loss    48842 non-null  int64
     12  hours-per-week  48842 non-null  int64
     13  native-country  47985 non-null  category
     14  class           48842 non-null  category
    dtypes: category(9), int64(6)
    memory usage: 2.7 MB
    FNru   openmlzfDataset data_id={} and name={} passed, but you can only specify a numeric data_id or a name, not both.rw   r   r   zlDataset data_id={} and version={} passed, but you can only specify a numeric data_id or a version, not both.zFNeither name nor data_id are provided. Please provide name or data_id.r   zVersion {} of dataset {} is inactive, meaning that issues have been found in the dataset. Try using a newer version from this URL: {}r   rd   r@   r~   zMOpenML registered a problem with the dataset. It might be unusable. Error: {}warningzIOpenML raised a warning on the dataset. It might be unusable. Warning: {}r   sparse_arffr   r   r   z`fetch_openml`zReturning pandas objects requires pandas to be installed. Alternatively, explicitly set `as_frame=False` and `parser='liac-arff'`.zUsing `parser=zf` with dense data requires pandas to be installed. Alternatively, explicitly set `parser='liac-arff'`.zhSparse ARFF datasets cannot be loaded with as_frame=True. Use as_frame=False or as_frame='auto' instead.z2Sparse ARFF datasets cannot be loaded with parser=z2. Use parser='liac-arff' or parser='auto' instead.r   r   r   r   stringzOSTRING attributes are not supported for array representation. Try as_frame=Truer  c                 6    g | ]}|d          dk    |d         S )	is_targetr   rd   r9   r   s     r&   
<listcomp>z fetch_openml.<locals>.<listcomp>O  s6     
 
 
{#v-- FO---r(   file_idr   )
r   r   r   r   r   r   r>   r?   r   r   z{}

Downloaded from openml.org.descriptionzhttps://www.openml.org/d/{})DESCRdetailsr@   )r   r   strlowerr   r   r   r   r   r   ImportErrorr   r.   r   r   r   r   
_DATA_FILEr   boolr   r   popr   )rd   r   r   r!   r   r   r   r   r>   r?   r   r   	data_infodata_descriptionreturn_sparseparser_r4   err_msgr   r   r   r   r   r   r@   bunchr  s                              r&   r   r     s   \ ~~		!I666	Y22	  zz||w--  
 +'9	
 
 
	 E"		hw00    T
 
 	
 37IFF!X--!6 + ( ' 	
 	
 	
 """""(&)9')B"C"C	
 	
 	
 $$$$$*F+;I+F$G$G	
 	
 	

 %X.4466-GM$,$6$6=  HH!.<++H(	0 !12222 	0 	0 	0 
, UV U U U  g&&C/	0  
 	A   hCV C C C   'w	::M $ 	 	G'+.8K0LMMM{#x// >   0 (((
 
(
 
 

 
M3	'	' ''		 '+M>JJL   -Wi@@ 00#m2D2DD 

,Y7
8
8C#h)%!%n5'  E   (z5<''5<<]++ K 
LL )0099     Ls   1G 
G+G&&G+)N)r;   r<   r=   )r;   r<   )r;   r<   N)PrO   r   rx   r$   ra   rG   
contextlibr   	functoolsr   os.pathr   tempfiler   typingr   r	   r
   r   r   r   r   urllib.errorr   r   urllib.requestr   r   warningsr   r   r   utilsr   utils._optional_dependenciesr   utils._param_validationr   r   r   r   r   r=   r   _arff_parserr   __all__rZ   r   r   r   r   r  r  OpenmlQualitiesTypeOpenmlFeaturesTyper'   r-   r:   r   r   rL   rl   r   rn   r   r   r   r   r   r   r   r   r  r   r   r   PathLiker   r   r9   r(   r&   <module>r+     s      				                     ' ' ' ' ' ' D D D D D D D D D D D D D D D D D D , , , , , , , , + + + + + + + +                 ? ? ? ? ? ?                    2 2 2 2 2 2
*;"
/1"
4S>* $sCx.) F F F F F F F /3! !!}! !+! 	! ! ! !J 8:    $ 14        H TWG+ G+G+!)#G+;>G+KPG+ G+ G+ G+T	 	 	 	 	* 	 	 	 5% 5%	5%C=5% }5% 	5%
 5% 
5% 5% 5% 5%x ^+ ^+
^+38_^+ }^+ 	^+
 ^+ ^+ ^+ ^+H 	- --}- - 	-
 
#s(^- - - -, 	1 11}1 1 	1
 1 1 1 1. 	B BB}B B 	B
 B B B B,M%8 MS M M M M> &*E# E#	E#}E# E# 	E#
 E# "#YE# !IE# E#s(O$E# E# E# E# d^E# E# E# E#f &*H H H	HH }H
 H dH s)H IH E#s(O$H H H H H d^H H H HV
 
 
6# # #  dHXq$v>>>

H:@V@VWHXq$v>>>E2;-tT*f::vh//0hxD@@@A(4d9===>J66677
 !$<   #'#  ( B  (!370@!'&*B B B
3-B 38_B c]	B
 c2;./0B E#t),-B B B CIB B B B d^B B B' &B B Br(   