mlflow

mlflow.log_param(key, value)

Logs the passed-in parameter under the current run, creating a run if necessary. :param key: Parameter name (string) :param value: Parameter value (string)

mlflow.log_metric(key, value)

Logs the passed-in metric under the current run, creating a run if necessary. :param key: Metric name (string) :param value: Metric value (float)

mlflow.log_artifacts(local_dir, artifact_path=None)

Log all the contents of a local directory as artifacts of the run.

mlflow.log_artifact(local_path, artifact_path=None)

Log a local file or directory as an artifact of the currently active run.

mlflow.active_run()

Returns the currently active Run, or None if no such run exists.

mlflow.start_run(run_uuid=None, experiment_id=None, source_name=None, source_version=None, entry_point_name=None, source_type=None)

Start a new MLflow run, setting it as the active run under which metrics and params will be logged. The return value can be used as a context manager within a with block; otherwise, end_run() must be called to terminate the current run. Note that if run_uuid is passed or the MLFLOW_RUN_ID environment variable is set, start_run will attempt to resume a run with the specified run ID (with run_uuid taking precedence over MLFLOW_RUN_ID), and other parameters will be ignored.

Parameters:
  • run_uuid – If specified, gets the run with the specified UUID and logs metrics and params under that run. The run’s end time will be unset and its status will be set to running, but the run’s other attributes will remain unchanged (the run’s source_version, source_type, etc will not be changed).
  • experiment_id – Only used when run_uuid is unspecified. ID of the experiment under which to create the current run. If unspecified, the run will be created under a new experiment with a randomly-generated name
  • source_name – Name of the source file or URI of the project to be associated with the run. Defaults to the current file if none provided.
  • source_version – Optional Git commit hash to associate with the run.
  • entry_point_name – Optional name of the entry point for to the current run.
  • source_type – Integer enum value describing the type of the run (“local”, “project”, etc). Defaults to mlflow.entities.source_type.SourceType.LOCAL.
Returns:

A ActiveRun object that acts as a context manager wrapping the run’s state

mlflow.end_run(status='FINISHED')
mlflow.get_artifact_uri()

Returns the artifact URI of the currently active run. Calls to log_artifact, log_artifacts will write artifact(s) to subdirectories of the returned URI.

mlflow.set_tracking_uri(uri)

Sets the tracking server URI to the passed-in value. Note that this does not affect the currently active run (if one exists), but will take effect for any successive runs.

mlflow.create_experiment(experiment_name)

Creates an experiment with the specified name and returns its ID.