API utils

neptunecontrib.api.utils.concat_experiments_on_channel(experiments, channel_name)[source]

Combines channel values from experiments into one dataframe.

This function helps to compare channel values from a list of experiments by combining them in a dataframe. E.g: Say we want to extract the log_loss channel values for a list of experiments. The resulting dataframe will have [‘id’,’x_log_loss’,’y_log_loss’] columns.

Parameters:
  • experiments (list) – list of neptune.experiments.Experiment objects.
  • channel_name (str) – name of the channel for which we want to extract values.
Returns:

Dataframe of [‘id’,’x_CHANNEL_NAME’,’y_CHANNEL_NAME’] values concatenated from a list of experiments.

Return type:

pandas.DataFrame

Examples

Instantiate a session:

from neptune.sessions import Session
session = Session()

Fetch a project and a list of experiments:

project = session.get_projects('neptune-ml')['neptune-ml/Salt-Detection']
experiments = project.get_experiments(state=['aborted'], owner=['neyo'], min_running_time=100000)

Construct a channel value dataframe:

from neptunecontrib.api.utils import concat_experiments_on_channel
compare_df = concat_experiments_on_channel(experiments,'unet_0 epoch_val iout loss')

Note

If an experiment in the list of experiments does not contain the channel with a specified channel_name it will be omitted.

neptunecontrib.api.utils.extract_project_progress_info(leadearboard, metric_colname, time_colname='finished')[source]

Extracts the project progress information from the experiment view.

This function takes the experiment view (leaderboard) and extracts the information that is important for analysing the project progress. It creates additional columns metric (actual experiment metric), metric_best (best metric score to date)), running_time_day (total amount of experiment running time for a given day in hours), ‘experiment_count_day’ (total number of experiments ran in a given day).

This function is usually used with the plot_project_progress from neptunecontrib.viz.projects.

Parameters:
  • leadearboard (pandas.DataFrame) – Dataframe containing the experiment view of the project. It can be extracted via project.get_leaderboard().
  • metric_colname (str) – name of the column containing the metric of interest.
  • time_colname (str) – name of the column containing the timestamp. It can be either finished or created. Default is ‘finished’.
Returns:

Dataframe of [‘id’, ‘metric’, ‘metric_best’, ‘running_time’, ‘running_time_day’, ‘experiment_count_day’, ‘owner’, ‘tags’, ‘timestamp’, ‘timestamp_day’] columns.

Return type:

pandas.DataFrame

Examples

Instantiate a session:

from neptune.sessions import Session
session = Session()

Fetch a project and the experiment view of that project:

project = session.get_projects('neptune-ml')['neptune-ml/Salt-Detection']
leaderboard = project.get_leaderboard()

Create a progress info dataframe:

from neptunecontrib.api.utils import extract_project_progress_info
progress_df = extract_project_progress_info(leadearboard,
                                            metric_colname='channel_IOUT',
                                            time_colname='finished')
neptunecontrib.api.utils.get_channel_columns(columns)[source]

Filters leaderboard columns to get the channel column names.

Parameters:columns (iterable) – Iterable of leaderboard column names.
Returns:A list of channel column names.
Return type:list
neptunecontrib.api.utils.get_filepaths(dirpath='.', extensions=None)[source]

Creates a list of all the files with selected extensions.

Parameters:
  • dirpath (str) – Folder from which all files with given extensions should be added to list.
  • extensions (list(str) or None) – All extensions with which files should be added to the list.
Returns:

A list of filepaths with given extensions that are in the directory or subdirecotries.

Return type:

list

Examples

Initialize Neptune:

import neptune
from neptunecontrib.versioning.data import log_data_version
neptune.init('USER_NAME/PROJECT_NAME')

Create experiment and track all .py files from given directory and subdirs:

with neptune.create_experiment(upload_source_files=get_filepaths(extensions=['.py'])):
    neptune.send_metric('score', 0.97)
neptunecontrib.api.utils.get_parameter_columns(columns)[source]

Filters leaderboard columns to get the parameter column names.

Parameters:columns (iterable) – Iterable of leaderboard column names.
Returns:A list of channel parameter names.
Return type:list
neptunecontrib.api.utils.get_pickled_artifact(experiment, filename)[source]

Downloads pickled artifact object from Neptune and returns a Python object.

Downloads the pickled object from artifacts of given experiment,
loads them and returns a Python object.
Parameters:
  • experiment (neptune.experiments.Experiment) – Neptune experiment.
  • filename (str) – filename under which object was saved in Neptune.

Examples

Initialize Neptune:

import neptune

session = neptune.sessions.Session()
project = session.get_project('USER_NAME/PROJECT_NAME')

Choose Neptune experiment:

experiment = project.get_experiments(id=['PRO-101'])[0]

Get your pickled object from experiment articats:

from neptunecontrib.monitoring.utils import get_artifact

results = get_pickled_artifact(experiment, 'results.pkl')
neptunecontrib.api.utils.get_property_columns(columns)[source]

Filters leaderboard columns to get the property column names.

Parameters:columns (iterable) – Iterable of leaderboard column names.
Returns:A list of channel property names.
Return type:list
neptunecontrib.api.utils.get_system_columns(columns)[source]

Filters leaderboard columns to get the system column names.

Parameters:columns (iterable) – Iterable of leaderboard column names.
Returns:A list of channel system names.
Return type:list
neptunecontrib.api.utils.strip_prefices(columns, prefices)[source]

Filters leaderboard columns to get the system column names.

Parameters:
  • columns (iterable) – Iterable of leaderboard column names.
  • prefices (list) – List of prefices to strip. You can choose one of [‘channel_’, ‘parameter_’, ‘property_’]
Returns:

A list of clean column names.

Return type:

list