L iDddlmZddlmZddlmZddlmZddlmZddlZ ddl m Z ddl m Z dd lmZdd lmZdd lmZdd lmZdd lmZej,rddlmZe eZdZGddeZGddeZddd ddZ d ddZy)) annotations)Callable)Sequence)cast) NamedTupleN) get_logger)Study) FrozenTrial) TrialState)_imports)_check_plot_args)_filter_nonfinite)godc"eZdZUded<ded<y) _EDFLineInfostr study_name np.ndarrayy_valuesN__name__ __module__ __qualname____annotations___/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/optuna/visualization/_edf.pyrrs Orrc"eZdZUded<ded<y)_EDFInfozlist[_EDFLineInfo]linesrx_valuesNrrrrr r !s rr Objective Value)target target_namec tjtjdd|iddi}t |||}|j }t |dk(rtjg|Sg}|D]7\}}|jtj|j||d9tj||} | jdd g | S) aPlot the objective value EDF (empirical distribution function) of a study. Note that only the complete trials are considered when plotting the EDF. .. note:: EDF is useful to analyze and improve search spaces. For instance, you can see a practical use case of EDF in the paper `Designing Network Design Spaces `__. .. note:: The plotted EDF assumes that the value of the objective function is in accordance with the uniform distribution over the objective space. Args: study: A target :class:`~optuna.study.Study` object. You can pass multiple studies if you want to compare those EDFs. target: A function to specify the value to display. If it is :obj:`None` and ``study`` is being used for single-objective optimization, the objective values are plotted. .. note:: Specify this argument if ``study`` is being used for multi-objective optimization. target_name: Target's name to display on the axis label. Returns: A :class:`plotly.graph_objects.Figure` object. z$Empirical Distribution Function PlottitlezCumulative Probability)r'xaxisyaxisr)datalayoutr!)xynamemode)range) r checkrLayout _get_edf_infor!lenFigureappendScatterr" update_yaxes) studyr$r%r+info edf_linestracesrrfigures rplot_edfr?&sN NN YY4 $01F  4D I 9~yyb00 F )^ H bjj4==H:T[\]^YYF6 2F q!f% Mrc nt|tr|g}n t|}t|||t |dk(r5t j dtgtjgS|d d}|}g}g}|D]}t|jdtjf|}tj|Dcgc] }|| c}} |j| |j|jt!d|Dr5t j d tgtjgStj"tj$|} tj&tj$|} tj(| | t*} g} t-||D]]\}} tj.| ddtj0f| kd | j2z }| jt5|| _t| | Scc}w) NrzThere are no studies.)r!r"c6tt|jS)N)rfloatvalue)ts r_targetz_get_edf_info.._targetwsqww' 'rF)deepcopystates)r$c38K|]}t|dk(yw)rN)r5).0valuess r z _get_edf_info..s 53v;!  5szThere are no complete trials.)axis)rr)rDr returnrB) isinstancer listr r5_loggerwarningr nparrayr get_trialsr COMPLETEr7rallmin concatenatemaxlinspaceNUM_SAMPLES_X_AXISzipsumnewaxissizer)r:r$r%studiesrE study_names all_valuestrialstrialrJ min_x_value max_x_valuer"edf_line_info_listrrs rr4r4es %'u+Wfk2 7|q/0b288B<88 ~ (K#%J-"   eZ5H5H4J  KTZ f=U6%==>&!5++,- 5* 5578b288B<88&& 34K&& 34K{{; 5GHH!+z:Z F66&BJJ/8;!Dv{{R!!,*x"XYZ ,x @@#>sH2 )r:Study | Sequence[Study]r$%Callable[[FrozenTrial], float] | Noner%rrMz 'go.Figure')Nr#)r:rhr$rir%rrMr ) __future__rcollections.abcrrtypingrrnumpyrRoptuna.loggingr optuna.studyr optuna.trialr r $optuna.visualization._plotly_importsr optuna.visualization._utilsr r is_successfulrrrPr[rr r?r4rrrrts"$$%$#98987 X : z59( < "< 2< <  <B59(/A "/A 1/A/A /Ar