CoolFace
Apppublic

Aluode/PerceptionLabPortable

sourceHugging Faceupdated 9mo agoView on Hugging Face
0likes
random.cpython-310.pyc37 linesDownload Raw Back to __pycache__
1o

2�Yi��@sLdZddlZddlZddlmZddlmZddl	m3Z4dgZd	dd�ZdS)5zUtilities for random sampling.�N�)�check_random_state)�sample_without_replacementrcCs,t�d�}t�d�}t�ddg�}tt|��D]�}t�||�||<||jjdkr3td||j��||jtj	dd�||<|dur[tj6||jdd�}|�d||jd�nt�||�}t�
t�|�d	�srtd7�|���|jd||jdkr�td�|||jd|jd���d||vr�t�||dd�||<t�|dd�}t|�}	||jddkr�t�||dk���}8d||9}t||�}t|||d
�}
|�|
�||dk}||}|t�|�}t�|��|	j|d��}|�||||�|�t|��qtj|||f|t|�ftd�S)a�Generate a sparse random matrix given column class distributions10 11    Parameters12    ----------13    n_samples : int,14        Number of samples to draw in each column.15 16    classes : list of size n_outputs of arrays of size (n_classes,)17        List of classes for each column.18 19    class_probability : list of size n_outputs of arrays of         shape (n_classes,), default=None20        Class distribution of each column. If None, uniform distribution is21        assumed.22 23    random_state : int, RandomState instance or None, default=None24        Controls the randomness of the sampled classes.25        See :term:`Glossary <random_state>`.26 27    Returns28    -------29    random_matrix : sparse csc matrix of size (n_samples, n_outputs)30 31    �irzclass dtype %s is not supportedF)�copyN)�shaperg�?z2Probability array at index {0} does not sum to onezXclasses[{0}] (length {1}) and class_probability[{0}] (length {2}) have different length.g)Zn_population�	n_samples�random_state)�size)�dtype)�array�range�len�npZasarrayr�kind�32ValueErrorZastypeZint64�emptyr�fill�isclose�sum�format�insertrZflatnonzero�item�intr�extendZsearchsortedZcumsum�uniform�append�spZ33csc_matrix)r�classesZclass_probabilityr	�data�indicesZindptr�jZclass_prob_j�rngZ
index_class_0Z	p_nonzeroZnnzZ34ind_sampleZclasses_j_nonzeroZclass_probability_nzZclass_probability_nz_normZclasses_ind�r#�~E:\DocsHouse\542 percep lab latest\PerceptionLab\PerceptionLab_Portable\python_embed\Lib\site-packages\sklearn/utils/random.py�_random_choice_cscs\3536���	�37��r%)NN)
�__doc__r�numpyrZscipy.sparse�sparser�r�_randomr�__all__r%r#r#r#r$�<module>s
Aluode/PerceptionLabPortable · CoolFace