
    0Phc                     L    d 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gZddZdS )	zUtilities for random sampling.    N   )check_random_state)sample_without_replacementr   c           	      P   t          j         d          }t          j         d          }t          j         ddg          }t          t          |                    D ]}t          j        ||                   ||<   ||         j        j        dk    rt          d||         j        z            ||                             t          j	        d          ||<   |Pt          j
        ||         j        d                   }|                    d||         j        d         z             nt          j        ||                   }t          j        t          j        |          d	          s"t          d
                    |                    |j        d         ||         j        d         k    r@t          d                    |||         j        d         |j        d                             d||         vr5t          j        ||         dd          ||<   t          j        |dd          }t#          |          }	||         j        d         dk    rt          j        ||         dk                                              }
d||
         z
  }t)          | |z            }t+          | ||          }|                    |           ||         dk    }||         }|t          j        |          z  }t          j        |                                |	                    |                    }|                    ||         |         |                    |                    t          |                     t7          j        |||f| t          |          ft(                    S )a  Generate a sparse random matrix given column class distributions

    Parameters
    ----------
    n_samples : int,
        Number of samples to draw in each column.

    classes : list of size n_outputs of arrays of size (n_classes,)
        List of classes for each column.

    class_probability : list of size n_outputs of arrays of         shape (n_classes,), default=None
        Class distribution of each column. If None, uniform distribution is
        assumed.

    random_state : int, RandomState instance or None, default=None
        Controls the randomness of the sampled classes.
        See :term:`Glossary <random_state>`.

    Returns
    -------
    random_matrix : sparse csc matrix of size (n_samples, n_outputs)

    ir   zclass dtype %s is not supportedF)copyN)shaper   g      ?z2Probability array at index {0} does not sum to onezXclasses[{0}] (length {1}) and class_probability[{0}] (length {2}) have different length.g        )n_population	n_samplesrandom_state)size)dtype)arrayrangelennpasarrayr   kind
ValueErrorastypeint64emptyr	   fillisclosesumformatinsertr   flatnonzeroitemintr   extendsearchsortedcumsumuniformappendsp
csc_matrix)r   classesclass_probabilityr   dataindicesindptrjclass_prob_jrngindex_class_0	p_nonzeronnz
ind_sampleclasses_j_nonzeroclass_probability_nzclass_probability_nz_normclasses_inds                     T/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sklearn/utils/random.py_random_choice_cscr9      sm   2 ;sDk#G[qc""F3w<<   5$ 5$Z
++
1: C''>AQQRRRQZ&&rxe&<<
 $8'!**:1*=>>>La'!*"21"556666:&7&:;;Lz"&..44 	DKKANN   a GAJ$4Q$777$$*Fwqz'*L,>q,A% %   GAJ71:q!44GAJ9\1c::L !..1:A""N71:?;;@@BBML77Ii)+,,C3&#L  J NN:&&& !(
a#/0A#B (<rv$@ @ )% /)0022CKKSK4I4I K KK
#45kBCCCc'll####=$09c'll2KSVWWWW    )NN)__doc__r   numpyr   scipy.sparsesparser&    r   _randomr   __all__r9    r:   r8   <module>rC      s    $ $
                        / / / / / /'
(TX TX TX TX TX TXr:   