
     hX              
          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 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 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  ej                    Zd Zd Zd Zd Zej         !                    dg d          d             Z"ed             Z#ej         !                    d ej$        g dd           ej$        g dd           ej$        d gd          f ej$        g d!e%           ej$        g d"e%           ej$        d#ge%          f ej$        g d!           ej$        g d"           ej$        d#g          fgg d$%          d&             Z&d' Z'ej         !                    dd(d)g          d*             Z(d+ Z)ej         !                    d, ej$        g dd           ej$        g d!e%           ej$        g d!          gg d$%          d-             Z*d. Z+d/ Z,d0 Z-d1 Z.d2 Z/d3 Z0d4 Z1d5 Z2d6 Z3d7 Z4d8 Z5d9 Z6d: Z7d; Z8d< Z9d= Z:d> Z;d? Z<dS )@    N)issparse)
coo_matrix)
csc_matrix)
csr_matrix)
dok_matrix)
lil_matrix)type_of_target)assert_array_equal)ignore_warnings)_to_object_arrayLabelBinarizer)MultiLabelBinarizer)LabelEncoder)label_binarize)_inverse_binarize_thresholding)_inverse_binarize_multiclass)datasetsc                 N    t          | d          r|                                 } | S )Ntoarray)hasattrr   as    b/var/www/html/Sam_Eipo/venv/lib/python3.11/site-packages/sklearn/preprocessing/tests/test_label.pyr   r      s&    q) IIKKH    c                     g d} t          d          }t          j        g dg          j        }|                    |           }t          |j        dg           t          ||           t          |                    |          |            t          d          }|                    |           }t          |          sJ t          |j        dg           t          ||	                                           t          |                    |	                                          |            t          d          }g d} t          j        g dg          j        }|                    |           }t          |j        d	dg           t          ||           t          j        d
dgdd
gdd
gd
dgg          }t          |                    |          |            g d} t          j        g dg dg dg dg dg          }|                    |           }t          |j        g d           t          ||           t          |                    |          |            d S )N)posr   r   r   Fsparse_outputr   r   r   r   r   T)negr   r   r!   r      r#   r   r!   r#   r   )spamhameggsr%   0r   r   r   r#   r   r   r#   r   r   r#   r   r   r#   r   r   r   )r'   r&   r%   r$   )
r   nparrayTfit_transformr
   classes_inverse_transformr   r   )inplbexpectedgot	to_inverts        r   test_label_binarizerr7   %   sh    '
&
&C	e	,	,	,Bx'')H


3

Cr{UG,,,x%%%r++C00#666 
d	+	+	+B


3

CC===r{UG,,,x///r++CKKMM::C@@@	e	,	,	,B
&
&
&Cx'')H


3

Cr{UEN333x%%%1a&1a&1a&1a&9::Ir++I66<<< .
-
-Cx	|||\\\<<<N H 

3

Cr{$@$@$@AAAx%%%r++C00#66666r   c            	      D   t                      } t          j        g dg dg dg          }|                     g d          }t	          ||           t          j        g dg dg dg dg dg dg          }|                     g d          }t	          ||           d S )Nr#   r   r   r   r#   r   r   r   r#   )bder   r   r   )r   r<   cr=   r>   f)r   r,   r-   r/   r
   	transform)r3   r4   r5   s      r   "test_label_binarizer_unseen_labelsrC   N   s    			BxIIIyyy9::H


???
+
+Cx%%%x	IIIyyy)))YYY			J H ,,555
6
6Cx%%%%%r   c                  @   t          dd          } t          j        g d          }t          j        g dg          j        }|                     |          }t          ||           t          |                     |          |           t          dd          } t          j        g d          }t          j        g dg d	g d
g d	g dg          }|                     |          }t          ||           t          |                     |          |           d S )Nr   	neg_label	pos_labelr"   )rE   r   r   rE      )   rI   r#   rI   r   )rE   rE   rE   rI   )rE   rE   rI   rE   )rE   rI   rE   rE   )rI   rE   rE   rE   )r   r,   r-   r.   r/   r
   r1   )r3   r2   r4   r5   s       r   'test_label_binarizer_set_label_encodingrK   \   s6   	"	2	2	2B (<<<
 
 Cx())+H


3

Cx%%%r++C00#666	"	2	2	2B (???
#
#Cx	
 H 

3

Cx%%%r++C00#66666r   dtype)Int64Float64booleanc                     t          j        d          }ddlm} |                    g d|           } |                                |          }|                    ddg          }t          |dgdgg           dS )ziChecks that LabelBinarizer works with pandas nullable dtypes.

    Non-regression test for gh-25637.
    pandasr   r   )	r#   r   r   r#   r   r#   r#   r   r#   rL   r#   N)pytestimportorskipsklearn.preprocessingr   SeriesfitrB   r
   )rL   pdr   y_truer3   y_outs         r   $test_label_binarizer_pandas_nullabler[   x   s     
	X	&	&B444444YY222%Y@@F					f	%	%BLL!Q  EusQCj)))))r   c                  	   t          j        g d          } t                                          |           }g d}d}t	          j        t          |          5  |                    |           d d d            n# 1 swxY w Y   t                      }d}t	          j        t          |          5  |                    g            d d d            n# 1 swxY w Y   t	          j        t          |          5  |                    g            d d d            n# 1 swxY w Y   g d}d}t          dd	
          }t	          j        t          |          5  |                    |           d d d            n# 1 swxY w Y   d}t          dd
          }t	          j        t          |          5  |                    |           d d d            n# 1 swxY w Y   d}t          d	dd          }t	          j        t          |          5  |                    |           d d d            n# 1 swxY w Y   d}t	          j        t          |          5  t          t          d	dgdd	gg          dd	dgd           d d d            n# 1 swxY w Y   g d	dgdgg ddgg}d}t	          j        t          |          5  t                                          |           d d d            n# 1 swxY w Y   d}t	          j        t          |          5  t          t          d	dgdd	gg          dg dd           d d d            n# 1 swxY w Y   d}t	          j        t          |          5  t          t          j        g dg dg          dg dd           d d d            n# 1 swxY w Y   d}t	          j        t          |          5  t                                          t          j        d	dgdd	gg                     d d d            n# 1 swxY w Y   t	          j        t          |          5  t          t          j        d	dgdd	gg          g d           d d d            d S # 1 swxY w Y   d S )Nr    )rI   rJ   )r   )r   rI   z@You appear to be using a legacy multi-label data representation.matchz.This LabelBinarizer instance is not fitted yet)r   r#   r   r#   z3neg_label=2 must be strictly less than pos_label=1.rI   r#   rF   z3neg_label=2 must be strictly less than pos_label=2.zqSparse binarization is only supported with non zero pos_label and zero neg_label, got pos_label=2 and neg_label=1TrG   rH   r   zfoo format is not supportedfoor   )youtput_typeclasses	thresholdrJ   )r   r#   rJ   z?You appear to be using a legacy multi-label data representationzAThe number of class is not equal to the number of dimension of y.r#   rI   rJ   z!output_type='binary', but y.shape)rI   r#   rJ   binaryz@Multioutput target data is not supported with label binarizationrd   )r,   r-   r   rW   rS   raises
ValueErrorrB   r1   r   r   r/   r   )	one_classr3   multi_labelerr_msginput_labelsy_seq_of_seqss         r   test_label_binarizer_errorsrp      s    &&I					i	(	(B(((KPG	z	1	1	1 " "
[!!!" " " " " " " " " " " " " " " 
		B>G	z	1	1	1  
R              	z	1	1	1 ! !
R   ! ! ! ! ! ! ! ! ! ! ! ! ! ! !  <<LCG	!q	1	1	1B	z	1	1	1  
|              CG	!q	1	1	1B	z	1	1	1  
|              	5  
!q	E	E	EB	z	1	1	1  
|               ,G	z	1	1	1 
 
&1a&1a&)**F		
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 !Q!iii!5MOG	z	1	1	1 6 6&&}5556 6 6 6 6 6 6 6 6 6 6 6 6 6 6 RG	z	1	1	1 
 
&1a&1a&)**II		
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 2G	z	1	1	1 
 
&h			999-.. II		
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 QG	z	1	1	1 9 9RX1v1v&6778889 9 9 9 9 9 9 9 9 9 9 9 9 9 9	z	1	1	1 F Frx!Q!Q 011999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?A?1CCC9DD"DE::E>E>3GGGH11H58H5)JJJ"K11K58K5)MMM6.N00N47N4:PP"%P",Q==RRzvalues, classes, unknown)rI   r#   rJ   r#   rJ   int64rR   rf      )r<   r   r@   r   r@   r   r<   r@   r=   )rq   objectstr)idsc                    t                      }|                    |            t          |j        |           t          |                    |           g d           t          |                    g d          |            t                      }|                    |           }t          |g d           t          j        t          d          5  |                    |           d d d            d S # 1 swxY w Y   d S )N)r#   r   rI   r   rI   zunseen labelsr^   )
r   rW   r
   r0   rB   r1   r/   rS   ri   rj   )valuesrd   unknownlerets        r   test_label_encoderr|      s+   0 
BFF6NNNr{G,,,r||F++___===r++OOO<<fEEE	B


6
"
"CsOOO,,,	z	9	9	9  
W                 s   C66C:=C:c                     t                      } |                     g d           t          | j        g d           t          |                     g d          g d           t          |                     g d          g d           t          j        t                    5  |                     ddg           d d d            d S # 1 swxY w Y   d S )N)r#   r#   rr      r   )r   r   r#   rr   r~   )r   r#   rr   rr   r~   r   r   )r#   rI   rJ   rJ   rr   r   r   r      )	r   rW   r
   r0   rB   r1   rS   ri   rj   )rz   s    r    test_label_encoder_negative_intsr      s&   	BFFr{$4$4$4555r||$;$;$;<<>S>S>STTT
222335L5L5L   
z	"	"  
aV                 s   $C		CCru   rt   c                    t                      }|                    t          j        ddg|                      d}t	          j        t          |          5  |                    d           d d d            d S # 1 swxY w Y   d S )NappleorangerR   zshould be a 1d arrayr^   )r   rW   r,   r-   rS   ri   rj   rB   )rL   rz   msgs      r    test_label_encoder_str_bad_shaper     s    	BFF28Wh'u555666
 C	z	-	-	-  
W                 s   A::A>A>c                  D   t                      } t          j        t                    5  |                     g            d d d            n# 1 swxY w Y   t          j        t                    5  |                     g            d d d            n# 1 swxY w Y   t                      } |                     g d           d}t          j        t          |          5  |                     dg           d d d            n# 1 swxY w Y   t          j        t          |          5  |                     g d           d d d            n# 1 swxY w Y   d}t          j        t          |          5  |                     d           d d d            d S # 1 swxY w Y   d S )N)r#   rI   rJ   r   r#   z!contains previously unseen labelsr^   rE   )rE   z should be a 1d array.+shape \(\) )r   rS   ri   rj   rB   r1   rW   )rz   r   s     r   test_label_encoder_errorsr     s   	B	z	"	"  
R              	z	"	" ! !
R   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! 
BFF
-C	z	-	-	- # #
bT"""# # # # # # # # # # # # # # #	z	-	-	- + +
\\\***+ + + + + + + + + + + + + + + .C	z	-	-	- ! !
R   ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! ! !sY   A

AA.BBBD  DD&E

EE2FFFrx   c                 (   t                      }|                    |            |                    g           }t          t	          j        g           |           |                    g           }t          t	          j        g           |           d S )N)r   rW   rB   r
   r,   r-   r1   )rx   rz   transformedinverse_transformeds       r   test_label_encoder_empty_arrayr   (  sx     
BFF6NNN,,r""Krx||[111..r22rx||%899999r   c                  x   d d d g} t          j        g dg dg dg          } | d                     }dD ]}| D ]}t          |	          }|                     |                      }t	          |          |k    sJ |r0|j        j        |j        j        k    sJ |                                }t          ||           t          g d
|j
                   |                    |          |k    sJ t          |	          }|                     |                                           |                      }t	          |          |k    sJ |r0|j        j        |j        j        k    sJ |                                }t          ||           t          g d
|j
                   |                    |          |k    sJ t          j        t                     5  |                    t#          t          j        g dg dg dg                               d d d            d S # 1 swxY w Y   d S )Nc                  
    g dS Nr]   r#   )r#   rI    r   r   r   <lambda>z9test_sparse_output_multilabel_binarizer.<locals>.<lambda>?      &&& r   c                      ddhdhddhfS NrI   rJ   r#   r   r   r   r   r   z9test_sparse_output_multilabel_binarizer.<locals>.<lambda>@      !Q!q!f% r   c                  ^    t          t          d          t          d          ddhg          S Nr]   r   r#   rI   iterr   r   r   r   z9test_sparse_output_multilabel_binarizer.<locals>.<lambda>A  %    d6llDJJA788 r   r   r#   r#   r9   r#   r#   r   r   TFr   rf   )rI   r   r   )r,   r-   r   r/   r   indicesrL   indptrr   r
   r0   r1   rW   rB   rS   ri   rj   r   )inputsindicator_matinverser   r2   mlbr5   s          r   'test_sparse_output_multilabel_binarizerr   <  s    	'&%%88F
 HiiiIII>??MfQikkG& 9 9 	9 	9C%MBBBC##CCEE**CC==M1111 ${(CJ,<<<<<kkmm}c222yyy#,777((--8888 &MBBBC''##%%..**335511CC==M1111 ${(CJ,<<<<<kkmm}c222yyy#,777((--88888/	92 
z	"	" W Wj999iii2S)T)TUUVVVW W W W W W W W W W W W W W W W W Ws   $>H//H36H3c                  d   d d d g} t          j        g dg dg dg          } | d                     }| D ]}t                      }|                     |                      }t	          ||           t	          g d|j                   |                    |          |k    sJ t                      }|                     |                                           |                      }t	          ||           t	          g d|j                   |                    |          |k    sJ d S )	Nc                  
    g dS r   r   r   r   r   r   z+test_multilabel_binarizer.<locals>.<lambda>g  r   r   c                      ddhdhddhfS r   r   r   r   r   r   z+test_multilabel_binarizer.<locals>.<lambda>h  r   r   c                  ^    t          t          d          t          d          ddhg          S r   r   r   r   r   r   z+test_multilabel_binarizer.<locals>.<lambda>i  r   r   r   r9   r   r   rf   )	r,   r-   r   r/   r
   r0   r1   rW   rB   )r   r   r   r2   r   r5   s         r   test_multilabel_binarizerr   d  sP    	'&%%88F
 HiiiIII>??MfQikkG 5 5!##&&=#...999cl333$$S))W4444 "##ggcceenn&&ssuu--=#...999cl333$$S))W444445 5r   c                      t                      } ddgdgg g}t          j        ddgddgddgg          }t          |                     |          |           d S )Nr#   rI   r   )r   r,   r-   r
   r/   )r   rb   Ys      r   &test_multilabel_binarizer_empty_sampler   }  se    


C
Q!bA
1a&1a&1a&)**As((++Q/////r   c                  `   t                      } ddgg}t          j        ddgddgg          }d}t          j        t
          |          5  |                     |                              ddgddgg          }d d d            n# 1 swxY w Y   t          j        g dg dg          }t          g d	
          } t          j        t
          |          5  |                     |                              ddgddgg          }d d d            n# 1 swxY w Y   t          ||           d S )Nr#   rI   r   zunknown class.* will be ignoredr^   rr   r9   r:   rf   rh   )	r   r,   r-   rS   warnsUserWarningrW   rB   r
   )r   rb   r   warning_messagematrixs        r   'test_multilabel_binarizer_unknown_classr     s   


C
QA
1a&1a&!""A7O	k	9	9	9 8 8%%1v1v&6778 8 8 8 8 8 8 8 8 8 8 8 8 8 8 	)))YYY'((A
iii
0
0
0C	k	9	9	9 8 8%%1v1v&6778 8 8 8 8 8 8 8 8 8 8 8 8 8 8vq!!!!!s$   /BB
B
/DDDc                     g d} t          j        g dg dg dg          }t          g d          }t          |                    |           |           t          |j        g d           t          g d          }t          |                    |                               |           |           t          |j        g d           t          g d          }t          |                    |           t          j        dgdgdgg|f                     t          |j        g d           t          |           } t          g d          }t          |                    |                               |           |           d	}t          g d
          }t          j        t          |          5  |                    |            d d d            d S # 1 swxY w Y   d S )Nr   r   r9   r#   r   r#   r#   rJ   rI   rh   )rr   r#   rJ   rI   r   ztThe classes argument contains duplicate classes. Remove these duplicates before passing them to MultiLabelBinarizer.)r#   rJ   rI   rJ   r^   )r,   r-   r   r
   r/   r0   rW   rB   hstackr   rS   ri   rj   )r2   r   r   rm   s       r   'test_multilabel_binarizer_given_classesr     s+   
 
 
 CHiiiIII>??M
iii
0
0
0Cs((--}===s|YYY/// iii
0
0
0Cswws||--c22MBBBs|YYY/// lll
3
3
3C#	QC!qc?M*J K K   s|\\\222 s))C
iii
0
0
0Cswws||--c22MBBB	G  lll
3
3
3C	z	1	1	1                   s   9GG #G c                  D   g d} t          j        g dg dg dg          }t          j        g dg dg dg          }t          g d          }t          |                    |           |           g d|_        t          |                    |           |           d S )	Nr   r   r9   r   r   r   rh   rf   )r,   r-   r   r
   r/   rd   )r2   r   indicator_mat2r   s       r   (test_multilabel_binarizer_multiple_callsr     s    
 
 
 CHiiiIII>??MXyyy)))YYY?@@N iii
0
0
0Cs((--}===))CKs((--~>>>>>r   c                     dgdgdgg} t          j        g dg dg dg          }t                      }t          |                    |           |           t          |                    |          |            t                      }t          |                    |                               |           |           t          |                    |          |            d S )Nr#   r   rI   r:   r9   r;   )r,   r-   r   r
   r/   r1   rW   rB   r2   r   r   s      r   .test_multilabel_binarizer_same_length_sequencer     s    3aS/CHiiiIII>??M


Cs((--}===s,,];;SAAA 

Cswws||--c22MBBBs,,];;SAAAAAr   c                     t          g d          } g dg dfg dg dfg d| fg}t          j        g dg dg d	g          }|D ]<\  }}t                      }t          j        |t          
          }t          |                    |          |           t          |j        |           t          j        |                    |          t          
          }t          ||           t                      }t          |	                    |          
                    |          |           t          |j        |           t          j        |                    |          t          
          }t          ||           >t                      }t          j        t                    5  |                    i i ddifg           d d d            d S # 1 swxY w Y   d S )N)r   rI   rJ   ))23)1)r   r   )r   r   r   ))r<   r@   r   )r   r<   rs   ))r   r   )r   )r   r   r   r9   r   rR   r   r<   )r   r,   r-   r   rt   r
   r/   r0   r1   rW   rB   rS   ri   	TypeError)tuple_classesr   r   r2   rd   r   indicator_mat_invs          r   ,test_multilabel_binarizer_non_integer_labelsr     s*   $%7%7%788M	)	)	)???;	)	)	)???;	.	.	.>F
 HiiiIII>??M 3 3W!##hs&)))3,,S11=AAA3<111HS%:%:=%I%IQWXXX,c222 "##3773<<11#66FFF3<111HS%:%:=%I%IQWXXX,c2222


C	y	!	! 4 4B"sCj!123334 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4s   +GGGc                      dg} t          j        ddgg          }t                      }t          |                    |           |           d S )Nr#   r#   r#   r   r#   )r,   r-   r   r
   r/   r   s      r   $test_multilabel_binarizer_non_uniquer     sM    .CHq!fX&&M


Cs((--}=====r   c                  p   dg} t                      }|                    |            t          j        t                    5  |                    t          j        ddgg                     d d d            n# 1 swxY w Y   |                    t          j        ddgg                     |                    t          j        ddgg                     |                    t          j        ddgg                     t          j        t                    5  |                    t          j        dgg                     d d d            n# 1 swxY w Y   t          j        t                    5  |                    t          j        g dg                     d d d            d S # 1 swxY w Y   d S )Nr   r#   rJ   r   r#   r#   r#   )r   r/   rS   ri   rj   r1   r,   r-   )r2   r   s     r   ,test_multilabel_binarizer_inverse_validationr     s>   .C


Cc	z	"	" 2 2bhAx001112 2 2 2 2 2 2 2 2 2 2 2 2 2 2 "(QF8,,---"(QF8,,---"(QF8,,--- 
z	"	" / /bhuoo.../ / / / / / / / / / / / / / /	z	"	" 5 5bh			{334445 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5 5s6    +A77A;>A;*EEE3+F++F/2F/c                     t          ddgg d          } t          j        g dg dg          }t          | |           t          ddgg d          } t          j        g dg dg          }t          | |           t          g d	g d
          } t          j        g dg dg dg dg          }t          | |           d S )Nr#   r   )r#   rI   rr   r   rh   r+   r(   )r#   r   rr   rI   r*   )r   r#   rI   rJ   )rJ   rI   r   r#   r)   )r   r,   r-   r
   )outr4   s     r   $test_label_binarize_with_class_orderr   
  s    
!Q
6
6
6Cx|||455HsH%%% !Q
6
6
6Cx|||455HsH%%%
|||
<
<
<Cx|||\\\<<<PQQHsH%%%%%r   c           	         dD ]}|dk    s|dk    rH|rFt          j        t                    5  t          | ||||           d d d            n# 1 swxY w Y   Wt          | ||||          }t	          t          |          |           t          |          |k    sJ t          |           }|dk    rt          ||          }nt          |||||z   dz            }t	          t          |          t          |                      t          |||          }	|	                    |           }t	          t          |          |           t          |          |k    sJ |	                    |          }
t	          t          |
          t          |                      t          |
          t          |           k    sJ d S )	Nr   r   rd   rG   rH   r   
multiclassrh   g       @)rc   rd   re   r`   )rS   ri   rj   r   r
   r   r   r	   r   r   r   r/   r1   )rb   rd   rH   rG   r4   r   	binarizedy_typeinversedr3   inverse_outputs              r   check_binarized_resultsr     sI   & /7 /7NNi1nn-nz**  #''"/                   #'
 
 
	 	79--x888	""m3333  ""\!!3IwOOOHH 6"%	1S8	  H 	78,,gajj999 9M
 
 
 $$Q''	79--x888	""m3333--i887>22GAJJ???''8A;;66666_/7 /7s   AA	A	c                  j   g d} ddg}d}d}t          j        ddgddgddgg          d d df                             d          }t          | ||||           g d} ddg}d}d}t          j        ddgddgddgg          d d df                             d          }t          | ||||           d S )Nr:   r   r#   rI   r   )r   r#   rJ   )r,   r-   reshaper   rb   rd   rH   rG   r4   s        r   test_label_binarize_binaryr   L  s    		A!fGIIx!R2q'Ar7344QQQT:BB7KKHAw	9hGGG 			A!fGIIx!Q!Q!Q011!!!Q$7??HHHAw	9hGGGGGr   c                      g d} g d}d}d}dt          j        d          z  }t          | ||||           t          j        t
                    5  t          | |d|d           d d d            d S # 1 swxY w Y   d S )Nr   r#   rI   rI   r   rJ   r   Tr   )r,   eyer   rS   ri   rj   r   r   s        r   test_label_binarize_multiclassr   _  s    		AiiGII26!99}HAw	9hGGG	z	"	" 
 
w"	QU	
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s   A22A69A6c                  x   t          j        g dg dg dg          g d} d}d}|z  }fdt          t          t          t
          t          fD             }g|z   D ]}t          || |||           t          j	        t                    5  t          || d|d	
           d d d            d S # 1 swxY w Y   d S )Nr:   r   r?   r   rI   r   c                 &    g | ]} |          S r   r   ).0sparse_matrixy_inds     r   
<listcomp>z2test_label_binarize_multilabel.<locals>.<listcomp>t  s3     	 	 	 	e	 	 	r   r   Tr   )r,   r-   r   r   r   r   r   r   rS   ri   rj   r   )rd   rH   rG   r4   y_sparserb   r   s         @r   test_label_binarize_multilabelr   n  sG   HiiiIII677EiiGII5 H	 	 	 	 
	 	 	H Wx L L7Iy(KKKK	z	"	" 
 
w"	QU	
 	
 	
 	

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
s   B//B36B3c                     t          j        t                    5  t          ddgddgdd           d d d            n# 1 swxY w Y   t          j        t          d          5  t          ddgddg	           d d d            n# 1 swxY w Y   t          j        t          d
          5  t          ddggg d	           d d d            d S # 1 swxY w Y   d S )Nr   rI   r#   )rd   rH   rG   zcontinuous target data is not r^   g333333?g@rh   zmismatch with the labelsrJ   rf   )rS   ri   rj   r   r   r   r   !test_invalid_input_label_binarizer     s   	z	"	" I I1v1vaHHHHI I I I I I I I I I I I I I I	z)I	J	J	J 3 3SzAq622223 3 3 3 3 3 3 3 3 3 3 3 3 3 3	z)C	D	D	D 4 4Ax33334 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4s3   >AA$BB
B
,CCCc                      t          t          g dg dg dg          t          j        d                    } t	          | t          j        g d                     d S )Nr:   )r   r   r   r?   rJ   r   )r   r   r,   aranger
   r-   )r5   s    r    test_inverse_binarize_multiclassr     s_    
&III{{{III6771 C sBHYYY//00000r   c                      t                      } |                     dddt          j        g           |                     t          j        g          }t          |dg           dS )z]Check that label encoder encodes nans in transform.

    Non-regression test for #22628.
    r   r<   rI   N)r   rW   r,   nanrB   r
   )rz   y_transs     r   test_nan_label_encoderr     sW    
 
BFFCc26"###llBF8$$Gw$$$$$r   )=numpyr,   rS   scipy.sparser   r   r   r   r   r   sklearn.utils.multiclassr	   sklearn.utils._testingr
   r   sklearn.utilsr   sklearn.preprocessing._labelr   r   r   r   r   r   sklearnr   	load_irisirisr   r7   rC   rK   markparametrizer[   rp   r-   rt   r|   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   <module>r     s        ! ! ! ! ! ! # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # 3 3 3 3 3 3 5 5 5 5 5 5 2 2 2 2 2 2 * * * * * * 7 7 7 7 7 7 < < < < < < 5 5 5 5 5 5 7 7 7 7 7 7 G G G G G G E E E E E E      x  &7 &7 &7R& & &7 7 78 "A"A"ABB* * CB* KF KF KF\  BH___G444BHYYYg...BHaS(((	
 BH...f===BH___F333BHcU&)))	
 BH...//BH___%%BHcUOO	
" 	#""'   * + * 	 	 	 5("344  54! ! !. 000***&999***++
 	#""   : : :%W %W %WP5 5 520 0 0" " "     F? ? ?B B B4 4 4:> > >5 5 5&& & &07 07 07fH H H&
 
 

 
 
44 4 41 1 1	% 	% 	% 	% 	%r   