APIExperiment

The APIExperiment class is used to access data from the Comet.ml Python API.

You can use an instance of the APIExperiment() class to easily access all of your logged experiment information at Comet.ml, including metrics, parameters, tags, and assets.

Examples:

The following examples assume your COMET_API_KEY is configured as per Python Configuration.

This example shows looking up an experiment by its URL:

```python

from comet_ml.api import API, APIExperiment

(assumes api keys are configured):

api = API() # can also: API(api_key="...")

Get an APIExperiment from the API:

experiment = api.get("cometpublic/comet-notebooks/example 001") ```

You can also make a new experiment using the API:

```python

Make a new APIExperiment (assumes api keys are configured):

experiment = APIExperiment(workspace="my-username", project_name="general") ```

Here is an end-to-end snippet to rename a metric. You can use this basic structure for logging new metrics (after the experiment has completed) such as averages or scaling to a baseline.

```python from comet_ml import API

WORKSPACE = "your-comet-id" PROJECT_NAME = "general" EXP_KEY = "your-experiment-key" OLD_METRIC_NAME = "loss" NEW_METRIC_NAME = "train_loss"

api = API() # can also: API(api_key="...")

experiment = api.get_experiment(WORKSPACE, PROJECT_NAME, EXP_KEY) old_metrics = experiment.get_metrics(OLD_METRIC_NAME)

for old_metric in old_metrics: experiment.log_metric( NEW_METRIC_NAME, old_metric["metricValue"], step=old_metric["step"], timestamp=old_metric["timestamp"], ) ```

For more usage examples, see Comet Python API examples.

APIExperiment.key

Get the experiment key (the unique id).

Example:

```python

api_experiment.key "34637643746374637463476" ```

APIExperiment.name

Get the experiment name.

Example:

```python

api_experiment.name "laughing_toaster_23454" ```

APIExperiment.url

Get the url of the experiment.

Example:

```python

api_experiment.url "https://www.comet.ml/username/34637643746374637463476" ```


APIExperiment.__init__

python __init__(self, *args, **kwargs)

Create a new APIExperiment, or use a previous experiment key to access an existing experiment.

Examples:

```python

Python API to create a new experiment:

(assumes api keys are configured):

experiment = APIExperiment(workspace=WORKSPACE, project_name=PROJECT)

Python API to access an existing experiment:

(assumes api keys are configured):

experiment = APIExperiment(previous_experiment=EXPERIMENT_KEY) ```

Note: api_key may be defined in environment (COMET_API_KEY)

or in a .comet.config file. Additional arguments will be given to API().


APIExperiment.add_tag

python add_tag(self, tag)

Append onto an experiment's list of tags.

Args:

  • tag: a tag (string)

Example:

```python

api_experiment.add_tag("baseline") ```


APIExperiment.add_tags

python add_tags(self, tags)

Append onto an experiment's list of tags.

Args:

  • tags: a list of tags (strings)

Example:

```python

api_experiment.add_tags(["successful", "best"]) ```


APIExperiment.archive

python archive(self)

Archive this experiment.

Example:

```python

api_experiment.archive() ```


python create_symlink(self, project_name)

Create a copy of this experiment in another project in the workspace.

Args:

  • project_name: the name of the project with which to create a symlink to this experiment in.

Example:

```python

api_experiment.create_symlink("my-other-project") ```


APIExperiment.delete_asset

python delete_asset(self, asset_id)

Delete an experiment's asset.

Args:

  • asset_id: the asset id of the asset to delete

APIExperiment.display

python display(self, clear=False, wait=True, new=0, autoraise=True, tab=None)

Show the Comet.ml experiment page in an IFrame in a Jupyter notebook or Jupyter lab, OR open a browser window or tab.

Common Args: - tab: name of the Tab on Experiment View

Note: the Tab name should be one of:

  • "artifacts"
  • "assets"
  • "audio"
  • "charts"
  • "code"
  • "confusion-matrices"
  • "histograms"
  • "images"
  • "installed-packages"
  • "metrics"
  • "notes"
  • "parameters"
  • "system-metrics"
  • "text"

For Jupyter environments:

Args:

  • clear: to clear the output area, use clear=True
  • wait: to wait for the next displayed item, use wait=True (cuts down on flashing)

For non-Jupyter environments:

Args:

  • new: open a new browser window if new=1, otherwise re-use existing window/tab
  • autoraise: make the browser tab/window active

APIExperiment.display_project

python display_project(self, view_id=None, clear=False, wait=True, new=0, autoraise=True)

Show the Comet.ml project page in an IFrame in a Jupyter notebook or Jupyter lab, OR open a browser window or tab.

Common Args: - view_id: (optional, string) the id of the view to show

For Jupyter environments:

Args:

  • clear: to clear the output area, use clear=True
  • wait: to wait for the next displayed item, use wait=True (cuts down on flashing)

For non-Jupyter environments:

Args:

  • new: open a new browser window if new=1, otherwise re-use existing window/tab
  • autoraise: make the browser tab/window active

APIExperiment.download_model

python download_model(self, name, output_path="./", expand=True)

Download and save all files from the model.

Args:

  • model_name: str, the name of the model
  • output: str, the output directory; defaults to current directory
  • expand: if True, the downloaded zipfile is unzipped; if False, then the zipfile is copied to the output_path

APIExperiment.download_tensorflow_folder

python download_tensorflow_folder(self, output_path="./", overwrite=False)

Download all files logged with Experiment.log_tensorflow_folder(FOLDER).

Args:

  • output_path: (str) where to download the files
  • overwrite: (bool) if True, then overwrite any file that exists

Example:

```python

experiment = comet_ml.Experiment() experiment.log_tensorboard_folder("logs") api = comet_ml.API() api_experiment = api.get_experiment_by_id(experiment.id) api_experiment.download_tensorflow_folder() ```


APIExperiment.end

python end(self)

Method called at end of experiment.


APIExperiment.get_additional_system_info

python get_additional_system_info(self)

Get the associated additional system info for this experiment.

Example:

```python

api_experiment.get_additional_system_info() [] ```


APIExperiment.get_asset

python get_asset(self, asset_id, return_type="binary", stream=False)

Get an asset, given the asset_id.

Args:

  • asset_id: (str) the asset ID
  • return_type: (str) the type of object returned. Default is "binary". Options: "binary", "text", or "response"
  • stream: (bool) when return_type is "response", you can also use stream=True to use the response as a stream

Examples:

```python

api_experiment.get_asset("298378237283728", return_type="json") {...} ```

To use with the streaming option:

```python

asset_response = api_experiment.get_asset( ... "298378237283728", ... return_type="response", ... stream=True, ... ) with open(filename, 'wb') as fd: for chunk in asset_response.iter_content(chunk_size=1024*1024): fd.write(chunk) ```


APIExperiment.get_asset_list

python get_asset_list(self, asset_type="all")

Get a list of assets associated with the experiment.

Args:

  • asset_type: Optional String, type of asset to return. Can be "all", "image", "histogram_combined_3d", "video", or "audio".

Returns a list of dictionaries of asset properties, like:

```python

from comet_ml.api import API api = API() x = api.get("myworkspace/project1/experiment_key") x.get_asset_list() [{'fileName': 'My Filename.png', 'fileSize': 21113, 'runContext': None, 'step': None, 'link': 'https://www.comet.ml/api/asset/download?experimentKey=KEY&assetId=ASSET_ID', 'createdAt': 1565898755830, 'dir': 'assets', 'canView': False, 'audio': False, 'video': False, 'histogram': False, 'image': True, 'type': 'image', 'metadata': None, 'assetId': ASSET_ID}, ...]

x.get_asset_list("image") [{'fileName': 'My Filename.png', 'fileSize': 21113, 'runContext': None, 'step': None, 'link': 'https://www.comet.ml/api/asset/download?experimentKey=KEY&assetId=ASSET_ID', 'createdAt': 1565898755830, 'dir': 'assets', 'canView': False, 'audio': False, 'video': False, 'histogram': False, 'image': True, 'type': 'image', 'metadata': None, 'assetId': ASSET_ID}, ...] ```


APIExperiment.get_code

python get_code(self)

Get the associated source code for this experiment.

Example:

```python

api_experiment.get_code() 'import comet_ml experiment = comet_ml.Experiment() experiment.end()' ```


APIExperiment.get_command

python get_command(self)

Get the associated command-line script and args for this experiment.

Example:

```python

api_experiment.get_command() ['keras.py', '--size', '1024', '--log', 'experiment.log'] ```


APIExperiment.get_curve

python get_curve(self, asset_id)

Get curve logged with experiment by asset id.

Example:

```python

api_experiment.get_curve("57457745745745774") {"name": "curve1", "x": [1, 2, 3], "y": [4, 5, 6], "step": 0} ```


APIExperiment.get_curves

python get_curves(self)

Get all curves logged with experiment.

Example:

```python

api_experiment.get_curves() [{"name": "curve1", "x": [1, 2, 3], "y": [4, 5, 6], "step": 0}] ```


APIExperiment.get_environment_details

python get_environment_details(self)

Deprecated. Use APIExperiment.get_os_packages() instead.


APIExperiment.get_executable

python get_executable(self)

Get the associated executable for this experiment.

Example:

```python

api_experiment.get_executable() '/usr/local/bin/python' ```


APIExperiment.get_git_metadata

python get_git_metadata(self)

Get the git-metadata associated with this experiment.

Example:

```python

api_experiment.get_git_metadata() { "branch": 'refs/heads/master', "origin": 'git@github.com:comet-ml/comet-examples.git', "parent": '96ff529b4c02e4e0bb92992a7c4ce81275985764', "root": 'eec2d16daa057d0cf4c2c49974e6ea51e732a7b2', "user": 'user', } ```


APIExperiment.get_git_patch

python get_git_patch(self)

Get the git-patch associated with this experiment as a zipfile containing an unique file named zip_file.patch.

Example:

```python

import io, zipfile zip_patch = io.BytesIO(api_experiment.get_git_patch()) archive = zipfile.ZipFile(zip_patch) patch = archive.read("git_diff.patch") patch b'...' ```


APIExperiment.get_gpu_static_info

python get_gpu_static_info(self)

Get the associated GPU static info for this experiment.

Example:

```python

api_experiment.get_gpu_static_info() [{ "gpuIndex": 0, "name": "GeForce GTX 950", "uuid": "GPU-cb6c1b39-5a56-6d79-8899-3796f23c6425", "totalMemory": 2090074112, "powerLimit": 110000, }, ...] ```


APIExperiment.get_hostname

python get_hostname(self)

Get the associated hostname for this experiment.

Example:

```python

api_experiment.get_hostname() 'name-of-computer-host' ```


APIExperiment.get_html

python get_html(self)

Get the HTML associated with this experiment.

Example:

```python

api_experiment.get_html() "Hello, world!" ```


APIExperiment.get_installed_packages

python get_installed_packages(self)

Get the associated installed packages for this experiment.

Example:

```python

api_experiment.get_installed_packages() ['absl-py==0.8.1', 'adal==1.2.2', 'alabaster==0.7.12', ...] ```


APIExperiment.get_ip

python get_ip(self)

Get the associated IP for this experiment.

Example:

```python

api_experiment.get_ip() '175.29.200.91' ```


APIExperiment.get_machine

python get_machine(self)

Get the associated total RAM for this experiment.

Example:

```python

api_experiment.get_machine() 'AMD64' ```


APIExperiment.get_max_memory

python get_max_memory(self)

Get the associated max total memory for this experiment.

Example:

```python

api_experiment.get_max_memory() 1024 ```


APIExperiment.get_metadata

python get_metadata(self)

Get the metadata associated with this experiment.

Example:

```python

from comet_ml import APIExperiment api_experiment = APIExperiment(previous_experiment='EXPERIMENT-KEY') api_experiment.get_metadata() { 'archived': False, 'durationMillis': 7, 'endTimeMillis': 1586174765277, 'experimentKey': 'EXPERIMENT-KEY', 'experimentName': None, 'fileName': None, 'filePath': None, 'optimizationId': None, 'projectId': 'PROJECT-ID', 'projectName': 'PROJECT-NAME', 'running': False, 'startTimeMillis': 1586174757596, 'throttle': False, 'workspaceName': 'WORKSPACE-NAME', } ```


APIExperiment.get_metrics

python get_metrics(self, metric=None)

Get all of the logged metrics. Optionally, just get the given metric name.

Args:

  • metric: Optional. String. If given, filter the metrics by name.

Example:

```python

from comet_ml.api import API api = API() x = api.get("myworkspace/project1/experiment_key")

x.get_metrics() [{'metricName': 'val_loss', 'metricValue': '0.13101346811652184', 'timestamp': 1558962376383, 'step': 1500, 'epoch': None, 'runContext': None}, {'metricName': 'acc', 'metricValue': '0.876', 'timestamp': 1564536453647, 'step': 100, 'epoch': None, 'runContext': None}, ...]

x.get_metrics("acc") [{'metricName': 'acc', 'metricValue': '0.876', 'timestamp': 1564536453647, 'step': 100, 'epoch': None, 'runContext': None}, ...] ```


APIExperiment.get_metrics_summary

python get_metrics_summary(self, metric=None)

Return the experiment metrics summary. Optionally, also if you provide the metric name, the function will only return the summary of the metric.

Args:

  • metric: optional (string), name of a metric

Examples:

```python

from comet_ml.api import API api = API() x = api.get("myworkspace/project1/experiment_key") x.get_metrics_summary() [{'name': 'val_loss', 'valueMax': '0.24951280827820302', 'valueMin': '0.13101346811652184', 'valueCurrent': '0.13101346811652184', 'timestampMax': 1558962367938, 'timestampMin': 1558962367938, 'timestampCurrent': 1558962376383, 'stepMax': 500, 'stepMin': 1500, 'stepCurrent': 1500}, ...]

api.get_metrics_summary("val_loss") {'name': 'val_loss', 'valueMax': '0.24951280827820302', 'valueMin': '0.13101346811652184', 'valueCurrent': '0.13101346811652184', 'timestampMax': 1558962367938, 'timestampMin': 1558962367938, 'timestampCurrent': 1558962376383, 'stepMax': 500, 'stepMin': 1500, 'stepCurrent': 1500} ```


APIExperiment.get_model_asset_list

python get_model_asset_list(self, model_name)

Get an experiment model's asset list by model name.

Args:

  • model_name: str, the name of the model

Returns: a list of asset dictionaries with these fields:

  • fileName
  • fileSize
  • runContext
  • step
  • link
  • createdAt
  • dir
  • canView
  • audio
  • histogram
  • image
  • type
  • metadata
  • assetId

Example:

```python

from comet_ml import API api = API() api_exp = api.get("workspace/project/765643463546345364536453436") api_exp.get_model_asset_list("Model Name") [ { "assetId": 74374637463476, "audio": False, "canView": False, "createdAt": 7337347634, "dir": "trained-models", "fileName": "model.h5", "fileSize": 254654, "histogram": False, "image": False, "link": "https://link-to-download-asset-file", "metadata": None, "remote": False, "runContext": "train", "step": 54, "type": "asset", } ] ```


APIExperiment.get_model_data

python get_model_data(self, name)

Deprecated. Use APIExperiment.get_model_asset_list(model_name) instead.


APIExperiment.get_model_graph

python get_model_graph(self)

Get the associated graph/model description for this experiment.

Example:

```python

api_experiment.get_model_graph() {"class_name": "Sequential", ...} ```


APIExperiment.get_model_names

python get_model_names(self)

Get a list of model names associated with this experiment.

Returns: list of model names


APIExperiment.get_name

python get_name(self)

Get the name of the experiment, if one.

Example:

```python

api_experiment.set_name("My Name") api_experiment.get_name() 'My Name' ```


APIExperiment.get_network_interface_ips

python get_network_interface_ips(self)

Get the associated network interface IPs for this experiment.

Example:

```python

api_experiment.get_network_interface_ips() ['127.0.0.1', '10.0.0.71', ...] ```


APIExperiment.get_os

python get_os(self)

Get the associated OS for this experiment.

Example:

```python

api_experiment.get_os() 'Linux-4.15.0-1059-oem-x86_64-with-Ubuntu-18.04-bionic' ```


APIExperiment.get_os_packages

python get_os_packages(self)

Get the OS packages for this experiment.

Example:

```python

api_experiment.get_os_packages() ['accountsservice=0.6.45-1ubuntu1', 'acl=2.2.52-3build1', 'acpi-support=0.142', ...] ```


APIExperiment.get_os_release

python get_os_release(self)

Get the associated OS release for this experiment.

Example:

```

api_experiment.get_os_release() '8' ```


APIExperiment.get_os_type

python get_os_type(self)

Get the associated os type for this experiment.

Example:

```python

api_experiment.get_os_type() 'Linux' ```


APIExperiment.get_others_summary

python get_others_summary(self, other=None)

Get the other items logged in summary form.

Args:

  • other: optional, string, the name of the other item logged. If given, return the valueCurrent of the other item. Otherwise, return all other items logged.

Examples:

```python

from comet_ml.api import API api = API() x = api.get("myworkspace/project1/experiment_key") x.get_others_summary() [{'name': 'trainable_params', 'valueMax': '712723', 'valueMin': '712723', 'valueCurrent': '712723', 'timestampMax': 1558962363411, 'timestampMin': 1558962363411, 'timestampCurrent': 1558962363411}, ...]

x.get_others_summary("trainable_params") ['712723'] ```


APIExperiment.get_output

python get_output(self)

Get the associated standard output for this experiment.

Example:

```python

api_experiment.get_output() "Experiment is live" ```


APIExperiment.get_parameters_summary

python get_parameters_summary(self, parameter=None)

Return the experiment parameters summary. Optionally, also if you provide a parameter name, the method will only return the summary of the given parameter.

Args:

  • parameter: optional (string), name of a parameter

Examples:

```python

from comet_ml.api import API api = API() x = api.get("myworkspace/project1/experiment_key") x.get_parameters_summary() [{'name': 'batch_size', 'valueMax': '120', 'valueMin': '120', 'valueCurrent': '120', 'timestampMax': 1558962363411, 'timestampMin': 1558962363411, 'timestampCurrent': 1558962363411}, ...]

x.get_parameters_summary("batch_size") {'name': 'batch_size', 'valueMax': '120', 'valueMin': '120', 'valueCurrent': '120', 'timestampMax': 1558962363411, 'timestampMin': 1558962363411, 'timestampCurrent': 1558962363411} ```


APIExperiment.get_pid

python get_pid(self)

Get the pid for this experiment.

Example:

```python

api_experiment.get_pid() 34658 ```


APIExperiment.get_processor

python get_processor(self)

Get the associated total RAM for this experiment.

Example:

```python

api_experiment.get_processor() 'Intel64 Family 6 Model 60 Stepping 3, GenuineIntel ```


APIExperiment.get_python_version

python get_python_version(self)

Get the Python version for this experiment.

Example:

```python

api_experiment.get_python_version() '3.6.8' ```


APIExperiment.get_python_version_verbose

python get_python_version_verbose(self)

Get the Python version verbose for this experiment.

Example:

```python

api_experiment.get_python_version_verbose() '3.6.8 (default, Oct 7 2019, 12:59:55) [GCC 8.3.0]' ```


APIExperiment.get_system_details

python get_system_details(self)

Get the system details associated with this experiment.

Returns a dictionary like:

python { "experimentKey": "someExperimentKey", "user": "system username" "pythonVersion": "python version" "pythonVersionVerbose": "python version with verbose flag" "pid": <Integer, pid>, "osType": "os experiment ran on", "os": "os with version info", "ip": "ip address", "hostname": "hostname", "gpuStaticInfoList": [ { "gpuIndex": <Integer, index>, "name": "name", "uuid": "someUniqueId", "totalMemory": <Integer, total memory>, "powerLimit": <Integer, max power> } ], "logAdditionalSystemInfoList": [ { "key": "someKey", "value": "someValue" } ], "systemMetricNames": ["name", "anotherName"], "maxTotalMemory": <double, max memory used>, "networkInterfaceIps": ["ip", "anotherIp"] "command": ["part1", "part2"], "executable": "The python Exe, if any (in future could be non python executables)", "osPackages": ["package", "anotherPackage"], "installedPackages": ["package", "anotherPackage"] }


APIExperiment.get_system_metric_names

python get_system_metric_names(self)

Get the associated system metric names for this experiment.

Example:

```python

api_experiment.get_system_metric_names() ['sys.cpu.percent.03', 'sys.cpu.percent.02', 'sys.cpu.percent.01', ...] ```


APIExperiment.get_tags

python get_tags(self)

Get the associated tags for this experiment.

Example:

```python

api_experiment.get_tags() ["best"] ```


APIExperiment.get_total_memory

python get_total_memory(self)

Get the associated total RAM for this experiment.

Example:

```python

api_experiment.get_total_memory() 1024 ```


APIExperiment.get_user

python get_user(self)

Get the associated user for this experiment.

Example:

```python

api_experiment.get_user() 'usename' ```


APIExperiment.log_additional_system_info

python log_additional_system_info(self, key, value)

Log additional system information for this experiment.

Args:

  • key: (string) the name for this system information
  • value: (any type), the value of the system information

Example:

```python

experiment.log_additional_system_info("some name": 42) ```


APIExperiment.log_asset

python log_asset(self, filename, step=None, overwrite=None, context=None, ftype=None, metadata=None)

Upload an asset to an experiment.

Args:

  • filename: the name of the asset file to upload
  • step: the current step
  • overwrite: if True, overwrite any previous upload
  • context: the current context (e.g., "train" or "test")
  • ftype: the type of asset (e.g., "image", "histogram_combined_3d", "image", "audio", or "video")
  • metadata: a JSON object to attach to image

Note: don't delete the file until upload is complete

Example:

```python

api_experiment.log_asset("histogram.json", ftype="histogram_compbined_3d") ```


APIExperiment.log_cpu_metrics

python log_cpu_metrics(self, cpu_metrics, context=None, step=None, epoch=None, timestamp=None)

Log an instance of cpu_metrics.

Args:

  • cpu_metrics: a list of integer percentages, ordered by cpu
  • context: optional, a run context
  • step: optional, the current step
  • epoch: optional, the current epoch
  • timestamp: optional, current time, in milliseconds

Example:

```python

Four CPUs:

api_experiment.log_cpu_metrics([25, 50, 10, 45]) ```


APIExperiment.log_curve

python log_curve(self, name, x, y, overwrite=False, step=None)

Log timeseries data.

Args:

  • name: (str) name of data
  • x: list of x-axis values
  • y: list of y-axis values
  • overwrite: (optional, bool) if True, overwrite previous log
  • step: (optional, int) the step value

Examples:

```python

experiment.log_curve("my curve", x=[1, 2, 3, 4, 5], y=[10, 20, 30, 40, 50]) experiment.log_curve("my curve", [1, 2, 3, 4, 5], [10, 20, 30, 40, 50]) ```


APIExperiment.log_gpu_metrics

python log_gpu_metrics(self, gpu_metrics)

Log an instance of gpu_metrics.

Args:

  • gpu_metrics: a list of dicts with keys:
  • gpuId: required, Int identifier
  • freeMemory: required, Long
  • usedMemory: required, Long
  • gpuUtilization: required, Int percentage utilization
  • totalMemory: required, Long

Example:

```python

api_experiment.log_gpu_metrics([{ ... "gpuId": 1, ... "freeMemory": 1024, ... "usedMemory": 856, ... "gpuUtilization": 25, ... "totalMemory": 2056, ... }]) ```


APIExperiment.log_html

python log_html(self, html, clear=False, timestamp=None)

Set, or append onto, an experiment's HTML.

Args:

  • html: (string) the HTML text to associate with this experiment
  • clear: (optional, boolean) if True, clear any previously logged HTML
  • timestamp: (optional, number) the current time (in milliseconds)

Example:

```python

api_experiment.log_html("Hello!") ```


APIExperiment.log_image

python log_image(self, filename, image_name=None, step=None, overwrite=None, context=None)

Upload an image asset to an experiment.

Args:

  • filename: the name of the image file to upload
  • image_name: the name of the image
  • step: the current step
  • overwrite: if True, overwrite any previous upload
  • context: the current context (e.g., "train" or "test")

Note: don't delete the file until upload is complete

Example:

```python

api_experiment.log_image("image.png", "Weights") ```


APIExperiment.log_load_metrics

python log_load_metrics(self, load_avg, context=None, step=None, epoch=None, timestamp=None)

Log an instance of system load metrics.

Args:

  • load_avg: required, the load average
  • context: optional, the run context
  • step: optional, the current step
  • epoch: optional, the current epoch
  • timestamp: optional, the current timestamp in milliseconds

Example:

```python

api_experiment.log_load_metrics(1.5, "validate", 100, 25, 65364346) ```


APIExperiment.log_metric

python log_metric(self, metric, value, step=None, timestamp=None)

Set a metric name/value pair for an experiment.

Args:

  • metric: string, the name of the metric
  • value: any type, the value of the metric
  • step: optional integer, the current step
  • timestamp: optional, the current timestamp in milliseconds

Example:

```python

api_experiment.log_metric("loss", 0.698) ```


APIExperiment.log_metrics

python log_metrics(self, metric_dict, step=None, timestamp=None)

Set a dictionary of metric name/value pairs for an experiment.

Args:

  • metric_dict: dict in the form of {"metric_name": value, ...}
  • step: optional integer, the current step
  • timestamp: optional, the current timestamp in milliseconds

Example:

```python

api_experiment.log_metrics({"loss": 0.698, "accuracy": 0.12}) [...] ```


APIExperiment.log_other

python log_other(self, key, value, timestamp=None)

Set an other key/value pair for an experiment.

Args:

  • key: string, the name of the other information
  • value: any time, the value of the other information
  • timestamp: optional, the current timestamp in milliseconds

Example:

```python

api_experiment.log_other("key", value) ```


APIExperiment.log_output

python log_output(self, output, context=None, stderr=False, timestamp=None)

Log output line(s).

Args:

     - **output**:  string representing standard output or error
     - **context**:  optional, the run context
     - **stderr**:  optional, boolean, if True, the lines are standard errors
     - **timestamp**:  optional, the current timestamp in milliseconds

Example:

```python

api_experiment.log_output("output line 1 output line 2") ```


APIExperiment.log_parameter

python log_parameter(self, parameter, value, step=None, timestamp=None)

Set a parameter name/value pair for an experiment.

Args:

  • parameter: string, the name of the parameter
  • value: any type, the value of the parameter
  • step: optional integer, the current step
  • timestamp: optional, the current timestamp in milliseconds

Example:

```python

api_experiment.log_parameter("hidden_layer_size", 64) ```


APIExperiment.log_parameters

python log_parameters(self, param_dict, step=None, timestamp=None)

Set a dictionary of parameter name/value pairs for an experiment.

Args:

  • param_dict: dict in the form of {"param_name": value, ...}
  • step: optional integer, the current step
  • timestamp: optional, the current timestamp in milliseconds

Example:

```python

api_experiment.log_parameters({"learning_rate": 0.12, "layers": 3}) [...] ```


APIExperiment.log_ram_metrics

python log_ram_metrics(self, total_ram, used_ram, context=None, step=None, epoch=None, timestamp=None)

Log an instance of RAM metrics.

Args:

  • total_ram: required, total RAM available
  • used_ram: required, RAM used
  • context: optional, the run context
  • step: optional, the current step
  • epoch: optional, the current epoch
  • timestamp: optional, the current timestamp in millisconds

Example:

```python

api_experiment.log_ram_metrics(1024, 865, "train", 100, 1, 3645346534) ```


APIExperiment.log_table

python log_table(self, filename, tabular_data=None, headers=False, **format_kwargs)

Log tabular data, including data, csv files, tsv files, and Pandas dataframes.

Args:

  • filename: str (required), a filename ending in ".csv", or ".tsv" (for tablular data) or ".json", ".csv", ".md", or ".html" (for Pandas dataframe data).
  • tabular_data: (optional) data that can be interpreted as 2D tabular data or a Pandas dataframe).
  • headers: bool or list, if True, will add column headers automatically if tabular_data is given; if False, no headers will be added; if list then it will be used as headers. Only useful with tabular data (csv, or tsv).
  • format_kwargs: (optional keyword arguments), when passed a Pandas dataframe these keyword arguments are used in the conversion to "json", "csv", "md", or "html". See Pandas Dataframe conversion methods (like to_json()) for more information.

See also:

Examples:

```python

api_experiment.log_table("vectors.tsv", ... [["one", "two", "three"], ... [1, 2, 3], ... [4, 5, 6]], ... api_experiment.log_table("dataframe.json", pandas_dataframe) ```


APIExperiment.register_model

python register_model(self, model_name, version="1.0.0", workspace=None, registry_name=None, public=None, description=None, comment=None, stages=None)

Register an experiment model in the workspace registry.

Args:

  • model_name: the name of the experiment model
  • workspace: optional, the name of workspace; defaults to current workspace
  • version: a proper semantic version string; defaults to "1.0.0"
  • registry_name: optional, the name of the registered workspace model, if not provided the model_name will be used instead.
  • public: optional, if True, then the model will be publically viewable
  • description: optional, a textual description of the model
  • comment: optional, a textual comment about the model
  • stages: optional, a list of textual tags such as ["production", "staging"] etc.

Returns {"registryModelId": "ath6ho4eijaexeShahJ9sohQu", "registryModelItemId": "yoi5saes7ea2vooG2ush1uuwi"} if successful.


APIExperiment.set_code

python set_code(self, code=None, filename=None)

Set the code for this experiment. Pass in either the code as a string, or provide filename.

Args:

     - **code**:  string, optional, the source code for this experiment
     - **filename**:  string, optional, the filename for this experiment

Example:

```python

api_experiment.set_code("import comet_ml experiment = comet_ml.Experiment()") api_experiment.set_code(filename="script.py") ```


APIExperiment.set_command

python set_command(self, command_args_list)

Set the command-line (script and args) for this experiment.

Args:

  • command_args_list: list of strings, starting with name of script, and followed by arguments.

Example:

```python

api_experiment.set_command(["script.py", "arg1", "arg2", "--flag", "arg3"]) ```


APIExperiment.set_end_time

python set_end_time(self, end_server_timestamp)

Set the end time of an experiment.

Args:

  • end_server_timestamp: a timestamp in milliseconds

Example:

```python

api_experiment.set_end_time(2652656352) ```

Note: Time is in milliseconds. If the start time has not

been set, it will be set to 1 second before the end time.


APIExperiment.set_executable

python set_executable(self, executable)

Set the executable for this experiment.

Args:

  • executable: string, the python executable

Example:

```python

api_experiment.set_executable("/usr/bin/python3") ```


APIExperiment.set_filename

python set_filename(self, filename)

Set the path and filename for this experiment.

Args:

  • filename: string, the python path and filename

Example:

```python

api_experiment.set_filename("../src/script.py") ```


APIExperiment.set_git_metadata

python set_git_metadata(self, user, root, branch, parent, origin)

Set the git metadata for this experiment.

Args:

  • user: (string, required) the name of the git user
  • root: (string, required) the name of the git root
  • branch: (string, required) the name of the git branch
  • parent: (string, required) the name of the git parent
  • origin: (string, required) the name of the git origin

Example:

```python

api_experiment.set_git_metadata("user", "root", "branch", "parent", "origin") ```


APIExperiment.set_git_patch

python set_git_patch(self, file_data)

Set the git patch for this experiment.

Args:

  • file_data: the contents or filename of the git patch file

Example:

```python

api_experiment.set_git_patch("git.patch") ```


APIExperiment.set_gpu_static_info

python set_gpu_static_info(self, gpu_static_info)

Set the GPU static info for this experiment.

Args:

  • gpu_static_info: list of dicts containing keys gpuIndex, name, uuid, totalMemory, and powerLimit and their values.

Example:

```python

api_experiment.set_gpu_static_info([{ "gpuIndex": 0, "name": "GeForce GTX 950", "uuid": "GPU-cb6c1b39-5a56-6d79-8899-3796f23c6425", "totalMemory": 2090074112, "powerLimit": 110000, }, ...]) ```


APIExperiment.set_hostname

python set_hostname(self, hostname)

Set the hostname for this experiment.

Args:

  • hostname: string, the hostname of the computer the experiment ran on

Example:

```python

api_experiment.set_hostname("machine.company.com") ```


APIExperiment.set_installed_packages

python set_installed_packages(self, installed_packages)

Set the installed Python packages for this experiment.

Args:

  • installed_packages: list of strings, a list of the installed Python packages

Example:

```python

api_experiment.set_installed_packages(["comet_ml", "matplotlib"]) ```


APIExperiment.set_ip

python set_ip(self, ip)

Set the internet protocol (IP) address for this experiment.

Args:

  • ip: string, the internet protocol address

Example:

```python

api_experiment.set_ip("10.0.0.7") ```


APIExperiment.set_machine

python set_machine(self, machine)

Set the machine for this experiment.

Args:

  • machine: string, the machine type

Example:

```python

import platform api_experiment.set_machine(platform.machine()) ```


APIExperiment.set_model_graph

python set_model_graph(self, graph)

Set the model graph for this experiment.

Args:

  • graph: various types, a representation of the model graph

Example:

```python

api_experiment.set_model_graph(model) ```


APIExperiment.set_name

python set_name(self, name)

Set a name for the experiment. Useful for filtering and searching on Comet.ml. Will shown by default under the Other tab. Args:

  • name: String. A name for the experiment.

APIExperiment.set_network_interface_ips

python set_network_interface_ips(self, network_interface_ips)

Set the network interface ips for this experiment.

Args:

  • network_interface_ips: list of strings, of local network interfaces

Example:

```python

api_experiment.set_network_interface_ips(["127.0.0.1", "192.168.1.100"]) ```


APIExperiment.set_os

python set_os(self, os)

Set the OS for this experiment.

Args:

  • os: string, the OS platform identifier

Example:

```python

import platform api_experiment.set_os(platform.platform(aliased=True)) ```


APIExperiment.set_os_packages

python set_os_packages(self, os_packages)

Set the OS packages for this experiment.

Args:

  • os_packages: list of strings, the OS package list

Example:

```python

api_experiment.set_os_packages(['accountsservice=0.6.45-1ubuntu1', ...]) ```


APIExperiment.set_os_release

python set_os_release(self, os_release)

Set the OS release for this experiment.

Args:

  • os_release: string, the OS release

Example:

```python

import platform api_experiment.set_os_release(platform.uname()[2]) ```


APIExperiment.set_os_type

python set_os_type(self, os_type)

Set the OS type for this experiment.

Args:

  • os_type: string, the OS type

Example:

```python

api_experiment.set_os_type("Linux 2.0.1, Ubuntu 16.10") ```


APIExperiment.set_pid

python set_pid(self, pid)

Set the process ID for this experiment.

Args:

  • pid: string, the OS process ID

Example:

```python

api_experiment.set_pid(54238) ```


APIExperiment.set_processor

python set_processor(self, processor)

Set the processor for this experiment.

Args:

  • processor: string, the processor name

Example:

```python

import platform api_experiment.set_processor(platform.processor()) ```


APIExperiment.set_python_version

python set_python_version(self, python_version)

Set the Python version for this experiment.

Args:

  • python_version: string, the verbose Python version

Example:

```python

api_experiment.set_python_version("3.6.7") ```


APIExperiment.set_python_version_verbose

python set_python_version_verbose(self, python_version_verbose)

Set the Python version verbose for this experiment.

Args:

  • python_version_verbose: string, the verbose Python version

Example:

```python

api_experiment.set_python_version_verbose("3.6.7, by Anaconda") ```


APIExperiment.set_start_time

python set_start_time(self, start_server_timestamp)

Set the start time of an experiment.

Args:

  • start_server_timestamp: a timestamp in milliseconds

Example:

```python

api_experiment.set_start_time(2652656352) ```

Note: Time is in milliseconds. If the end time has not been set

it will automatically be set for 1 second after the start time.


APIExperiment.set_user

python set_user(self, user)

Set the user for this experiment.

Args:

  • user: string, the OS username

Example:

```python

api_experiment.set_user("os-user-name") ```


APIExperiment.to_json

python to_json(self, full=False)

The experiment data in JSON-like format.

Args:

     - **full**:  bool (optional), if True, get all experiment information.

Examples:

```python

experiment.to_json() ```

Returns:

```json {'id': '073e272581ac48c283910a05e5495381', 'name': None, 'workspace': 'testuser', 'project_name': 'test-project-7515', 'archived': False, 'url': 'https://www.comet.ml/testuser/test-project-7515/073e272581ac48c283910a05e54953801', 'duration_millis': 4785, 'start_server_timestamp': 1571318652586, 'end_server_timestamp': 7437457, 'optimization_id': None, }

```python

experiment.to_json(full=True) ```

Returns:

json {'id': '073e272581ac48c283910a05e5495380', 'name': None, 'workspace': 'testuser', 'project_name': 'test-project-7515', 'archived': False, 'url': 'https://staging.comet.ml/testuser/test-project-7515/073e272581ac48c283910a05e5495380', 'duration_millis': 4785, 'start_server_timestamp': 1571318652586, 'end_server_timestamp': 7437457, 'optimization_id': None, 'asset_list': [], 'code': 'one two three ', 'html': '<b>hello<b> <i>world!</i> ', 'metrics': [], 'metrics_summary': [], 'output': 'four five six ', 'parameters_summary': [], 'system_details': {'experimentKey': None, 'user': None, 'pythonVersion': None, 'pythonVersionVerbose': None, 'pid': None, 'osType': None, 'os': None, 'ip': None, 'hostname': None, 'gpuStaticInfoList': [], 'logAdditionalSystemInfoList': [], 'systemMetricNames': [], 'maxTotalMemory': None, 'networkInterfaceIps': None, 'command': None, 'executable': None, 'osPackages': ['lib1', 'lib2', 'lib3'], 'installedPackages': [], 'totalRam': None}, 'tags': ['tag6', 'tag7', 'tag8'], 'git_patch': b'', 'git_metadata': {'user': None, 'root': None, 'branch': None, 'parent': None, 'origin': None}, }


APIExperiment.update_status

python update_status(self)

Update the status for this experiment. Sends the keep-alive status for it in the UI. The return JSON dictionary contains the recommended interval to send subsequent update_status() messages.

Example:

```python

api_experiment.update_status() {'isAliveBeatDurationMillis': 10000, 'gpuMonitorIntervalMillis': 60000, 'cpuMonitorIntervalMillis': 68000} ```