ó
    †ñ:iÖo  ã                   ól   • S SK r S SKJr  S SKrS SKrSSKJ	r	  SSK
Jr  SSKJr  SSKJr  S
S jrSS	 jrg)é    Né   )ÚExplanation)Úformat_valueé   )Úlabels)Ú	get_stylec                 óÔ   • [        5       nUSL a  [        R                  " 5         [        U [        5      (       d  Sn[        U5      eU R                  n[        U5      S:w  a  SU S3n[        U5      e[        U R                  5      nU R                  b  U R                  OU R                  nU R                  n[        U SS5      n	[        U SS5      n
U R                  n[        U[         R"                  5      (       a$  Uc  [%        UR&                  5      nUR                  nUcL  [(        R*                  " [-        [        U5      5       Vs/ s H  n[.        S	   [1        U5      -  PM     sn5      n[3        U[        U5      5      nS
n[-        US-
  SS5      n[(        R4                  " [(        R6                  " U5      * 5      n/ n/ n/ n/ n/ n/ n/ n/ n/ n/ nXkR9                  5       -   n[-        US-   5       Vs/ s H  nSPM     nn[        R:                  " 5       R=                  SXÞ-  S-   5        U[        U5      :X  a  UnOUS-
  n[-        U5       GHÖ  nUUU      nUU-  nUS:¼  ag  UR?                  Xü   5        UR?                  U5        U	b.  UR?                  U	UU      5        UR?                  U
UU      5        UR?                  U5        OfUR?                  Xü   5        UR?                  U5        U	b.  UR?                  U	UU      5        UR?                  U
UU      5        UR?                  U5        UU:w  d	  US-   U:  a4  [        R@                  " UU/Xü   S-
  S-
  Xü   S-   /URB                  SS
SS9  Uc  UUU      UXü   '   GM:  [(        RD                  " [G        UUU      5      [(        RH                  5      (       a8  [K        [        UUU      5      S5      S-   [1        UUU      5      -   UXü   '   GM«  [1        UUU      5      S-   [1        UUU      5      -   UXü   '   GMÙ     U[        U5      :  a‘  [        U 5      U-
  S-    S3US'   UU-
  n U S:  a8  UR?                  S5        UR?                  U * 5        UR?                  UU -   5        O7UR?                  S5        UR?                  U * 5        UR?                  UU -   5        U[%        [(        R*                  " U5      [(        R*                  " U5      -   5      -   U-   [%        [(        R*                  " U5      [(        R*                  " U5      -   5      -   n![(        RL                  " U!5      [(        R2                  " U!5      -
  n"[(        R*                  " U V#s/ s H  n#U#S:  a  SU"-  OSPM     sn#5      n$[        RN                  " U[(        R*                  " U5      U$-   SU"-  -   [(        R*                  " U5      SU"-  -
  URP                  SS9  [(        R*                  " U V#s/ s H  n#U#* S:  a  SU"-  OSPM     sn#5      n$[        RN                  " U[(        R*                  " U5      U$-   SU"-  -
  [(        R*                  " U5      SU"-  -   URR                  SS9  Sn%Sn&[        RT                  " 5       S   [        RT                  " 5       S   -
  n'[        R:                  " 5       n([        RV                  " 5       n)U)RY                  5       R[                  U(R\                  R_                  5       5      n*U*R`                  n+U'U+-  n,U,U%-  n-U(Rb                  Re                  5       n.[-        [        U5      5       GHr  nUU   n/[        Rf                  " UU   UU   U/U--
  S[3        U/U-5      URP                  U&U&S9n0Ubf  U[        U5      :  aW  [        Rh                  " UU   UU   -   UU   [(        R*                  " UU   UU   -
  /UU   UU   -
  //5      URj                  S9  [        Rl                  " UU   S
U/-  -   UU   [K        UU   S 5      S!S!URn                  S"S#9n1U1RY                  U.S$9n2U0RY                  U.S$9n3U2R`                  U3R`                  :”  d  GM"  U1Rq                  5         [        Rl                  " UU   S%U,-  -   U/-   UU   [K        UU   S 5      S&S!URP                  S"S#9n1GMu     [-        [        U5      5       GHu  nUU   n/[        Rf                  " UU   UU   U/* U--
  * S[3        U/* U-5      URR                  U&U&S9n0Ubf  U[        U5      :  aW  [        Rh                  " UU   UU   -   UU   [(        R*                  " UU   UU   -
  /UU   UU   -
  //5      URr                  S9  [        Rl                  " UU   S
U/-  -   UU   [K        UU   S 5      S!S!URn                  S"S#9n1U1RY                  U.S$9n2U0RY                  U.S$9n3U2R`                  U3R`                  :”  d  GM%  U1Rq                  5         [        Rl                  " UU   S%U,-  -
  U/-   UU   [K        UU   S 5      S'S!URR                  S"S#9n1GMx     [%        [-        U5      5      [%        [(        Rt                  " U5      S(-   5      -   n4[        Rv                  " U4USS USS  V5s/ s H  n5U5Ry                  S)5      S   PM     sn5-   S*S+9  [-        U5       H$  n[        Rz                  " XÃR|                  S
S,SS-9  M&     [        R~                  " USSU-  URB                  SS
SS9  XkR9                  5       -   n6[        R~                  " U6SSURB                  SS
SS9  [        RV                  " 5       R€                  Rƒ                  S.5        [        RV                  " 5       R„                  Rƒ                  S/5        [        RV                  " 5       R†                  S'   R‰                  S5        [        RV                  " 5       R†                  S0   R‰                  S5        [        RV                  " 5       R†                  S&   R‰                  S5        U)R‹                  S*S19  U)R�                  5       u  n7n8U)R�                  5       n9U9R‘                  U7U85        U9R“                  Xf[3        S(U8S2-  5      -   /5        U9R•                  S3S4[K        US5      -   S5-   /S"S&S69  U9R†                  S'   R‰                  S5        U9R†                  S0   R‰                  S5        U9R†                  S&   R‰                  S5        U9R�                  5       n:U:R‘                  U7U85        U:R“                  XkR9                  5       -   XkR9                  5       -   [3        S(U8S2-  5      -   /5        U:R•                  S7S8[K        U6S5      -   S5-   /S"S&S69  U:R€                  R—                  5       n;U;S   R™                  U;S   R›                  5       [œ        Rž                  R¡                  S9SU(R\                  5      -   5        U;S   R™                  U;S   R›                  5       [œ        Rž                  R¡                  S:SU(R\                  5      -   5        U;S   R£                  UR¤                  5        U:R†                  S'   R‰                  S5        U:R†                  S0   R‰                  S5        U:R†                  S&   R‰                  S5        U9R€                  R—                  5       n;U;S   R™                  U;S   R›                  5       [œ        Rž                  R¡                  S;SU(R\                  5      -   5        U;S   R™                  U;S   R›                  5       [œ        Rž                  R¡                  S<S=U(R\                  5      -   5        U;S   R£                  UR¤                  5        U)R„                  R—                  5       n;[-        U5       H!  nU;U   R£                  UR¤                  5        M#     U(       a  [        R¦                  " 5         g[        RV                  " 5       $ s  snf s  snf s  sn#f s  sn#f s  sn5f )>a  Plots an explanation of a single prediction as a waterfall plot.

The SHAP value of a feature represents the impact of the evidence provided by that feature on the model's
output. The waterfall plot is designed to visually display how the SHAP values (evidence) of each feature
move the model output from our prior expectation under the background data distribution, to the final model
prediction given the evidence of all the features.

Features are sorted by the magnitude of their SHAP values with the smallest
magnitude features grouped together at the bottom of the plot when the number of
features in the models exceeds the ``max_display`` parameter.

Parameters
----------
shap_values : Explanation
    A one-dimensional :class:`.Explanation` object that contains the feature values and SHAP values to plot.

max_display : int
    The maximum number of features to display (default is 10).

show : bool
    Whether :external+mpl:func:`matplotlib.pyplot.show()` is called before returning.
    Setting this to ``False`` allows the plot to be customized further after it
    has been created, returning the current axis via plt.gca().

Examples
--------
See `waterfall plot examples <https://shap.readthedocs.io/en/latest/example_notebooks/api_examples/plots/waterfall.html>`_.

FzRThe waterfall plot requires an `Explanation` object as the `shap_values` argument.r   zeThe waterfall plot can currently only plot a single explanation, but a matrix of explanations (shape z‹) was passed! Perhaps try `shap.plots.waterfall(shap_values[0])` or for multi-output models, try `shap.plots.waterfall(shap_values[0, 0])`.NÚlower_boundsÚupper_boundsÚFEATUREç      à?éÿÿÿÿÚ é   ç      ø?r   é   çš™™™™™Ù?ú--©ÚcolorÚ	linestyleÚ	linewidthÚzorderú%0.03fú = ú other featuresçš™™™™™¹?ç{®Gáz”?ç{®Gáz„?©Úleftr   Úalphaçš™™™™™¹¿ç{®Gáz´?çš™™™™™é?©Úhead_lengthr   ÚwidthÚ
head_width©ÚxerrÚecolorú%+0.02fÚcenteré   ©ÚhorizontalalignmentÚverticalalignmentr   Úfontsize©ÚrendererçrÇqÇ±?r!   Úrightç:Œ0âŽyE>Ú=é   ©r3   ©r   é   ©r   ÚlwÚdashesr   ÚbottomÚnoneÚtop©Ú	labelsizeg»½×Ùß|Û=ú

$E[f(X)]$ú
$ = Ú$©r3   Úhaú$f(x)$ú$ = çrÇqÇÁ¿çUUUUUUÅ?çrÇqÇÑ¿çä8Žã8ŽÓ?çÇqÇqŒ¿)Tr   ÚpltÚioffÚ
isinstancer   Ú	TypeErrorÚshapeÚlenÚ
ValueErrorÚfloatÚbase_valuesÚdisplay_dataÚdataÚfeature_namesÚgetattrÚvaluesÚpdÚSeriesÚlistÚindexÚnpÚarrayÚranger   ÚstrÚminÚargsortÚabsÚsumÚgcfÚset_size_inchesÚappendÚplotÚvlines_colorÚ
issubdtypeÚtypeÚnumberr   ÚmaxÚbarhÚprimary_color_positiveÚprimary_color_negativeÚxlimÚgcaÚget_window_extentÚtransformedÚdpi_scale_transÚinvertedr(   ÚcanvasÚget_rendererÚarrowÚerrorbarÚsecondary_color_positiveÚtextÚ
text_colorÚremoveÚsecondary_color_negativeÚarangeÚyticksÚsplitÚaxhlineÚhlines_colorÚaxvlineÚxaxisÚset_ticks_positionÚyaxisÚspinesÚset_visibleÚtick_paramsÚget_xlimÚtwinyÚset_xlimÚ
set_xticksÚset_xticklabelsÚget_majorticklabelsÚset_transformÚget_transformÚ
matplotlibÚ
transformsÚScaledTranslationÚ	set_colorÚtick_labels_colorÚshow)<Úshap_valuesÚmax_displayr    ÚstyleÚemsgÚsv_shaperZ   Úfeaturesr]   r
   r   r_   ÚiÚnum_featuresÚ
row_heightÚrngÚorderÚ	pos_leftsÚpos_indsÚ
pos_widthsÚpos_lowÚpos_highÚ	neg_leftsÚneg_indsÚ
neg_widthsÚneg_lowÚneg_highÚlocÚ_ÚyticklabelsÚnum_individualÚsvalÚremaining_impactÚpointsÚdatawÚwÚlabel_paddingr'   Ú	bar_widthÚxlenÚfigÚaxÚbboxr(   Úbbox_to_xscaleÚ	hl_scaledr5   ÚdistÚ	arrow_objÚtxt_objÚ	text_bboxÚ
arrow_bboxÚ	ytick_posÚlabelÚfxÚxminÚxmaxÚax2Úax3Útick_labelss<                                                               ÚX/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/shap/plots/_waterfall.pyÚ	waterfallrÕ      s  € ô< ‹K€Eàˆu‚}Ü�ŠŒ
ô �k¤;×/Ñ/ØcˆÜ˜‹oÐð × Ñ €HÜ
ˆ8ƒ}˜Óð-Ø-5¨Jð 7=ð=ð 	ô ˜ÓÐä˜×/Ñ/Ó0€KØ+6×+CÑ+CÑ+Oˆ{×'Ò'ÐU`×UeÑUe€HØ×-Ñ-€MÜ˜;¨¸Ó=€LÜ˜;¨¸Ó=€LØ×Ñ€Fô �(œBŸI™I×&Ñ&ØÑ Ü  §¡Ó0ˆMØ—?‘?ˆð ÑÜŸšÄeÌCÐPVËKÔFXÓ!YÒFXÀ¤&¨Ñ"3´c¸!³fÔ"<ÑFXÑ!YÓZˆô �{¤C¨£KÓ0€LØ€JÜ
�˜qÑ  " bÓ
)€CÜ�JŠJœŸš˜v›�Ó'€EØ€IØ€HØ€JØ€GØ€HØ€IØ€HØ€JØ€GØ€HØ
Ÿ
™
›Ñ
$€CÜ$ \°AÑ%5Ô6Ó7Ò6˜!“2Ñ6€KÐ7ô ‡G‚GƒI×Ñ˜a Ñ!:¸SÑ!@ÔAð ”s˜6“{Ó"Ø%‰à%¨Ñ)ˆô �>×"ˆØ�e˜A‘hÑˆØˆt‰ˆØ�1‹9Ø�O‰O˜C™FÔ#Ø×Ñ˜dÔ#ØÑ'Ø—‘˜|¨E°!©HÑ5Ô6Ø—‘ ¨U°1©XÑ 6Ô7Ø×Ñ˜SÕ!à�O‰O˜C™FÔ#Ø×Ñ˜dÔ#ØÑ'Ø—‘˜|¨E°!©HÑ5Ô6Ø—‘ ¨U°1©XÑ 6Ô7Ø×Ñ˜SÔ!Ø˜\Ó)¨Q°©U°^Ó-CÜ�HŠHØ�c�
Ø‘˜!‘˜cÑ! 3¡6¨C¡<Ð0Ø×(Ñ(ØØØòð ÑØ"/°°a±Ñ"9ˆK˜™Ôä�}Š}œT (¨5°©8Ñ"4Ó5´r·y±y×AÑAä ¤ x°°a±Ñ'9Ó!:¸HÓEÈÑMÔPSÐTaÐbgÐhiÑbjÑTkÓPlÑlð ˜C™FÔ#ô '*¨(°5¸±8Ñ*<Ó&=ÀÑ&EÌÈMÐZ_Ð`aÑZbÑLcÓHdÑ&d�˜C™FÔ#ñE #ðJ ”c˜&“kÓ!Ü Ó,¨|Ñ;¸aÑ?Ð@ÀÐPˆ�A‰Ø&¨Ñ,ÐØ˜aÓØ�O‰O˜AÔØ×ÑÐ/Ð/Ô0Ø×Ñ˜SÐ#3Ñ3Õ4à�O‰O˜AÔØ×ÑÐ/Ð/Ô0Ø×Ñ˜SÐ#3Ñ3Ô4ð 	Ü
Œr�xŠx˜	Ó"¤R§X¢X¨jÓ%9Ñ9Ó
:ñ	;à
ñ	ô Œr�xŠx˜	Ó"¤R§X¢X¨jÓ%9Ñ9Ó
:ñ	;ð ô �FŠF�6‹NœRŸVšV F›^Ñ+€Eô —H’HÁ:ÓNÂ:¸a¨Q°«U˜c Ešk¸Ò9Á:ÑNÓO€MÜ‡H‚HØÜ
�Š�Ó˜}Ñ,¨t°e©|Ñ;Ü�XŠX�iÓ  4¨%¡<Ñ/Ø×*Ñ*Øòô —H’HÁZÓPÂZÀ¨q¨b°1«f˜d Ušl¸!Ò;ÁZÑPÓQ€MÜ‡H‚HØÜ
�Š�Ó˜}Ñ,¨t°e©|Ñ;Ü�XŠX�iÓ  4¨%¡<Ñ/Ø×*Ñ*Øòð €KØ€IÜ�8Š8‹:�a‰=œ3Ÿ8š8›: a™=Ñ(€DÜ
�'Š'‹)€CÜ	�Š‹€BØ×ÑÓ!×-Ñ-¨c×.AÑ.A×.JÑ.JÓ.LÓM€DØ�J‰J€EØ˜E‘\€NØ Ñ,€IØ�z‰z×&Ñ&Ó(€Hô ”3�x“=×!ˆØ˜!‰}ˆÜ—I’IØ�a‰LØ�Q‰KØ�9ÑØÜ˜D )Ó,Ø×.Ñ.ØØ ñ	
ˆ	ð Ñ 1¤s¨7£|Ó#3Ü�LŠLØ˜!‘˜z¨!™}Ñ,Ø˜‘Ü—X’X 
¨1¡°¸±
Ñ :Ð;¸hÀq¹kÈJÐWXÉMÑ>YÐ=ZÐ[Ó\Ø×5Ñ5ò	ô —(’(Ø�a‰L˜3 ™:Ñ%Ø�Q‰KÜ˜ A™¨	Ó2Ø (Ø&Ø×"Ñ"Øñ
ˆð ×-Ñ-°xÐ-Ð@ˆ	Ø×0Ñ0¸(Ð0ÐCˆ
ð �?‰?˜Z×-Ñ-Ö-Ø�N‰NÔä—h’hØ˜!‘ ¨.Ñ8Ñ8¸4Ñ?Ø˜‘Ü˜Z¨™]¨IÓ6Ø$*Ø"*Ø×2Ñ2Øñ‹GñK "ô` ”3�x“=×!ˆØ˜!‰}ˆä—I’IØ�a‰LØ�Q‰KØˆe�iÑÐ ØÜ˜T˜E 9Ó-Ø×.Ñ.ØØ ñ	
ˆ	ð Ñ 1¤s¨7£|Ó#3Ü�LŠLØ˜!‘˜z¨!™}Ñ,Ø˜‘Ü—X’X 
¨1¡°¸±
Ñ :Ð;¸hÀq¹kÈJÐWXÉMÑ>YÐ=ZÐ[Ó\Ø×5Ñ5ò	ô —(’(Ø�a‰L˜3 ™:Ñ%Ø�Q‰KÜ˜ A™¨	Ó2Ø (Ø&Ø×"Ñ"Øñ
ˆð ×-Ñ-°xÐ-Ð@ˆ	Ø×0Ñ0¸(Ð0ÐCˆ
ð �?‰?˜Z×-Ñ-Ö-Ø�N‰NÔä—h’hØ˜!‘ ¨.Ñ8Ñ8¸4Ñ?Ø˜‘Ü˜Z¨™]¨IÓ6Ø$+Ø"*Ø×2Ñ2Øñ‹GñM "ôd ”U˜<Ó(Ó)¬D´·²¸<Ó1HÈ4Ñ1OÓ,PÑP€IÜ‡J‚Jˆy˜+ c rÐ*ÐP[Ð\_Ð]_ÑP`Ó-aÒP`Àu¨e¯k©k¸#Ó.>¸rÔ.BÑP`Ñ-aÑaÐlnÒoô �<Ö ˆÜ�Š�A×/Ñ/°CÀÈrÔRñ !ô ‡K‚K�˜Q  LÑ 0¸×8JÑ8JÐVZÐfiÐrtÒuØ	—z‘z“|Ñ	#€BÜ‡K‚K��A�q × 2Ñ 2¸dÈcÐZ\Ò]ô ‡G‚GƒI‡O�O×&Ñ& xÔ0Ü‡G‚GƒI‡O�O×&Ñ& vÔ.Ü‡G‚GƒI×Ñ�WÑ×)Ñ)¨%Ô0Ü‡G‚GƒI×Ñ�UÑ×'Ñ'¨Ô.Ü‡G‚GƒI×Ñ�VÑ×(Ñ(¨Ô/Ø‡N�N˜R€NÑ ð —‘“�J€Dˆ$Ø
�(‰(‹*€CØ‡L�L��tÔØ‡N�NØ	¤C¨¨d°U©lÓ$;Ñ;Ð<ôð ×Ñ˜¨´<ÀÈXÓ3VÑ(VÐY\Ñ(\Ð]ÐhjÐouÐÑvØ‡J�JˆwÑ×#Ñ# EÔ*Ø‡J�JˆuÑ×!Ñ! %Ô(Ø‡J�JˆvÑ×"Ñ" 5Ô)ð �)‰)‹+€CØ‡L�L��tÔØ‡N�NØ	—z‘z“|Ñ	# [·:±:³<Ñ%?Ä#ÀdÈDÐSXÉLÓBYÑ%YÐZôð ×Ñ˜ 6¬L¸¸XÓ,FÑ#FÈÑ#LÐMÐXZÐ_eÐÑfØ—)‘)×/Ñ/Ó1€KØ��N× Ñ Ø�A‰×$Ñ$Ó&¬×)>Ñ)>×)PÑ)PÐQ[Ð]^Ð`c×`sÑ`sÓ)tÑtôð ��N× Ñ Ø�A‰×$Ñ$Ó&¬×)>Ñ)>×)PÑ)PÐQZÐ\]Ð_b×_rÑ_rÓ)sÑsôð ��N×Ñ˜U×4Ñ4Ô5Ø‡J�JˆwÑ×#Ñ# EÔ*Ø‡J�JˆuÑ×!Ñ! %Ô(Ø‡J�JˆvÑ×"Ñ" 5Ô)ð —)‘)×/Ñ/Ó1€KØ��N× Ñ Ø�A‰×$Ñ$Ó&¬×)>Ñ)>×)PÑ)PÐQ[Ð]^Ð`c×`sÑ`sÓ)tÑtôð ��N× Ñ Ø�A‰×$Ñ$Ó&Ü
×
Ñ
×
1Ñ
1°)¸YÈ×H[ÑH[Ó
\ñ	]ôð
 ��N×Ñ˜U×4Ñ4Ô5ð —(‘(×.Ñ.Ó0€KÜ�<Ö ˆØ�A‰× Ñ  ×!8Ñ!8Ö9ñ !ö Ü�Š�
ä�wŠw‹yÐùòG	 "Zùò$ 8ùòL Oùò Qùòr .bs#   ÅAAÇ9AAÖAAØAA ê7AA%c                 óÆ  • [        5       nUSL a  [        R                  " 5         SnSn[        [	        U 5      5      R                  S5      (       aL  U n	U	R                  n U	R                  nU	R                  nU	R                  n[        U	SS5      n[        U	SS5      n[        U [        R                  5      (       a  [        U 5      S:”  d  [        U [        5      (       a  [!        S5      e[        UR"                  5      S:X  a  [!        S	5      e[        U[$        R&                  5      (       a$  Uc  [        UR(                  5      nUR                  nUcL  [        R*                  " [-        [        U5      5       V
s/ s H  n
[.        S
   [        U
5      -  PM     sn
5      n[1        U[        U5      5      nSn[-        US-
  SS5      n[        R2                  " [        R4                  " U5      * 5      n/ n/ n/ n/ n/ n/ n/ n/ n/ n/ nXR7                  5       -   n[-        US-   5       V
s/ s H  n
SPM     nn
[        R8                  " 5       R;                  SX¼-  S-   5        U[        U5      :X  a  UnOUS-
  n[-        U5       GHK  n
XU
      nUU-  nUS:¼  ae  UR=                  XÚ   5        UR=                  U5        Ub,  UR=                  XŽU
      5        UR=                  X~U
      5        UR=                  U5        OdUR=                  XÚ   5        UR=                  U5        Ub,  UR=                  XŽU
      5        UR=                  X~U
      5        UR=                  U5        UU:w  d	  U
S-   U:  a*  [        R>                  " UU/XÚ   S-
  S-
  XÚ   S-   /SSSSS9  Uc  X>U
      UXÚ   '   GM*  [A        X.U
      S5      S-   X>U
      -   UXÚ   '   GMN     U[        U5      :  a‘  [        U5      U-
  S-    S3US'   U U-
  nUS:  a8  UR=                  S5        UR=                  U* 5        UR=                  UU-   5        O7UR=                  S5        UR=                  U* 5        UR=                  UU-   5        U[        [        R*                  " U5      [        R*                  " U5      -   5      -   U-   [        [        R*                  " U5      [        R*                  " U5      -   5      -   n[        RB                  " U5      [        R0                  " U5      -
  n[        R*                  " U V s/ s H  n U S:  a  SU-  OSPM     sn 5      n![        RD                  " U[        R*                  " U5      U!-   SU-  -   [        R*                  " U5      SU-  -
  URF                  SS9  [        R*                  " U V s/ s H  n U * S:  a  SU-  OSPM     sn 5      n![        RD                  " U[        R*                  " U5      U!-   SU-  -
  [        R*                  " U5      SU-  -   URH                  SS9  Sn"Sn#[        RJ                  " 5       S   [        RJ                  " 5       S   -
  n$[        R8                  " 5       n%[        RL                  " 5       n&U&RO                  5       RQ                  U%RR                  RU                  5       5      n'U'RV                  n(U$U(-  n)U)U"-  n*U%RX                  R[                  5       n+[-        [        U5      5       GHx  n
UU
   n,[        R\                  " Xú   UU
   [C        U,U*-
  S 5      S[1        U,U*5      URF                  U#U#S!9n-Ube  U
[        U5      :  aV  [        R^                  " Xú   UU
   -   UU
   [        R*                  " UU
   UU
   -
  /UU
   UU
   -
  //5      UR`                  S"9  [        Rb                  " Xú   SU,-  -   UU
   [A        UU
   S#5      S$S$URd                  S%S&9n.U.RO                  U+S'9n/U-RO                  U+S'9n0U/RV                  U0RV                  :”  d  GM)  U.Rg                  5         [        Rb                  " Xú   S(U)-  -   U,-   UU
   [A        UU
   S#5      S)S$URF                  S%S&9n.GM{     [-        [        U5      5       GH  n
UU
   n,[        R\                  " UU
   UU
   [C        U,* U*-
  S 5      * S[1        U,* U*5      URH                  U#U#S!9n-Ubf  U
[        U5      :  aW  [        R^                  " UU
   UU
   -   UU
   [        R*                  " UU
   UU
   -
  /UU
   UU
   -
  //5      URh                  S"9  [        Rb                  " UU
   SU,-  -   UU
   [A        UU
   S#5      S$S$URd                  S%S&9n.U.RO                  U+S'9n/U-RO                  U+S'9n0U/RV                  U0RV                  :”  d  GM/  U.Rg                  5         [        Rb                  " UU
   S(U)-  -
  U,-   UU
   [A        UU
   S#5      S*S$URH                  S%S&9n.GM‚     [        Rj                  " [        [-        U5      5      S-  USS USS  V1s/ s H  n1U1Rm                  S+5      S   PM     sn1-   S,S-9  [-        U5       H$  n
[        Rn                  " X¦Rp                  SS.SS/9  M&     [        Rr                  " U SSU-  URt                  SSSS9  XR7                  5       -   n2[        Rr                  " U2SSURt                  SSSS9  [        RL                  " 5       Rv                  Ry                  S05        [        RL                  " 5       Rz                  Ry                  S15        [        RL                  " 5       R|                  S*   R                  S5        [        RL                  " 5       R|                  S2   R                  S5        [        RL                  " 5       R|                  S)   R                  S5        U&R�                  S,S39  U&Rƒ                  5       u  n3n4U&R…                  5       n5U5R‡                  U3U45        U5R‰                  X S4-   /5        U5R‹                  S5S6[A        U S5      -   S7-   /S%S)S89  U5R|                  S*   R                  S5        U5R|                  S2   R                  S5        U5R|                  S)   R                  S5        U5R…                  5       n6U6R‡                  U3U45        U6R‰                  XR7                  5       -   XR7                  5       -   S4-   /5        U6R‹                  S9S:[A        U2S5      -   S7-   /S%S)S89  U6Rv                  R�                  5       n7U7S   R�                  U7S   R‘                  5       [’        R”                  R—                  S;SU%RR                  5      -   5        U7S   R�                  U7S   R‘                  5       [’        R”                  R—                  S<SU%RR                  5      -   5        U7S   R™                  URš                  5        U6R|                  S*   R                  S5        U6R|                  S2   R                  S5        U6R|                  S)   R                  S5        U5Rv                  R�                  5       n7U7S   R�                  U7S   R‘                  5       [’        R”                  R—                  S=SU%RR                  5      -   5        U7S   R�                  U7S   R‘                  5       [’        R”                  R—                  S>S?U%RR                  5      -   5        U7S   R™                  URš                  5        U&Rz                  R�                  5       n7[-        U5       H!  n
U7U
   R™                  URš                  5        M#     U(       a  [        Rœ                  " 5         g[        R8                  " 5       $ s  sn
f s  sn
f s  sn f s  sn f s  sn1f )@a€  Plots an explanation of a single prediction as a waterfall plot.

The SHAP value of a feature represents the impact of the evidence provided by that feature on the model's
output. The waterfall plot is designed to visually display how the SHAP values (evidence) of each feature
move the model output from our prior expectation under the background data distribution, to the final model
prediction given the evidence of all the features. Features are sorted by the magnitude of their SHAP values
with the smallest magnitude features grouped together at the bottom of the plot when the number of features
in the models exceeds the max_display parameter.

Parameters
----------
expected_value : float
    This is the reference value that the feature contributions start from. For SHAP values it should
    be the value of explainer.expected_value.

shap_values : numpy.array
    One dimensional array of SHAP values.

features : numpy.array
    One dimensional array of feature values. This provides the values of all the
    features, and should be the same shape as the shap_values argument.

feature_names : list
    List of feature names (# features).

max_display : int
    The maximum number of features to display (default is 10).

show : bool
    Whether matplotlib.pyplot.show() is called before returning. Setting this to False allows the plot
    to be customized further after it has been created.

FNzExplanation'>r
   r   r   aE  waterfall_plot requires a scalar expected_value of the model output as the first parameter, but you have passed an array as the first parameter! Try shap.waterfall_plot(explainer.expected_value[0], shap_values[0], X[0]) or for multi-output models try shap.waterfall_plot(explainer.expected_value[0], shap_values[0][0], X[0]).r   zhThe waterfall_plot can currently only plot a single explanation but a matrix of explanations was passed!r   r   r   r   r   r   r   r   r   z#bbbbbbr   r   r   r   r   r   r   r   r    r#   r$   r%   g�íµ ÷Æ°>r&   r*   r-   r.   r/   r0   r4   r6   r!   r7   r9   r:   r;   r<   r>   rA   rB   rC   rD   r8   rF   rG   rH   rI   rK   rL   rM   rN   rO   rP   rQ   )Or   rR   rS   rg   rr   ÚendswithÚexpected_valuer_   r\   r]   r^   rT   rd   ÚndarrayrW   rb   Ú	ExceptionrV   r`   ra   rc   re   rf   r   rh   ri   rj   rk   rl   rm   rn   ro   r   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   r(   r~   r   r€   r�   r‚   rƒ   r„   r…   r†   rˆ   r‰   rŠ   r‹   rŒ   rp   r�   rŽ   r�   r�   r‘   r’   r“   r”   r•   r–   r—   r˜   r™   rš   r›   rœ   r�   rž   rŸ   r    )8rØ   r¡   r¦   r]   r¢   r    r£   r   r
   Úshap_expr§   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Á   rÂ   rÃ   rÄ   r(   rÅ   rÆ   r5   rÇ   rÈ   rÉ   rÊ   rË   rÍ   rÎ   rÏ   rÐ   rÑ   rÒ   rÓ   s8                                                           rÔ   Úwaterfall_legacyrÜ   x  sŒ  € ôD ‹K€Eàˆu‚}Ü�ŠŒ
ð €LØ€LÜ
Œ4�ÓÓ ×)Ñ)¨/×:Ñ:Ø!ˆØ!×0Ñ0ˆØ—o‘oˆØ—=‘=ˆØ ×.Ñ.ˆÜ˜x¨¸Ó>ˆÜ˜x¨¸Ó>ˆô 	�>¤2§:¡:×.Ñ.´3°~Ó3FÈÓ3JÌzÐZhÔjn×OoÑOoÜðYó
ð 	
ô ˆ;×ÑÓ Ó"ÜØvó
ð 	
ô
 �(œBŸI™I×&Ñ&ØÑ Ü  §¡Ó0ˆMØ—?‘?ˆð ÑÜŸšÄeÌCÐP[ÓL\ÔF]Ó!^ÒF]À¤&¨Ñ"3´c¸!³fÔ"<ÑF]Ñ!^Ó_ˆô �{¤C¨Ó$4Ó5€LØ€JÜ
�˜qÑ  " bÓ
)€CÜ�JŠJœŸš˜{Ó+Ð+Ó,€EØ€IØ€HØ€JØ€GØ€HØ€IØ€HØ€JØ€GØ€HØ
Ÿ?™?Ó,Ñ
,€CÜ$ \°AÑ%5Ô6Ó7Ò6˜!“2Ñ6€KÐ7ô ‡G‚GƒI×Ñ˜a Ñ!:¸SÑ!@ÔAð ”s˜;Ó'Ó'Ø%‰à%¨Ñ)ˆô �>×"ˆØ ™8Ñ$ˆØˆt‰ˆØ�1‹9Ø�O‰O˜C™FÔ#Ø×Ñ˜dÔ#ØÑ'Ø—‘˜|°!©HÑ5Ô6Ø—‘ °1©XÑ 6Ô7Ø×Ñ˜SÕ!à�O‰O˜C™FÔ#Ø×Ñ˜dÔ#ØÑ'Ø—‘˜|°!©HÑ5Ô6Ø—‘ °1©XÑ 6Ô7Ø×Ñ˜SÔ!Ø˜\Ó)¨Q°©U°^Ó-CÜ�HŠHØ�c�
˜S™V a™Z¨#Ñ-¨s©v¸©|Ð<ÀIÐY]ÐilÐuwòð ÑØ"/°a±Ñ"9ˆK˜™Ôä".¨x¸a¹Ñ/AÀ8Ó"LÈuÑ"TÐWdÐklÑemÑWnÑ"nˆK˜™Ôñ1 #ð6 ”c˜+Ó&Ó&Ü Ó,¨|Ñ;¸aÑ?Ð@ÀÐPˆ�A‰Ø)¨CÑ/ÐØ˜aÓØ�O‰O˜AÔØ×ÑÐ/Ð/Ô0Ø×Ñ˜SÐ#3Ñ3Õ4à�O‰O˜AÔØ×ÑÐ/Ð/Ô0Ø×Ñ˜SÐ#3Ñ3Ô4ð 	Ü
Œr�xŠx˜	Ó"¤R§X¢X¨jÓ%9Ñ9Ó
:ñ	;à
ñ	ô Œr�xŠx˜	Ó"¤R§X¢X¨jÓ%9Ñ9Ó
:ñ	;ð ô �FŠF�6‹NœRŸVšV F›^Ñ+€Eô —H’HÁ:ÓNÂ:¸a¨Q°«U˜c Ešk¸Ò9Á:ÑNÓO€MÜ‡H‚HØÜ
�Š�Ó˜}Ñ,¨t°e©|Ñ;Ü�XŠX�iÓ  4¨%¡<Ñ/Ø×*Ñ*Øòô —H’HÁZÓPÂZÀ¨q¨b°1«f˜d Ušl¸!Ò;ÁZÑPÓQ€MÜ‡H‚HØÜ
�Š�Ó˜}Ñ,¨t°e©|Ñ;Ü�XŠX�iÓ  4¨%¡<Ñ/Ø×*Ñ*Øòð €KØ€IÜ�8Š8‹:�a‰=œ3Ÿ8š8›: a™=Ñ(€DÜ
�'Š'‹)€CÜ	�Š‹€BØ×ÑÓ!×-Ñ-¨c×.AÑ.A×.JÑ.JÓ.LÓM€DØ�J‰J€EØ˜E‘\€NØ Ñ,€IØ�z‰z×&Ñ&Ó(€Hô ”3�x“=×!ˆØ˜!‰}ˆÜ—I’IØ‰LØ�Q‰KÜ��yÑ  (Ó+ØÜ˜D )Ó,Ø×.Ñ.ØØ ñ	
ˆ	ð Ñ 1¤s¨7£|Ó#3Ü�LŠLØ‘˜z¨!™}Ñ,Ø˜‘Ü—X’X 
¨1¡°¸±
Ñ :Ð;¸hÀq¹kÈJÐWXÉMÑ>YÐ=ZÐ[Ó\Ø×5Ñ5ò	ô —(’(Ø‰L˜3 ™:Ñ%Ø�Q‰KÜ˜ A™¨	Ó2Ø (Ø&Ø×"Ñ"Øñ
ˆð ×-Ñ-°xÐ-Ð@ˆ	Ø×0Ñ0¸(Ð0ÐCˆ
ð �?‰?˜Z×-Ñ-Ö-Ø�N‰NÔä—h’hØ‘ ¨.Ñ8Ñ8¸4Ñ?Ø˜‘Ü˜Z¨™]¨IÓ6Ø$*Ø"*Ø×2Ñ2Øñ‹GñK "ô` ”3�x“=×!ˆØ˜!‰}ˆä—I’IØ�a‰LØ�Q‰KÜ�$�˜Ñ" HÓ-Ð-ØÜ˜T˜E 9Ó-Ø×.Ñ.ØØ ñ	
ˆ	ð Ñ 1¤s¨7£|Ó#3Ü�LŠLØ˜!‘˜z¨!™}Ñ,Ø˜‘Ü—X’X 
¨1¡°¸±
Ñ :Ð;¸hÀq¹kÈJÐWXÉMÑ>YÐ=ZÐ[Ó\Ø×5Ñ5ò	ô —(’(Ø�a‰L˜3 ™:Ñ%Ø�Q‰KÜ˜ A™¨	Ó2Ø (Ø&Ø×"Ñ"Øñ
ˆð ×-Ñ-°xÐ-Ð@ˆ	Ø×0Ñ0¸(Ð0ÐCˆ
ð �?‰?˜Z×-Ñ-Ö-Ø�N‰NÔä—h’hØ˜!‘ ¨.Ñ8Ñ8¸4Ñ?Ø˜‘Ü˜Z¨™]¨IÓ6Ø$+Ø"*Ø×2Ñ2Øñ‹GñM "ôb ‡J‚JÜŒU�<Ó Ó! AÑ%Ø�C�RÐ¸kÈ#È2Ñ>NÓOÒ>N°U˜EŸK™K¨Ó,¨RÔ0Ñ>NÑOÑOØòô �<Ö ˆÜ�Š�A×/Ñ/°CÀÈrÔRñ !ô ‡K‚K�  1 |Ñ#3¸5×;MÑ;MÐY]ÐilÐuwÒxØ	Ÿ/™/Ó+Ñ	+€BÜ‡K‚K��A�q × 2Ñ 2¸dÈcÐZ\Ò]ô ‡G‚GƒI‡O�O×&Ñ& xÔ0Ü‡G‚GƒI‡O�O×&Ñ& vÔ.Ü‡G‚GƒI×Ñ�WÑ×)Ñ)¨%Ô0Ü‡G‚GƒI×Ñ�UÑ×'Ñ'¨Ô.Ü‡G‚GƒI×Ñ�VÑ×(Ñ(¨Ô/Ø‡N�N˜R€NÑ ð —‘“�J€Dˆ$Ø
�(‰(‹*€CØ‡L�L��tÔØ‡N�NØ	¨$Ñ.Ð/ôð ×ÑØ	˜¤<°ÀÓ#IÑIÈCÑOÐPÐ[]Ðbhð ñ ð ‡J�JˆwÑ×#Ñ# EÔ*Ø‡J�JˆuÑ×!Ñ! %Ô(Ø‡J�JˆvÑ×"Ñ" 5Ô)ð �)‰)‹+€CØ‡L�L��tÔà‡N�NàŸ_™_Ó.Ñ.ØŸ_™_Ó.Ñ.°Ñ5ð	
ôð ×Ñ˜ 6¬L¸¸XÓ,FÑ#FÈÑ#LÐMÐXZÐ_eÐÑfØ—)‘)×/Ñ/Ó1€KØ��N× Ñ Ø�A‰×$Ñ$Ó&¬×)>Ñ)>×)PÑ)PÐQ[Ð]^Ð`c×`sÑ`sÓ)tÑtôð ��N× Ñ Ø�A‰×$Ñ$Ó&¬×)>Ñ)>×)PÑ)PÐQZÐ\]Ð_b×_rÑ_rÓ)sÑsôð ��N×Ñ˜U×4Ñ4Ô5Ø‡J�JˆwÑ×#Ñ# EÔ*Ø‡J�JˆuÑ×!Ñ! %Ô(Ø‡J�JˆvÑ×"Ñ" 5Ô)ð —)‘)×/Ñ/Ó1€KØ��N× Ñ Ø�A‰×$Ñ$Ó&¬×)>Ñ)>×)PÑ)PÐQ[Ð]^Ð`c×`sÑ`sÓ)tÑtôð ��N× Ñ Ø�A‰×$Ñ$Ó&Ü
×
Ñ
×
1Ñ
1°)¸YÈ×H[ÑH[Ó
\ñ	]ôð ��N×Ñ˜U×4Ñ4Ô5ð —(‘(×.Ñ.Ó0€KÜ�<Ö ˆØ�A‰× Ñ  ×!8Ñ!8Ö9ñ !ö Ü�Š�
ä�wŠw‹yÐùò} "_ùò$ 8ùòx Oùò Qùòr Ps   Å;
È)Ô'Ö2é
)é
   T)NNNrÝ   T)r›   Úmatplotlib.pyplotÚpyplotrR   Únumpyrd   Úpandasr`   r   r   Úutilsr   Ú_labelsr   Ú_styler   rÕ   rÜ   © ó    rÔ   Ú<module>rç      s*   ðÛ Ý Û Û å Ý  Ý Ý ôeõPiræ   