
    -ji                    J   S SK Jr  S SKJr  S SKJr  S SKJr  S SKJ	r	  S SK
Jr  S SK
Jr  S SKJr  \(       a  S S	KJr  S S
KJr  S SKJr  S SK
Jr  \R*                  " 5       (       a  S SKJr  S SKJr  \" \5      rSrSr\" S5      SSS\	4           SS jj5       rSS jrg)    )annotations)TYPE_CHECKING)experimental_func)
get_logger)DEFAULT_MIN_N_TRIALS)_get_improvement_info)_get_y_range)_imports)Study)BaseErrorEvaluator)BaseImprovementEvaluator)_ImprovementInfo)Axes)pltg?g      ?z3.2.0FNc                Z    [         R                  " 5         [        XX#5      n[        XT5      $ )a  Plot the potentials for future objective improvement.

This function visualizes the objective improvement potentials, evaluated
with ``improvement_evaluator``.
It helps to determine whether we should continue the optimization or not.
You can also plot the error evaluated with
``error_evaluator`` if the ``plot_error`` argument is set to :obj:`True`.
Note that this function may take some time to compute
the improvement potentials.

.. seealso::
    Please refer to :func:`optuna.visualization.plot_terminator_improvement`.

Args:
    study:
        A :class:`~optuna.study.Study` object whose trials are plotted for their improvement.
    plot_error:
        A flag to show the error. If it is set to :obj:`True`, errors
        evaluated by ``error_evaluator`` are also plotted as line graph.
        Defaults to :obj:`False`.
    improvement_evaluator:
        An object that evaluates the improvement of the objective function.
        Default to :class:`~optuna.terminator.RegretBoundEvaluator`.
    error_evaluator:
        An object that evaluates the error inherent in the objective function.
        Default to :class:`~optuna.terminator.CrossValidationErrorEvaluator`.
    min_n_trials:
        The minimum number of trials before termination is considered.
        Terminator improvements for trials below this value are
        shown in a lighter color. Defaults to ``20``.

Returns:
    A :class:`matplotlib.axes.Axes` object.
)r
   checkr   _get_improvement_plot)study
plot_errorimprovement_evaluatorerror_evaluatormin_n_trialsinfos         q/home/james-whalen/.local/lib/python3.13/site-packages/optuna/visualization/matplotlib/_terminator_improvement.pyplot_terminator_improvementr      s'    T NN 4I[D 44    c           	     *   [        U R                  5      n[        R                  R	                  S5        [        R
                  " 5       u  p4UR                  S5        UR                  S5        UR                  S5        [        R                  " S5      nUS:X  a  [        R                  S5        U$ UR                  U R                  S US-    U R                  S US-    S	U" S5      [        X!::  a  SOS S
9  X!:  a3  UR                  U R                  US  U R                  US  S	U" S5      SS9  U R                  b-  UR                  U R                  U R                  S	U" S5      SS9  UR!                  5         UR#                  [%        X5      5        U$ )NggplotzTerminator Improvement PlotTrialzTerminator Improvementtab10r   zThere are no complete trials.   o)markercoloralphalabel)r#   r$   r&      Error)lentrial_numbersr   styleusesubplots	set_title
set_xlabel
set_ylabelget_cmap_loggerwarningplotimprovementsALPHAerrorslegendset_ylimr	   )r   r   n_trials_axcmaps         r   r   r   O   st   4%%&H IIMM(LLNEALL./MM'MM*+<< D1}78	GG-\A-.,L1,-1g*2*B&   
|}-lm,q'* 	 	
 {{
KKq' 	 	
 IIKKKT01Ir   )r   r   r   boolr   zBaseImprovementEvaluator | Noner   zBaseErrorEvaluator | Noner   intreturn'Axes')r   r   r   r?   r@   rA   )
__future__r   typingr   optuna._experimentalr   optuna.loggingr   'optuna.terminator.improvement.evaluatorr   ,optuna.visualization._terminator_improvementr   r	   3optuna.visualization.matplotlib._matplotlib_importsr
   optuna.study.studyr   optuna.terminatorr   r   r   is_successfulr   r   __name__r2   PADDING_RATIO_Yr6   r   r    r   r   <module>rO      s    "   2 % H N E H (4:M HG
X
  7 =A15,,5,5,5 ;,5 /	,5
 ,5 ,5 ,5^+r   