Skip to main content

NeptuneAnalyzer

A class for analyzing Neptune runs and fetching experiment data. Method generated by attrs for class NeptuneAnalyzer.

Static methods

combine_trials

Combine trials into a pd.DataFrame object. Parameters: Returns:

Instance variables

  • api_token: str: Neptune API token, e.g. “your_api_token”.
  • project: str: Neptune project name, e.g. “user_name/project_name”.

Methods

run_context

Context manager to initialize and stop a Neptune run. Parameters: Yields:

clear_cache

Clear the cache for _fetch_neptune_metadata.

best_metrics

Fetch best metrics from Neptune runs. Parameters: Returns:

best_params

Fetch best parameters from Neptune runs. Parameters: Returns:

trial_params

Fetch trial parameters from Neptune runs. Metadata is queried with the below:
  • metadata_tag=trials/trials/0/distributions (Primary)
  • metadata_tag=trials/trials (Fallback)
Parameters: Returns:

get_best_trials

Fetch the best trials from Neptune runs. Parameters: Returns:

get_all_trials

Fetch all trials from Neptune runs. Parameters: Returns:

metrics

List metric names from a Neptune run. Parameters: Returns:

params

List parameter names from a Neptune run. Parameters: Returns:

all_params

List parameter names from a Neptune run. Parameters: Returns:

run_composer

Run portfolio analytics from run_id. New generation logging is supported. Parameters: Returns:

all_combination

Generate combinations of metric and parameter names. Parameters: Returns:

param_combination

Generate permutations of parameter names. Parameters: Returns:

optuna_study

Loads Optuna study from an existing Neptune run. Loading mechanics depend on the study storage type used during the run:
  • If the study used InMemoryStorage, it will be loaded from the logged pickled study object.
  • If the study used database storage, it will be loaded from the logged database URL.
To resume an existing run, you need the run ID. It is stored in the run’s sys/id field. Parameters: Returns:

optuna_trials_dataframe

Export optuna trials as a pandas DataFrame. The DataFrame provides various features to analyze studies. It is also useful to draw a histogram of objective values and to export trials as a CSV file. If there are no trials, an empty pd.DataFrame is returned. Parameters: Returns:

optuna_best_trials

Export optuna best trials as a pandas DataFrame. Parameters: Returns:

stats

Compute statistics from a Neptune run. Parameters: Returns:

plot_pareto_front

Plot pareto front. Parameters: Returns:

plot_contour

Plot the parameter relationship as contour plot in a study. Parameters: Returns:

plot_param_importances

Plot parameter importance.
An importance evaluator object that specifies which algorithm to base the importance assessment on, defaults to FanovaImportanceEvaluator.
Parameters: Returns:

plot_edf

Plot the objective value EDF (empirical distribution function) of a study. Parameters: Returns:

plot_optimization_history

Plot optimization history of all trials in a study. Parameters: Returns:

plot_parallel_coordinate

Plot the high-dimensional parameter relationships in a study. Parameters: Returns:

plot_rank

Plot parameter relations as scatter plots with colors indicating ranks of target value.
Trials missing the specified parameters will not be plotted.
Parameters: Returns:

plot_slice

Plot the parameter relationship as a slice plot in a study. Trials missing the specified parameters will not be plotted.
The slice plot is useful for visualizing the relationship between hyperparameters and the objective function values.It can help you:
  • Identify Parameter Sensitivity: Shows which hyperparameters have a strong influence on performance.
  • Detect Bad Regions: Highlights ranges where performance is consistently poor.
  • Spot Non-linear Patterns: You might notice trends.
  • Debug Optimization: If you see no pattern or strange clumping, it might indicate:
    • A bad search space.
    • Problems with the objective function.
  • Guide Future Searches: Helps you refine the search space for better performance in future runs.
Parameters: Returns:

plot_hypervolume_history

Plot hypervolume history of all trials in a study. This function is only applicable for multi-objective optimization studies. It computes the hypervolume of the Pareto front at each trial and plots the hypervolume history. The hypervolume is a measure of the volume of the dominated region in the objective space, defined by the reference point. The higher the hypervolume, the better the Pareto front.
Study must be multi-objective. For single-objective optimization, please use plot_optimization_history instead.
Parameters: Returns:

plot_timeline

Plot the timeline of a study. Parameters: Returns:

plot_intermediate_values

Plot intermediate values of all trials in a study. Parameters: Returns:

plot_terminator_improvement

Plot the potentials for future objective improvement. This function does not support multi-objective optimization study.
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 True. Note that this function may take some time to compute the improvement potentials. The improvement_evaluator defaults to RegretBoundEvaluator and the error_evaluator to CrossValidationErrorEvaluator.
Parameters: Returns:

plot_params_correlation

Plot parameters correlation matrix. Parameters: Returns:

plot_metrics_correlation

Plot metrics correlation matrix. Parameters: Returns:

plot_metrics

Plot a histogram matrix of metrics for a Neptune run. Parameters: Returns:

plot_params

Plot a scatter matrix of parameters for a Neptune run. Parameters: Returns:

plot_density_heatmap

Plot a density heatmap for a metric and parameter. Parameters: Returns:

plot_density_contour

Plot a density contour for a metric and parameter. Parameters: Returns:

plot_frontier

Plot an efficient frontier.
This function plots the efficient frontier of a study, which is a graphical representation of the trade-off between risk and return. The efficient frontier is a curve that shows the optimal risk-return combinations for a given set of trials. The points on the curve represent the best possible trade-offs between risk and return, while points below the curve are suboptimal:
  • x is generally a risk metric (e.g., volatility), while y is a performance measure (e.g., returns).
  • The risk-adjusted optimized point is calculated as: risk_adj = (returns - risk_free_rate) / risks
Parameters: Returns: