
    (^i                        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&                         rd dlmZ d dlmZ  ee      ZdZdZ ed      dddef	 	 	 	 	 	 	 	 	 	 	 dd       ZddZy)    )annotations)experimental_func)
get_logger)Study)BaseErrorEvaluator)BaseImprovementEvaluator)DEFAULT_MIN_N_TRIALS)_get_improvement_info)_get_y_range)_ImprovementInfo)_imports)Axes)pltg?g      ?z3.2.0FNc                ^    t        j                          t        | |||      }t        ||      S )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         x/var/www/html/hubwallet-dev/venv/lib/python3.12/site-packages/optuna/visualization/matplotlib/_terminator_improvement.pyplot_terminator_improvementr      s-    T NN 
4I?[D |44    c           	     8   t        | j                        }t        j                  j	                  d       t        j
                         \  }}|j                  d       |j                  d       |j                  d       t        j                  d      }|dk(  rt        j                  d       |S |j                  | j                  d |dz    | j                  d |dz    d	 |d      t        ||k  rdnd 
       ||kD  r6|j                  | j                  |d  | j                  |d  d	 |d      d       | j                  0|j                  | j                  | j                  d	 |d      d       |j!                          |j#                  t%        | |             |S )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   J   s|   4%%&H IIMM(LLNEArLL./MM'MM*+<< D1}78	GG-\A-.,L1,-1g*2l*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?   r@   )
__future__r   optuna._experimentalr   optuna.loggingr   optuna.study.studyr   optuna.terminatorr   r   'optuna.terminator.improvement.evaluatorr	   ,optuna.visualization._terminator_improvementr
   r   r   3optuna.visualization.matplotlib._matplotlib_importsr   is_successfulr   r   __name__r1   PADDING_RATIO_Yr5   r   r    r   r   <module>rM      s    " 2 % $ 0 6 H N E I H 8HG
X
  7 =A15,,5,5,5 ;,5 /	,5
 ,5 ,5 ,5^+r   