6

I am unable to change the experiment id of a MLflow experiment.

Currently, I am running the following code to create an experiment before logging:

mlflow.set_experiment(experiment_name="my_model")

with mlflow.start_run():
   #train model

Doing so allows me to create a new experiment, but the experiment id will always be 1.

The yaml file created looks like this:

artifact_location: file:///project/src/mlruns/1
experiment_id: '1'
lifecycle_stage: active
name: my_model

I have tried to look at the MLflow documentation, but I cannot find examples or functions where the experiment id is altered.

I would greatly appreciate any help or tips with this.

MDan
  • 295
  • 2
  • 13

2 Answers2

8

You should call you experiment_id in the start_run():

mlflow.set_experiment("experiment name")
experiment = mlflow.get_experiment_by_name("experiment name")

with mlflow.start_run(experiment_id=experiment.experiment_id):
     # train model

Note: If you use set_tracking_uri(), you should set_experiment() after that.

Maryam Bahrami
  • 1,056
  • 9
  • 18
0

mlflow has unique id per experiment, if you want new exp id you have to set new experiment name

with mlflow.start_run(mlflow.set_experiment("new_experiment"),run_name='train') as run :
   #train model

run_name can be anything which you like ,meaningful to you

if you want to change exp id of your experiment_name="my_model" take a back up and delete the artifact and the database which store the mapping of it and re run your module. but before delete make sure you see some other exp on ml UI.

punam
  • 155
  • 8