ó
    tñ:iI'  ã            "       óø  • S r SSKrSSKrSSKJr  SSKJrJrJr  SSK	r
SSKJr  SSKJrJr  SSKJr  \r\r\SS	SSS
SSSSSSSSS.S\\\\4   S\\   S\S\\   S\\   S\S\S\S\S\S\\   S\S\S\S \S!\4 S" jj5       r\SSSSSSSS#SS$.	S\\\4   S\S%\\   S&\\   S'\\   S(\\   S)\\   S*\\   S+\S,\S \S!\4S- jj5       r\SSSSS#SS..S\\\4   S\S%\\   S&\\   S\\   S+\S,\S \S!\4S/ jj5       rg)0zPlotting Library.é    N)ÚBytesIO)ÚAnyÚOptionalÚUnioné   )ÚPathLike)ÚBoosterÚ_deprecate_positional_args)ÚXGBModelgš™™™™™É?zFeature importancezImportance scoreÚFeaturesÚ ÚweightTz{v})ÚaxÚheightÚxlimÚylimÚtitleÚxlabelÚylabelÚfmapÚimportance_typeÚmax_num_featuresÚgridÚshow_valuesÚvalues_formatÚboosterr   r   r   r   r   r   r   r   r   r   r   r   r   ÚkwargsÚreturnc          	      óD  •  SSK Jn  [        U [        5      (       a  U R                  5       R                  X˜S9nOH[        U [        5      (       a  U R                  X˜S9nO#[        U [        5      (       a  U nO[        S5      eU(       d  [        S5      eU Vs/ s H
  nUUU   4PM     nnU
b  [        US S9U
* S nO[        US	 S9n[        U6 u  nnUc  UR                  S
S
5      u  nn[        R                  " [        U5      5      nUR                   " UU4SUS.UD6  USL aA  [        UU5       H1  u  nnUR#                  US
-   [%        U5      UR'                  US9SS9  M3     UR)                  U5        UR+                  U5        Ub0  [        U[,        5      (       a  [        U5      S:w  a  [        S5      eOS[/        U5      S-  4nUR1                  U5        Ub0  [        U[,        5      (       a  [        U5      S:w  a  [        S5      eOS[        U5      4nUR3                  U5        Ub  UR5                  U5        Ub  UR7                  U5        Ub  UR9                  U5        UR;                  U5        U$ ! [         a  n[        S5      UeSnAff = fs  snf )aå  Plot importance based on fitted trees.

Parameters
----------
booster :
    Booster or XGBModel instance, or dict taken by Booster.get_fscore()
ax : matplotlib Axes
    Target axes instance. If None, new figure and axes will be created.
grid :
    Turn the axes grids on or off.  Default is True (On).
importance_type :
    How the importance is calculated: either "weight", "gain", or "cover"

    * "weight" is the number of times a feature appears in a tree
    * "gain" is the average gain of splits which use the feature
    * "cover" is the average coverage of splits which use the feature
      where coverage is defined as the number of samples affected by the split
max_num_features :
    Maximum number of top features displayed on plot. If None, all features will be
    displayed.
height :
    Bar height, passed to ax.barh()
xlim :
    Tuple passed to axes.xlim()
ylim :
    Tuple passed to axes.ylim()
title :
    Axes title. To disable, pass None.
xlabel :
    X axis title label. To disable, pass None.
ylabel :
    Y axis title label. To disable, pass None.
fmap :
    The name of feature map file.
show_values :
    Show values on plot. To disable, pass False.
values_format :
    Format string for values. "v" will be replaced by the value of the feature
    importance.  e.g. Pass "{v:.2f}" in order to limit the number of digits after
    the decimal point to two, for each value printed on the graph.
kwargs :
    Other keywords passed to ax.barh()

Returns
-------
ax : matplotlib Axes
r   Nz.You must install matplotlib to plot importance)r   r   z/tree must be Booster, XGBModel or dict instancez_Booster.get_score() results in empty.  This maybe caused by having all trees as decision dumps.c                 ó   • U S   $ ©Nr   © ©Ú_xs    ÚS/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/xgboost/plotting.pyÚ<lambda>Ú!plot_importance.<locals>.<lambda>n   ó   € ¨r°!ªuó    )Úkeyc                 ó   • U S   $ r!   r"   r#   s    r%   r&   r'   p   r(   r)   r   Úcenter)Úalignr   T)Úv)Úvaé   z"xlim must be a tuple of 2 elementsgš™™™™™ñ?z"ylim must be a tuple of 2 elementséÿÿÿÿ)Úmatplotlib.pyplotÚpyplotÚImportErrorÚ
isinstancer   Úget_boosterÚ	get_scorer	   ÚdictÚ
ValueErrorÚsortedÚzipÚsubplotsÚnpÚarangeÚlenÚbarhÚtextÚfloatÚformatÚ
set_yticksÚset_yticklabelsÚtupleÚmaxÚset_xlimÚset_ylimÚ	set_titleÚ
set_xlabelÚ
set_ylabelr   )r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   ÚpltÚeÚ
importanceÚkÚtuplesÚlabelsÚvaluesÚ_ÚylocsÚxÚys                             r%   Úplot_importancerX      s™  € ðDSÝ'ô �'œ8×$Ñ$Ø×(Ñ(Ó*×4Ñ4Ø+ð 5ð 
‰
ô 
�GœW×	%Ñ	%Ø×&Ñ&°Ð&ÐR‰
Ü	�GœT×	"Ñ	"Ø‰
äÐJÓKÐKæÜðIó
ð 	
ñ
 +5Ó5ª* Qˆq�*˜Q‘-Ó ©*€FÐ5ØÑ#ä˜Ñ$4Ñ5Ð7GÐ6GÐ6HÐI‰ä˜Ñ$4Ñ5ˆÜ˜&�\�N€FˆFà	�zØ—‘˜Q Ó"‰ˆˆ2ä�IŠI”c˜&“kÓ"€EØ‡G‚GˆE�6ÐC °&ÑC¸FÒCà�dÒÜ˜ Ö&‰DˆAˆqØ�G‰G�A˜‘Eœ5 ›8 ]×%9Ñ%9¸AÐ%9Ð%>À8ˆGÓLñ 'ð ‡M�M�%ÔØ×Ñ�vÔàÑÜ˜$¤×&Ñ&¬#¨d«)°q«.ÜÐAÓBÐBð +9ð ”3�v“; Ñ$Ð%ˆØ‡K�K�ÔàÑÜ˜$¤×&Ñ&¬#¨d«)°q«.ÜÐAÓBÐBð +9ð ”C˜“KÐ ˆØ‡K�K�ÔàÑØ
�‰�UÔØÑØ
�‰�fÔØÑØ
�‰�fÔØ‡G�GˆD„MØ€Iøô} ó SÜÐJÓKÐQRÐRûðSüò( 6s   ‚I? ÂJÉ?
JÊ	JÊJF)	r   Ú	num_treesÚrankdirÚ	yes_colorÚno_colorÚcondition_node_paramsÚleaf_node_paramsÚ
with_statsÚtree_idxrY   rZ   r[   r\   r]   r^   r_   r`   c       	         ó¶  •  SSK Jn  [        U [        5      (       a  U R                  5       n Sn0 nU
R                  5        H
  u  nnUXï'   M     Ub  0 U
S'   X:S   S'   UR                  5        H)  u  nnU
R                  SS5      b	  UU
S   U'   O0 U
S'   X¯	 M+     Uc  Ub  0 U
S'   Ub  XJS   S	'   Ub  XZS   S
'   Ub  XjS'   Ub  XzS'   U
(       a  US-  nU[        R                  " U
5      -  nUb0  [        R                  " S[        5        U	SU4;  a  [        S5      eUn	U R                  XUS9U	   nU" U5      nU$ ! [         a  n[        S5      UeSnAff = f)aó  Convert specified tree to graphviz instance. IPython can automatically plot
the returned graphviz instance. Otherwise, you should call .render() method
of the returned graphviz instance.

Parameters
----------
booster :
    Booster or XGBModel instance
fmap :
   The name of feature map file
num_trees :

    .. deprecated:: 3.0

    Specify the ordinal number of target tree

rankdir :
    Passed to graphviz via graph_attr
yes_color :
    Edge color when meets the node condition.
no_color :
    Edge color when doesn't meet the node condition.
condition_node_params :
    Condition node configuration for for graphviz.  Example:

    .. code-block:: python

        {'shape': 'box',
         'style': 'filled,rounded',
         'fillcolor': '#78bceb'}

leaf_node_params :
    Leaf node configuration for graphviz. Example:

    .. code-block:: python

        {'shape': 'box',
         'style': 'filled',
         'fillcolor': '#e48038'}

with_stats :

    .. versionadded:: 3.0

    Controls whether the split statistics should be included.

tree_idx :

    .. versionadded:: 3.0

    Specify the ordinal index of target tree.

kwargs :
    Other keywords passed to graphviz graph_attr, e.g. ``graph [ {key} = {value} ]``

Returns
-------
graph: graphviz.Source

r   )ÚSourcez&You must install graphviz to plot treeNÚdotÚgraph_attrsrZ   Úedger[   r\   r]   r^   Ú:zAThe `num_trees` parameter is deprecated, use `tree_idx` insetad. zDBoth `num_trees` and `tree_idx` are used, prefer `tree_idx` instead.)r   Údump_formatr_   )Úgraphvizrb   r4   r5   r   r6   ÚitemsÚgetÚjsonÚdumpsÚwarningsÚwarnÚFutureWarningr9   Úget_dump)r   r   rY   rZ   r[   r\   r]   r^   r_   r`   r   rb   rN   Ú
parametersÚextrar*   ÚvalueÚtreeÚgs                      r%   Úto_graphvizrv   ˜   s·  € ðVKÝ#ô �'œ8×$Ñ$Ø×%Ñ%Ó'ˆð €JØ€EØ—l‘l–n‰
ˆˆUØˆ‹
ñ %ð ÑØ "ˆˆ}ÑØ+2ˆ}Ñ˜iÑ(Ø—k‘k–m‰
ˆˆUØ�:‰:�m TÓ*Ñ6Ø).ˆF�=Ñ! #Ò&à$&ˆF�=Ñ!ØŠKñ $ð Ñ Ñ 4Øˆˆv‰ØÑØ&/ˆv‰�{Ñ#ØÑØ%-ˆv‰�zÑ"àÑ(Ø*?Ð&Ñ'ØÑ#Ø%5Ð!Ñ"æØ�cÑˆ
Ø”d—j’j Ó(Ñ(ˆ
àÑÜ�ŠØOÜô	
ð ˜A˜y˜>Ó)ÜØVóð ð ˆà×Ñ È*ÐÐUØñ€Dñ 	ˆt‹€AØ€Høôi ó KÜÐBÓCÈÐJûðKús   ‚D= Ä=
EÅEÅE)r   rY   rZ   r   r_   r`   c          	      ó†  •  SSK Jn  SSK Jn	  Uc  U	R	                  SS5      u  p´[        U 4UUUUUS.UD6n[        5       nUR                  UR                  SS	95        UR                  S5        UR                  U5      nUR                  U5        UR                  S
5        U$ ! [         a  n
[        S5      U
eSn
A
ff = f)aV  Plot specified tree.

Parameters
----------
booster :
    Booster or XGBModel instance
fmap: str (optional)
   The name of feature map file
num_trees :

    .. deprecated:: 3.0

rankdir : str, default "TB"
    Passed to graphviz via graph_attr
ax : matplotlib Axes, default None
    Target axes instance. If None, new figure and axes will be created.

with_stats :

    .. versionadded:: 3.0

    See :py:func:`to_graphviz`.

tree_idx :

    .. versionadded:: 3.0

    See :py:func:`to_graphviz`.

kwargs :
    Other keywords passed to :py:func:`to_graphviz`

Returns
-------
ax : matplotlib Axes

r   )Úimage)r3   z(You must install matplotlib to plot treeNr   )r   rY   rZ   r_   r`   Úpng)rC   Úoff)Ú
matplotlibrx   r3   r4   r<   rv   r   ÚwriteÚpipeÚseekÚimreadÚimshowÚaxis)r   r   rY   rZ   r   r_   r`   r   rx   rM   rN   rT   ru   ÚsÚimgs                  r%   Ú	plot_treer„     sÈ   € ðbMÝ$Ý,ð 
�zØ—‘˜Q Ó"‰ˆäØð	àØØØØñ	ð ñ	€Aô 	‹	€AØ‡G�GˆA�F‰F˜%ˆFÐ Ô!Ø‡F�Fˆ1„IØ
�,‰,�q‹/€Cà‡I�Iˆc„NØ‡G�GˆE„NØ€Iøô/ ó MÜÐDÓEÈ1ÐLûðMús   ‚B% Â%
C Â/B;Â;C )Ú__doc__rk   rm   Úior   Útypingr   r   r   Únumpyr=   Ú_typingr   Úcorer	   r
   Úsklearnr   ÚAxesÚGraphvizSourcer8   rB   rF   ÚstrÚintÚboolrX   rv   r„   r"   r)   r%   Ú<module>r‘      s²  ðñ Û Û Ý ß 'Ñ 'ã å ß 5Ý à
€Ø€ð ð ØØ Ø Ø%Ø$ØØØ#Ø&*ØØØòAØ�8˜W dÐ*Ñ+ðAð 	�‰ðAð ð	Að
 �5‰/ðAð �5‰/ðAð ðAð ðAð ðAð ðAð ðAð ˜s‘mðAð ðAð ðAð ðAð  ð!Að" 
ô#Aó ðAðH ð Ø#Ø!Ø#Ø"Ø,0Ø'+ØØò@Ø�7˜HÐ$Ñ%ð@ð ð@ð ˜‰}ð	@ð
 �c‰]ð@ð ˜‰}ð@ð �s‰mð@ð $ D™>ð@ð ˜t‘nð@ð ð@ð ð@ð ð@ð ô@ó ð@ðF ð Ø#Ø!ØØØòJØ�7˜HÐ$Ñ%ðJð ðJð ˜‰}ð	Jð
 �c‰]ðJð 	�‰ðJð ðJð ðJð ðJð 
ôJó ñJr)   