`L icJdZddlZddlZddlmZddlmZddl m Z dgZ ddZ y) zUtilities for random sampling.N)check_random_state)sample_without_replacementrc tjd}tjd}tjddg}tt|D]}tj||||<||j j dk7rtd||j z||jtjd||<|Ktj||jd}|jd||jdz ntj||}tjtj|dstd j||jd||jdk7r9td j|||jd|jdd||vr4tj ||dd||<tj |dd }t#|} ||jddkDrtj$||dk(j'} d|| z } t)|| z} t+|| | } |j-| ||dk7}||}|tj|z }tj.|j1| j3| }|j-|||||j5t|t7j8|||f|t|ft(S)aGenerate 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 `. Returns ------- random_matrix : sparse csc matrix of size (n_samples, n_outputs) irzclass dtype %s is not supportedF)copy)shaperg?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)arrayrangelennpasarrayrkind ValueErrorastypeint64emptyr fillisclosesumformatinsertr flatnonzeroitemintrextend searchsortedcumsumuniformappendsp csc_matrix)r classesclass_probabilityr dataindicesindptrj class_prob_jrng index_class_0 p_nonzeronnz ind_sampleclasses_j_nonzeroclass_probability_nzclass_probability_nz_norm classes_inds Z/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/sklearn/utils/random.py_random_choice_cscr9s2 ;;s Dkk#G [[qc "F 3w< 5$ZZ + 1:   C '>AQAQQR RQZ&&rxxe&<   $88'!**:*:1*=>L   a'!*"2"21"55 6::&7&:;Lzz"&&.4DKKAN    a GAJ$4$4Q$7 7$$*Fwqz''*L,>,>q,A%  GAJ 71:q!4GAJ99\1c:L!. 1:  A  "NN71:?;@@BML77Ii)+,C3&#LJ NN: &!( a #/0A#B (rCs($   / ' (TXr: