ó
    †ñ:iõz  ã                   óª  • S SK r S SKrS SKrS SKrS SKrSSKJr  SSKJrJ	r	   S SK
r S SKJr  S rS rS	 rS
 rSCS jrSCS jrSCS jrSCS jrSCS jrSCS jrSCS jrSCS jrSCS jrSCS jrSCS jrSCS jrSCS jr SCS jr!SCS jr"SCS jr#SCS jr$SCS jr%SCS jr&SCS jr'SCS jr(SCS  jr)SCS! jr*SCS" jr+SCS# jr,SCS$ jr-SCS% jr.SCS& jr/S' r0SCS( jr1SCS) jr2SCS* jr3SCS+ jr4S, r50 r6 SDS- jr7Sq8Sq9Sq:Sq;Sq<Sq=S. r>S/ r?S0 r@S1 rAS2 rBS3 rCS4 rDS5 rES6 rFS7 rGS8 rHS9 rIS: rJS; rKS< rLS= rMS> rNS? rOS@ rPSA rQSB rRg! \ a     GNf = f! \ a
    S SKJr   GN"f = f)Eé    Né   )Ú__version__é   )ÚmeasuresÚmethods)Útrain_test_splitc                 ó®  • [         R                  R                  5       n[         R                  R                  S5        / n[        S5       HÑ  n[	        [        U 5      USUS9u  pxpšU" 5       nUR                  Xy5        [        R                  " 5       n[        [        U5      " X·5      n[        R                  " 5       U-
  n[        R                  " 5       nU" U5        [        R                  " 5       U-
  nUR                  XïS-  UR                  S   -  -   5        MÓ     [         R                  R                  U5        S[         R                  " U5      4$ )zCRuntime (sec / 1k samples)
transform = "negate_log"
sort_order = 2
éÝ  é   éd   ©Ú	test_sizeÚrandom_stateg     @�@r   N)ÚnpÚrandomÚseedÚranger   Ú	__toarrayÚfitÚtimeÚgetattrr   ÚappendÚshapeÚmean)ÚXÚyÚmodel_generatorÚmethod_nameÚold_seedÚmethod_repsÚiÚX_trainÚX_testÚy_trainÚ_ÚmodelÚstartÚ	explainerÚ
build_timeÚexplain_times                   ÚY/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/shap/benchmark/metrics.pyÚruntimer,      s  € ô
 �y‰y�~‰~Ó€HÜ‡I�I‡N�N�4Ôð €KÜ�1ŽXˆÜ&6´yÀ³|ÀQÐRUÐdeÑ&fÑ#ˆ˜ñ  Ó!ˆØ�	‰	�'Ô#ô —	’	“ˆÜœG [Ô1°%ÓAˆ	Ü—Y’Y“[ 5Ñ(ˆ
ä—	’	“ˆÙ�&ÔÜ—y’y“{ UÑ*ˆð 	×Ñ˜:°vÑ(=ÀÇÁÈQÁÑ(OÑOÖPñ% ô& ‡I�I‡N�N�8Ôà”—’˜Ó%Ð%Ð%ó    c           	      ó:   ^^• S mUU4S jnS[        XSTXC5      4$ )z5Local Accuracy
transform = "identity"
sort_order = 0
c                 óf   • [         R                  " X-
  5      [         R                  " U 5      S-   -  $ )zQComputes local accuracy as the normalized standard deviation of numerical scores.g�íµ ÷Æ°>)r   Ústd©ÚtrueÚpreds     r+   Ú	score_mapÚ!local_accuracy.<locals>.score_map>   s%   € ä�vŠv�d‘kÓ"¤b§f¢f¨T£l°TÑ&9Ñ:Ð:r-   c           
      óF   >• [         R                  " XXU" U5      TTU5      $ ©N)r   Úlocal_accuracy)	r"   r#   r$   Úy_testÚattr_functionÚtrained_modelr   r   r4   s	          €€r+   Úscore_functionÚ&local_accuracy.<locals>.score_functionB   s*   ø€ Ü×&Ò&Ø˜f©m¸FÓ.CÀ_ÐV_Ðanó
ð 	
r-   N)Ú__score_method)r   r   r   r   r<   r4   s     `  @r+   r8   r8   8   s%   ù€ ò;ö
ð
 ”  d¨O¸^ÓYÐYÐYr-   c                 óx   • 0 SS_SS_SS_SS_SS_S	S_S
S_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_nSXC   4$ )z=Consistency Guarantees
transform = "identity"
sort_order = 1
Úlinear_shap_corrç      ð?Úlinear_shap_indÚcoefç        Úkernel_shap_1000_meanrefgš™™™™™é?Úsampling_shap_1000r   ÚsaabasÚ	tree_gainÚtree_shap_tree_path_dependentÚtree_shap_independent_200Úmean_abs_tree_shapÚlime_tabular_regression_1000Ú lime_tabular_classification_1000ÚmapleÚ
tree_mapleÚ	deep_shapg333333ã?Úexpected_gradientsN© )r   r   r   r   Ú
guaranteess        r+   Úconsistency_guaranteesrT   J   sá   € ðØ˜Cðà˜3ðð 	�ðð 	# Cð	ð
 	˜cðð 	�#ðð 	�#ðð 	�Sðð 	(¨ðð 	$ Sðð 	˜cðð 	'¨ðð 	+¨Cðð 	�ðð 	�cðð  	�Sð!ð" 	˜cð#€Jð( �Ñ(Ð(Ð(r-   c                 ó.   • [         R                  " U5      $ )z9A trivial metric that is just is the output of the model.)r   r   r1   s     r+   Ú__mean_predrV   j   s   € ä�7Š7�4‹=Ðr-   c           
      óF   • [        [        R                  XX#SU[        5      $ )z�Keep Positive (mask)
xlabel = "Max fraction of features kept"
ylabel = "Mean model output"
transform = "identity"
sort_order = 4
r   ©Ú__run_measurer   Ú	keep_maskrV   ©r   r   r   r   Únum_fcountss        r+   Úkeep_positive_maskr]   o   s"   € ô œ×+Ñ+¨Q°?ÐQRÐT_ÔalÓmÐmr-   c           
      óF   • [        [        R                  XX#SU[        5      $ )zˆKeep Negative (mask)
xlabel = "Max fraction of features kept"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 5
éÿÿÿÿrX   r[   s        r+   Úkeep_negative_maskr`   y   s"   € ô œ×+Ñ+¨Q°?ÐQSÐU`ÔbmÓnÐnr-   c           
      ón   • [        [        R                  XX#SU[        R                  R
                  5      $ )zsKeep Absolute (mask)
xlabel = "Max fraction of features kept"
ylabel = "R^2"
transform = "identity"
sort_order = 6
r   )rY   r   rZ   ÚsklearnÚmetricsÚr2_scorer[   s        r+   Úkeep_absolute_mask__r2re   ƒ   s1   € ô Ü×Ñ˜A /ÀÀ;ÔPW×P_ÑP_×PhÑPhóð r-   c           
      ón   • [        [        R                  XX#SU[        R                  R
                  5      $ )zwKeep Absolute (mask)
xlabel = "Max fraction of features kept"
ylabel = "ROC AUC"
transform = "identity"
sort_order = 6
r   ©rY   r   rZ   rb   rc   Úroc_auc_scorer[   s        r+   Úkeep_absolute_mask__roc_aucri   �   ó1   € ô Ü×Ñ˜A /ÀÀ;ÔPW×P_ÑP_×PmÑPmóð r-   c           
      óF   • [        [        R                  XX#SU[        5      $ )z�Remove Positive (mask)
xlabel = "Max fraction of features removed"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 7
r   ©rY   r   Úremove_maskrV   r[   s        r+   Úremove_positive_maskrn   ›   ó"   € ô œ×-Ñ-¨q°_ÐSTÐVaÔcnÓoÐor-   c           
      óF   • [        [        R                  XX#SU[        5      $ )z†Remove Negative (mask)
xlabel = "Max fraction of features removed"
ylabel = "Mean model output"
transform = "identity"
sort_order = 8
r_   rl   r[   s        r+   Úremove_negative_maskrq   ¥   ó"   € ô œ×-Ñ-¨q°_ÐSUÐWbÔdoÓpÐpr-   c           
      ón   • [        [        R                  XX#SU[        R                  R
                  5      $ )z}Remove Absolute (mask)
xlabel = "Max fraction of features removed"
ylabel = "1 - R^2"
transform = "one_minus"
sort_order = 9
r   )rY   r   rm   rb   rc   rd   r[   s        r+   Úremove_absolute_mask__r2rt   ¯   ó1   € ô Ü×Ñ˜a OÀ!À[ÔRY×RaÑRa×RjÑRjóð r-   c           
      ón   • [        [        R                  XX#SU[        R                  R
                  5      $ )z�Remove Absolute (mask)
xlabel = "Max fraction of features removed"
ylabel = "1 - ROC AUC"
transform = "one_minus"
sort_order = 9
r   ©rY   r   rm   rb   rc   rh   r[   s        r+   Úremove_absolute_mask__roc_aucrx   »   ó1   € ô Ü×Ñ˜a OÀ!À[ÔRY×RaÑRa×RoÑRoóð r-   c           
      óF   • [        [        R                  XX#SU[        5      $ )z†Keep Positive (resample)
xlabel = "Max fraction of features kept"
ylabel = "Mean model output"
transform = "identity"
sort_order = 10
r   ©rY   r   Úkeep_resamplerV   r[   s        r+   Úkeep_positive_resampler}   Ç   ó"   € ô œ×/Ñ/°°ÐUVÐXcÔepÓqÐqr-   c           
      óF   • [        [        R                  XX#SU[        5      $ )z�Keep Negative (resample)
xlabel = "Max fraction of features kept"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 11
r_   r{   r[   s        r+   Úkeep_negative_resampler€   Ñ   ó"   € ô œ×/Ñ/°°ÐUWÐYdÔfqÓrÐrr-   c           
      ón   • [        [        R                  XX#SU[        R                  R
                  5      $ )zxKeep Absolute (resample)
xlabel = "Max fraction of features kept"
ylabel = "R^2"
transform = "identity"
sort_order = 12
r   )rY   r   r|   rb   rc   rd   r[   s        r+   Úkeep_absolute_resample__r2rƒ   Û   ó1   € ô Ü×Ñ  oÀAÀ{ÔT[×TcÑTc×TlÑTlóð r-   c           
      ón   • [        [        R                  XX#SU[        R                  R
                  5      $ )z|Keep Absolute (resample)
xlabel = "Max fraction of features kept"
ylabel = "ROC AUC"
transform = "identity"
sort_order = 12
r   )rY   r   r|   rb   rc   rh   r[   s        r+   Úkeep_absolute_resample__roc_aucr†   ç   s1   € ô Ü×Ñ  oÀAÀ{ÔT[×TcÑTc×TqÑTqóð r-   c           
      óF   • [        [        R                  XX#SU[        5      $ )z’Remove Positive (resample)
xlabel = "Max fraction of features removed"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 13
r   ©rY   r   Úremove_resamplerV   r[   s        r+   Úremove_positive_resamplerŠ   ó   s"   € ô œ×1Ñ1°1¸ÐWXÐZeÔgrÓsÐsr-   c           
      óF   • [        [        R                  XX#SU[        5      $ )z‹Remove Negative (resample)
xlabel = "Max fraction of features removed"
ylabel = "Mean model output"
transform = "identity"
sort_order = 14
r_   rˆ   r[   s        r+   Úremove_negative_resamplerŒ   ý   s"   € ô œ×1Ñ1°1¸ÐWYÐ[fÔhsÓtÐtr-   c           
      ón   • [        [        R                  XX#SU[        R                  R
                  5      $ )z‚Remove Absolute (resample)
xlabel = "Max fraction of features removed"
ylabel = "1 - R^2"
transform = "one_minus"
sort_order = 15
r   )rY   r   r‰   rb   rc   rd   r[   s        r+   Úremove_absolute_resample__r2rŽ     s1   € ô Ü× Ñ  !¨ÀaÈÔV]×VeÑVe×VnÑVnóð r-   c           
      ón   • [        [        R                  XX#SU[        R                  R
                  5      $ )z†Remove Absolute (resample)
xlabel = "Max fraction of features removed"
ylabel = "1 - ROC AUC"
transform = "one_minus"
sort_order = 15
r   )rY   r   r‰   rb   rc   rh   r[   s        r+   Ú!remove_absolute_resample__roc_aucr�     s1   € ô Ü× Ñ  !¨ÀaÈÔV]×VeÑVe×VsÑVsóð r-   c           
      óF   • [        [        R                  XX#SU[        5      $ )z„Keep Positive (impute)
xlabel = "Max fraction of features kept"
ylabel = "Mean model output"
transform = "identity"
sort_order = 16
r   ©rY   r   Úkeep_imputerV   r[   s        r+   Úkeep_positive_imputer”     ro   r-   c           
      óF   • [        [        R                  XX#SU[        5      $ )z‹Keep Negative (impute)
xlabel = "Max fraction of features kept"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 17
r_   r’   r[   s        r+   Úkeep_negative_imputer–   )  rr   r-   c           
      ón   • [        [        R                  XX#SU[        R                  R
                  5      $ )zvKeep Absolute (impute)
xlabel = "Max fraction of features kept"
ylabel = "R^2"
transform = "identity"
sort_order = 18
r   )rY   r   r“   rb   rc   rd   r[   s        r+   Úkeep_absolute_impute__r2r˜   3  ru   r-   c           
      ón   • [        [        R                  XX#SU[        R                  R
                  5      $ )zzKeep Absolute (impute)
xlabel = "Max fraction of features kept"
ylabel = "ROC AUC"
transform = "identity"
sort_order = 19
r   rg   r[   s        r+   Úkeep_absolute_impute__roc_aucrš   ?  rj   r-   c           
      óF   • [        [        R                  XX#SU[        5      $ )z�Remove Positive (impute)
xlabel = "Max fraction of features removed"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 7
r   ©rY   r   Úremove_imputerV   r[   s        r+   Úremove_positive_imputerž   K  r~   r-   c           
      óF   • [        [        R                  XX#SU[        5      $ )zˆRemove Negative (impute)
xlabel = "Max fraction of features removed"
ylabel = "Mean model output"
transform = "identity"
sort_order = 8
r_   rœ   r[   s        r+   Úremove_negative_imputer    U  r�   r-   c           
      ón   • [        [        R                  XX#SU[        R                  R
                  5      $ )zRemove Absolute (impute)
xlabel = "Max fraction of features removed"
ylabel = "1 - R^2"
transform = "one_minus"
sort_order = 9
r   )rY   r   r�   rb   rc   rd   r[   s        r+   Úremove_absolute_impute__r2r¢   _  r„   r-   c           
      ón   • [        [        R                  XX#SU[        R                  R
                  5      $ )zƒRemove Absolute (impute)
xlabel = "Max fraction of features removed"
ylabel = "1 - ROC AUC"
transform = "one_minus"
sort_order = 9
r   rw   r[   s        r+   Úremove_absolute_impute__roc_aucr¤   k  ry   r-   c           
      óF   • [        [        R                  XX#SU[        5      $ )z„Keep Positive (retrain)
xlabel = "Max fraction of features kept"
ylabel = "Mean model output"
transform = "identity"
sort_order = 6
r   ©rY   r   Úkeep_retrainrV   r[   s        r+   Úkeep_positive_retrainr¨   w  s"   € ô œ×.Ñ.°°oÐTUÐWbÔdoÓpÐpr-   c           
      óF   • [        [        R                  XX#SU[        5      $ )z‹Keep Negative (retrain)
xlabel = "Max fraction of features kept"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 7
r_   r¦   r[   s        r+   Úkeep_negative_retrainrª   �  s"   € ô œ×.Ñ.°°oÐTVÐXcÔepÓqÐqr-   c           
      óF   • [        [        R                  XX#SU[        5      $ )z‘Remove Positive (retrain)
xlabel = "Max fraction of features removed"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 11
r   ©rY   r   Úremove_retrainrV   r[   s        r+   Úremove_positive_retrainr®   ‹  s"   € ô œ×0Ñ0°!¸ÐVWÐYdÔfqÓrÐrr-   c           
      óF   • [        [        R                  XX#SU[        5      $ )zŠRemove Negative (retrain)
xlabel = "Max fraction of features removed"
ylabel = "Mean model output"
transform = "identity"
sort_order = 12
r_   r¬   r[   s        r+   Úremove_negative_retrainr°   •  s"   € ô œ×0Ñ0°!¸ÐVXÐZeÔgrÓsÐsr-   c           	      óp   ^ ^^^• UU UU4S jn[        SUR                  S   U5      n	U	[        XU	TX„5      4$ )Nc                 ó‚  >• T
S:X  a&  [         R                  " [        U" U5      5      5      nOT
[        U" U5      5      -  n[         R                  " [	        U5      5      U -  n	[         R
                  " U	[         R                  " US:¬  5      R                  S5      5      R                  [        5      n	T" X‘X2XHTTXg5
      $ )Nr   r   )
r   ÚabsÚ__strip_listÚonesÚlenÚminimumÚarrayÚsumÚastypeÚint)Úfcountr"   r#   r$   r9   r:   r;   r   ÚAÚnmaskÚattribution_signÚmeasurer   Úsummary_functions             €€€€r+   r<   Ú%__run_measure.<locals>.score_function   s�   ø€ Ø˜qÓ Ü—’”|¡M°&Ó$9Ó:Ó;‰Aà ¤<±¸fÓ0EÓ#FÑFˆAÜ—’œ˜F›Ó$ vÑ-ˆÜ—
’
˜5¤"§(¢(¨1°©6Ó"2×"6Ñ"6°qÓ"9Ó:×AÑAÄ#ÓFˆÙØ˜G¨V¸ÐIYÐ[hó
ð 	
r-   r   r   ©Ú__intlogspacer   r>   )
rÀ   r   r   r   r   r¿   r\   rÁ   r<   Úfcountss
   `  ` ` `  r+   rY   rY   Ÿ  s;   û€ ÷	
ð 	
ô ˜A˜qŸw™w q™z¨;Ó7€GØ”N 1¨°/À>Ó_Ð_Ð_r-   c           	      ól   • [        [        R                  XX#[        R                  R
                  U5      $ )zƒBatch Remove Absolute (retrain)
xlabel = "Fraction of features removed"
ylabel = "1 - R^2"
transform = "one_minus"
sort_order = 13
)Ú__run_batch_abs_metricr   Úbatch_remove_retrainrb   rc   rd   r[   s        r+   Ú!batch_remove_absolute_retrain__r2rÉ   ¯  s-   € ô "Ü×%Ñ% q¨_Ì7Ï?É?×KcÑKcÐepóð r-   c           	      ól   • [        [        R                  XX#[        R                  R
                  U5      $ )zyBatch Keep Absolute (retrain)
xlabel = "Fraction of features kept"
ylabel = "R^2"
transform = "identity"
sort_order = 13
)rÇ   r   Úbatch_keep_retrainrb   rc   rd   r[   s        r+   Úbatch_keep_absolute_retrain__r2rÌ   »  s-   € ô "Ü×#Ñ# Q¨?ÌÏÉ×IaÑIaÐcnóð r-   c           	      ól   • [        [        R                  XX#[        R                  R
                  U5      $ )z‡Batch Remove Absolute (retrain)
xlabel = "Fraction of features removed"
ylabel = "1 - ROC AUC"
transform = "one_minus"
sort_order = 13
)rÇ   r   rÈ   rb   rc   rh   r[   s        r+   Ú&batch_remove_absolute_retrain__roc_aucrÎ   Ç  s-   € ô "Ü×%Ñ% q¨_Ì7Ï?É?×KhÑKhÐjuóð r-   c           	      ól   • [        [        R                  XX#[        R                  R
                  U5      $ )z}Batch Keep Absolute (retrain)
xlabel = "Fraction of features kept"
ylabel = "ROC AUC"
transform = "identity"
sort_order = 13
)rÇ   r   rË   rb   rc   rh   r[   s        r+   Ú$batch_keep_absolute_retrain__roc_aucrÐ   Ó  s-   € ô "Ü×#Ñ# Q¨?ÌÏÉ×IfÑIfÐhsóð r-   c           	      ól   ^ ^^• UU U4S jn[        SUR                  S   U5      nU[        XUTXt5      4$ )Nc                 ó†  >• [         R                  " [        U" U5      5      5      n[         R                  " [	        U5      5      U -  R                  [        5      n[         R                  " [        U" U5      5      5      n	[         R                  " [	        U5      5      U -  R                  [        5      n
T" XŠXX$XyTT5
      $ r7   )r   r³   r´   rµ   r¶   rº   r»   )r¼   r"   r#   r$   r9   r:   r;   ÚA_trainÚnkeep_trainÚA_testÚ
nkeep_testÚlossÚmetricr   s              €€€r+   r<   Ú.__run_batch_abs_metric.<locals>.score_functionà  s�   ø€ Ü—&’&œ¡m°GÓ&<Ó=Ó>ˆÜ—w’wœs 7›|Ó,¨vÑ5×=Ñ=¼cÓBˆä—’œ¡]°6Ó%:Ó;Ó<ˆÜ—g’gœc &›kÓ*¨VÑ3×;Ñ;¼CÓ@ˆ
á�k¨wÀÐQXÐbqÐswÓxÐxr-   r   r   rÃ   )	rØ   r   r   r   r   r×   r\   r<   rÅ   s	   `  ` `   r+   rÇ   rÇ   ß  s7   ú€ ÷yô ˜A˜qŸw™w q™z¨;Ó7€GØ”N 1¨°/À>Ó_Ð_Ð_r-   c	           
      ó¾  ^^^^^^^^^•  [           [        R                  R                  5       n	[        R                  R                  S5        / n
[        R                  " [        U 5      R                  5       5      R                  5       [        R                  " [        U5      5      R                  5       -   n[        U5       GH•  m[        [        U 5      XTS9u  mmmmSSR                  [        X³R                  /5      -   S-   n[         R"                  R                  XŒS-   5      n[         R"                  R%                  U5      (       a,  ['        US5       n[         R(                  " U5      mSSS5        OEU" 5       mTR+                  TT5        ['        US	5       n[         R,                  " TU5        SSS5        S
R                  UR                  U[/        U5      [/        U5      [/        T5      U/5      mUUUUUUUUU4	S jnT[0        ;  a/  U
R3                  U" [5        [6        U5      " TT5      5      5        GM~  U
R3                  U" S5      5        GM˜     [        R                  R                  U	5        [        R8                  " U
5      R;                  S5      $ ! [         a    [        S5      ef = f! , (       d  f       GN= f! , (       d  f       GN= f)zTest an explanation method.zGThe 'dill' package could not be loaded and is needed for the benchmark!r
   r   Úmodel_cache__vÚ__z.pickleÚrbNÚwbr%   c                 ó´   >	^ • U U4S jnTc  T
" TTTTUT	T5      $ / nT H!  nUR                  T
" UTTTTUT	T5      5        M#     [        R                  " U5      $ )Nc                 óH   >• T[         ;  a  T" U 5      [         T'   [         T   $ r7   )Ú_attribution_cache)ÚX_innerr:   Úattr_keys    €€r+   Úcached_attr_functionÚ;__score_method.<locals>.score.<locals>.cached_attr_function  s'   ø€ ØÔ#5Ó5Ù3@ÀÓ3IÔ& xÑ0Ü)¨(Ñ3Ð3r-   )r   r   r¸   )r:   rä   ÚscoresÚfr#   r"   rã   rÅ   r!   r&   r<   r9   r$   s   `   €€€€€€€€€r+   ÚscoreÚ__score_method.<locals>.score  si   ù€ ö4ð ‰Ù% g¨v°wÀÐH\Ð^cÐefÓgÐgà�Û �AØ—M‘M¡.°°G¸VÀWÈfÐVjÐlqÐstÓ"uÖvñ !ä—x’x Ó'Ð'r-   r   )ÚpickleÚ	NameErrorÚImportErrorr   r   r   ÚhashlibÚsha256r   ÚflattenÚ	hexdigestr   r   Újoinr   Ú__name__ÚosÚpathÚisfileÚopenÚloadr   ÚdumpÚstrrá   r   r   r   r¸   r   )r   r   rÅ   r   r<   r   Únrepsr   Ú	cache_dirr   r    Ú	data_hashÚmodel_idÚ
cache_filerç   rè   r#   r"   rã   r!   r&   r9   r$   s     ` `           @@@@@@@r+   r>   r>   ð  s(  ÿø€ ðeÝô �y‰y�~‰~Ó€HÜ‡I�I‡N�N�4Ôð €Kä—’œy¨›|×3Ñ3Ó5Ó6×@Ñ@ÓBÄWÇ^Â^ÔT]Ð^_ÓT`ÓEa×EkÑEkÓEmÑm€IÜ�5�\ˆÜ+;¼IÀa»LÈ!ÐopÑ+qÑ(ˆ�˜ &ð $ d§i¡i´¸i×IaÑIaÐ0bÓ&cÑcÐfoÑoˆÜ—W‘W—\‘\ )¸	Ñ-AÓBˆ
Ü�7‰7�>‰>˜*×%Ñ%Ü�j $Ô'¨1ÜŸš A›�÷ (Ð'ñ $Ó%ˆEØ�I‰I�g˜wÔ'Ü�j $Ô'¨1Ü—’˜E 1Ô%÷ (ð —8‘8˜_×5Ñ5°{ÄCÈ	ÃNÔTWÐX]ÓT^Ô`cÐdeÓ`fÐhqÐrÓsˆ÷	(õ 	(ð  Ô-Ó-Ø×Ñ™u¤W¬W°kÔ%BÀ5È'Ó%RÓS×Tà×Ñ™u T›{×+ñI ôL ‡I�I‡N�N�8ÔÜ�8Š8�KÓ ×%Ñ% aÓ(Ð(øôc ó eÜÐcÓdÐdðeú÷" (Ö'ú÷
 (Ö'ús#   ‹J" ÅJ;ÆKÊ"J8Ê;
K
	Ë
K	c                 óª   • U[         L a  U [        L a  [        $ U[        L a  U [        L a  [
        $ [        q[         q[        qU qUq U " U5      q[        $ r7   )Ú
__cache_X0Ú
__cache_f0Ú__cache0Ú
__cache_X1Ú
__cache_f1Ú__cache1)rç   r   s     r+   Ú__check_cacher  3  sO   € ð 	ŒJ‚˜1¤
š?ÜˆØ	
ŒjŠ˜Q¤*š_Üˆäˆ
Üˆ
ÜˆØˆ
Øˆ
Ù�Q“4ˆÜˆr-   c                 óÂ   • [         R                  " [         R                  " XU -
  [         R                  " SSUSS9S-
  -  S-  -   5      R	                  [
        5      5      $ )Nr   r   T)Úendpointé	   )r   ÚuniqueÚroundÚlogspacerº   r»   )r'   ÚendÚcounts      r+   rÄ   rÄ   D  sN   € Ü�9Š9”R—X’X˜e¨U¡{´r·{²{À1ÀaÈÐY]Ñ7^ÐabÑ7bÑ&cÐfgÑ&gÑgÓh×oÑoÔpsÓtÓuÐur-   c                 ó@   • [        U S5      (       a  U R                  n U $ )z$Converts DataFrames to numpy arrays.Úvalues)Úhasattrr  )r   s    r+   r   r   H  s   € äˆq�(×ÑØ�H‰HˆØ€Hr-   c                 ó:   • [        U [        5      (       a  U S   $ U $ )z`This assumes that if you have a list of outputs you just want the second one (the second class).r   )Ú
isinstanceÚlist)Úattrss    r+   r´   r´   O  s   € ä�%œ×ÑØ�Q‰xˆàˆr-   c                 ó  • SnSn[         R                  " XE45      nUR                    [         R                  " U5      U-  nSUSS2S4'   X'SS& [	        SSS5       H  nSXhS4'   X'U'   M     X7S'   U " 5       n	U	R                  Xg5        U	$ )Ni@B r   r   r   iè  )r   Úzerosr   rµ   r   r   )
r   Úval00Úval01Úval11ÚNÚMr   r   r!   r&   s
             r+   Ú
_fit_humanr  W  s•   € à€AØ	€AÜ
�Š�!�Ó€AØ‡G‚GÜ
�Š�‹
�UÑ€AØ€A€aˆ€fˆa€i�LØ€aˆ€IÜ�1�g˜tÖ$ˆØˆˆQˆ$‰Øˆ!‹ñ %ð €a�DÙÓ€EØ	‡I�Iˆa„OØ€Lr-   c                 ó¦  • [         R                  " U 5      R                  5       S:X  d   S5       e[         R                  " S5      nU(       d@  U(       d9  [         R                  " / SQ5      n[         R                  " / SQ/5      USS S 24'   O�U(       d@  U(       a9  [         R                  " / SQ5      n[         R                  " / SQ/5      USS S 24'   OFU(       a?  U(       a8  [         R                  " / SQ5      n[         R                  " / S	Q/5      USS S 24'   [        USS
S5      n[        [        U5      " Xp5      nU" U5      n	SWU	SS S 24   44$ )Nr   úJHuman agreement metrics are only for use with the human_agreement dataset!©r   r   ©rD   rD   rD   ©rD   rD   rA   ©rD   ç       @rD   ©rD   rA   rA   ©ç      @r'  rD   ©rA   rA   rA   r   é
   Úhuman©r   r³   Úmaxr  r¸   r  r   r   ©
r   r   r   ÚfeverÚcoughr#   Úhuman_consensusr&   r:   Úmethods_attrss
             r+   Ú
_human_andr2  i  óþ   € Ü�6Š6�!‹9�=‰=‹?˜aÓÐmÐ!mÓmÐô �XŠX�hÓ€FÞžÜŸ(š(¢?Ó3ˆÜ—x’x¢Ð 1Ó2ˆˆq’!ˆtŠÞ–uÜŸ(š(¢?Ó3ˆÜ—x’x¢Ð 1Ó2ˆˆq’!ˆtŠÞ	–5ÜŸ(š(¢?Ó3ˆÜ—x’x¢Ð 1Ó2ˆˆq’!ˆt‰ô �¨¨1¨bÓ1€EäœG [Ô1°%Ó;€MÙ! &Ó)€MØ�_ m°A²q°DÑ&9Ð:Ð:Ð:r-   c                 ó   • [        XUSS5      $ )a�  AND (false/false)

This tests how well a feature attribution method agrees with human intuition
for an AND operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if cough: +2 points
if fever and cough: +6 points

transform = "identity"
sort_order = 0
F©r2  ©r   r   r   r   s       r+   Úhuman_and_00r7  €  ó   € ô �a¨+°u¸eÓDÐDr-   c                 ó   • [        XUSS5      $ )a€  AND (false/true)

This tests how well a feature attribution method agrees with human intuition
for an AND operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if cough: +2 points
if fever and cough: +6 points

transform = "identity"
sort_order = 1
FTr5  r6  s       r+   Úhuman_and_01r:  ‘  ó   € ô �a¨+°u¸dÓCÐCr-   c                 ó   • [        XUSS5      $ )a  AND (true/true)

This tests how well a feature attribution method agrees with human intuition
for an AND operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if cough: +2 points
if fever and cough: +6 points

transform = "identity"
sort_order = 2
Tr5  r6  s       r+   Úhuman_and_11r=  ¢  ó   € ô �a¨+°t¸TÓBÐBr-   c                 ó¦  • [         R                  " U 5      R                  5       S:X  d   S5       e[         R                  " S5      nU(       d@  U(       d9  [         R                  " / SQ5      n[         R                  " / SQ/5      USS S 24'   O�U(       d@  U(       a9  [         R                  " / SQ5      n[         R                  " / SQ/5      USS S 24'   OFU(       a?  U(       a8  [         R                  " / SQ5      n[         R                  " / S	Q/5      USS S 24'   [        USS
S5      n[        [        U5      " Xp5      nU" U5      n	SWU	SS S 24   44$ )Nr   r  r   r!  r"  ©rD   g       @rD   r%  r&  r(  é   r)  r*  r+  r-  s
             r+   Ú	_human_orrB  ³  r3  r-   c                 ó   • [        XUSS5      $ )a~  OR (false/false)

This tests how well a feature attribution method agrees with human intuition
for an OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if cough: +2 points
if fever or cough: +6 points

transform = "identity"
sort_order = 0
F©rB  r6  s       r+   Úhuman_or_00rE  Ê  s   € ô �Q¨°e¸UÓCÐCr-   c                 ó   • [        XUSS5      $ )a}  OR (false/true)

This tests how well a feature attribution method agrees with human intuition
for an OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if cough: +2 points
if fever or cough: +6 points

transform = "identity"
sort_order = 1
FTrD  r6  s       r+   Úhuman_or_01rG  Û  s   € ô �Q¨°e¸TÓBÐBr-   c                 ó   • [        XUSS5      $ )a|  OR (true/true)

This tests how well a feature attribution method agrees with human intuition
for an OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if cough: +2 points
if fever or cough: +6 points

transform = "identity"
sort_order = 2
TrD  r6  s       r+   Úhuman_or_11rI  ì  s   € ô �Q¨°d¸DÓAÐAr-   c                 ó¦  • [         R                  " U 5      R                  5       S:X  d   S5       e[         R                  " S5      nU(       d@  U(       d9  [         R                  " / SQ5      n[         R                  " / SQ/5      USS S 24'   O�U(       d@  U(       a9  [         R                  " / SQ5      n[         R                  " / SQ/5      USS S 24'   OFU(       a?  U(       a8  [         R                  " / SQ5      n[         R                  " / S	Q/5      USS S 24'   [        USS
S5      n[        [        U5      " Xp5      nU" U5      n	SWU	SS S 24   44$ )Nr   r  r   r!  r"  r@  r%  ©r$  r$  rD   r(  rA  é   r*  r+  r-  s
             r+   Ú
_human_xorrM  ý  óþ   € Ü�6Š6�!‹9�=‰=‹?˜aÓÐmÐ!mÓmÐô �XŠX�hÓ€FÞžÜŸ(š(¢?Ó3ˆÜ—x’x¢Ð 1Ó2ˆˆq’!ˆtŠÞ–uÜŸ(š(¢?Ó3ˆÜ—x’x¢Ð 1Ó2ˆˆq’!ˆtŠÞ	–5ÜŸ(š(¢?Ó3ˆÜ—x’x¢Ð 1Ó2ˆˆq’!ˆt‰ô �¨¨1¨aÓ0€EäœG [Ô1°%Ó;€MÙ! &Ó)€MØ�_ m°A²q°DÑ&9Ð:Ð:Ð:r-   c                 ó   • [        XUSS5      $ )a–  XOR (false/false)

This tests how well a feature attribution method agrees with human intuition
for an eXclusive OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if cough: +2 points
if fever or cough but not both: +6 points

transform = "identity"
sort_order = 3
F©rM  r6  s       r+   Úhuman_xor_00rQ    r8  r-   c                 ó   • [        XUSS5      $ )a•  XOR (false/true)

This tests how well a feature attribution method agrees with human intuition
for an eXclusive OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if cough: +2 points
if fever or cough but not both: +6 points

transform = "identity"
sort_order = 4
FTrP  r6  s       r+   Úhuman_xor_01rS  %  r;  r-   c                 ó   • [        XUSS5      $ )a”  XOR (true/true)

This tests how well a feature attribution method agrees with human intuition
for an eXclusive OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if cough: +2 points
if fever or cough but not both: +6 points

transform = "identity"
sort_order = 5
TrP  r6  s       r+   Úhuman_xor_11rU  6  r>  r-   c                 ó¦  • [         R                  " U 5      R                  5       S:X  d   S5       e[         R                  " S5      nU(       d@  U(       d9  [         R                  " / SQ5      n[         R                  " / SQ/5      USS S 24'   O�U(       d@  U(       a9  [         R                  " / SQ5      n[         R                  " / SQ/5      USS S 24'   OFU(       a?  U(       a8  [         R                  " / SQ5      n[         R                  " / S	Q/5      USS S 24'   [        USS
S5      n[        [        U5      " Xp5      nU" U5      n	SWU	SS S 24   44$ )Nr   r  r   r!  r"  r#  r%  rK  r(  r   rL  r*  r+  r-  s
             r+   Ú
_human_sumrW  G  rN  r-   c                 ó   • [        XUSS5      $ )aE  SUM (false/false)

This tests how well a feature attribution method agrees with human intuition
for a SUM operation. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if cough: +2 points

transform = "identity"
sort_order = 0
F©rW  r6  s       r+   Úhuman_sum_00rZ  ^  s   € ô �a¨+°u¸eÓDÐDr-   c                 ó   • [        XUSS5      $ )aD  SUM (false/true)

This tests how well a feature attribution method agrees with human intuition
for a SUM operation. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if cough: +2 points

transform = "identity"
sort_order = 1
FTrY  r6  s       r+   Úhuman_sum_01r\  n  s   € ô �a¨+°u¸dÓCÐCr-   c                 ó   • [        XUSS5      $ )aC  SUM (true/true)

This tests how well a feature attribution method agrees with human intuition
for a SUM operation. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if cough: +2 points

transform = "identity"
sort_order = 2
TrY  r6  s       r+   Úhuman_sum_11r^  ~  s   € ô �a¨+°t¸TÓBÐBr-   )é   )r)  r   z/tmp)Srí   ró   r   Únumpyr   rb   Ú r   r   r   Údillrê   Ú	ExceptionÚsklearn.model_selectionr   Úsklearn.cross_validationr,   r8   rT   rV   r]   r`   re   ri   rn   rq   rt   rx   r}   r€   rƒ   r†   rŠ   rŒ   rŽ   r�   r”   r–   r˜   rš   rž   r    r¢   r¤   r¨   rª   r®   r°   rY   rÉ   rÌ   rÎ   rÐ   rÇ   rá   r>   r  r   r  r  r  r  r  rÄ   r   r´   r  r2  r7  r:  r=  rB  rE  rG  rI  rM  rQ  rS  rU  rW  rZ  r\  r^  rR   r-   r+   Ú<module>rf     sÓ  ðÛ Û 	Û ã Û å ß ð	Ûð:Ý8ò
&òDZò$)ò@ô
nôoô	ô	ôpôqô	ô	ôrôsô	ô	ôtôuô	ô	ôpôqô	ô	ôrôsô	ô	ôqôrôsôtò`ô 	ô	ô	ô	ò`ð Ð ð ekô7)ðv €Ø€
Ø€
Ø€Ø€
Ø€
òò"vòòòò$;ò.Eò"Dò"Cò";ò.Dò"Cò"Bò";ò.Eò"Dò"Cò";ò.Eò Dó Cøðc ó 	Úð	ûð
 ó :ß9Ð9ð:ús"   ¤D5 ©E Ä5D?Ä>D?ÅEÅE