Experiments
This page explains how to create, view, update, and delete experiments; add comments; and manage experiment tags in H2O MLOps using the Python client. It also describes experiment properties and how to compute Kubernetes options.
To learn more about experiments, see Understand experiments in MLOps.
Prerequisites​
Before you begin,
- Connect to H2O MLOps. For instructions, see Connect to H2O MLOps.
- Create a project. For steps, see Create a project.
Create an experiment​
Use the create()
method to create a new experiment in a project:
experiment = project.experiments.create(
data="/path/test.zip",
name="my-experiment"
description="Test experiment",
)
You can link or unlink an H2O Driverless AI (DAI) experiment, or an existing DAI or H2O MLOps experiment in storage, to a project.
Link an experiment by UID:
project.experiments.link(uid="your-experiment-uid")
Unlink an experiment:
project.experiments.unlink(uid="your-experiment-uid")
View experiments​
Count experiments​
Get the total number of experiments in a project:
Input:
project.experiments.count()
Output:
1
List experiments​
List all experiments in a project:
Input:
project.experiments.list()
Output:
| name | uid | tags
---+---------------+--------------------------------------+--------
0 | my-experiment | d9a47c99-c66c-4ff9-b2b6-30faf5f413ef |
Filter experiments​
Use the experiments.list()
method with key-value arguments to filter the experiments.
Input:
project.experiments.list(name="my-experiment")
This returns a list of matching experiments as a table.
Output:
| name | uid | tags
---+----------------------+--------------------------------------+--------
0 | my-experiment | d9a47c99-c66c-4ff9-b2b6-30faf5f413ef |
Retrieve an experiment​
Retrieve a specific experiment by UID:
Input:
experiment = project.experiments.get(uid="d9a47c99-c66c-4ff9-b2b6-30faf5f413ef")
experiment
You can also retrieve a specific experiment from the list returned by experiments.list()
using indexing.
For example, experiment = project.experiments.list(key=value)[index]
. The key
and value
arguments are optional.
Output:
<class 'h2o_mlops._experiments.MLOpsExperiment(
uid='d9a47c99-c66c-4ff9-b2b6-30faf5f413ef',
name='my-experiment',
description='Test experiment',
is_registered=True,
owner_username='test.user@test.com',
created_time=datetime.datetime(2025, 5, 22, 7, 2, 48, 185159, tzinfo=tzutc()),
last_modified_time=datetime.datetime(2025, 5, 22, 7, 2, 48, 185159, tzinfo=tzutc())
)'>
Experiment properties​
An experiment has the following main properties:
uid
: The unique identifier of the experiment.name
: The name of the experiment.description
: A description of the experiment.is_registered
: If the experiment is registered or not.owner
: The experiment owner.created_time
: The timestamp when the experiment was created.last_modified_time
: The timestamp of the last modification.
Metadata​
Each experiment includes metadata you can retrieve using the following method:
Input:
experiment.metadata
Output:
| key | value
---+---------------------+---------------------------------------------
0 | h2o3/algo | glm
1 | h2o3/algo_full_name | Generalized Linear Modeling
2 | h2o3/category | Regression
3 | h2o3/columns | ['Origin', 'Dest', 'fDayofMonth', 'fYear...
4 | h2o3/created_time | 2020-08-24 07:21:50.137000+00:00
5 | input_schema | [{'name': 'Origin', 'type': 'STR'}, {'na...
6 | model_type | h2o3/mojo
7 | output_schema | [{'name': 'Distance', 'type': 'FLOAT64'}...
8 | tool | h2o3
To get a specific metadata entry by index:
Input:
experiment.metadata[3]
Output:
{'h2o3/columns': ['Origin',
'Dest',
'fDayofMonth',
'fYear',
'UniqueCarrier',
'fDayOfWeek',
'fMonth',
'IsDepDelayed']}
Parameters​
To access parameters related to the dataset used in the experiment:
Input:
experiment.parameters["target_column"]
Output:
{'training_dataset_id': '',
'validation_dataset_id': '',
'test_dataset_id': '',
'target_column': 'Distance',
'weight_column': '',
'fold_column': ''}
In this example, the target column is Distance
.
Statistics​
To access training statistics:
Input:
experiment.statistics
Output:
{'training_duration': None}
Input schema​
To view the schema of the input dataset:
Input:
experiment.input_schema
Output:
| name | type
---+---------------+--------
0 | Origin | STR
1 | Dest | STR
2 | fDayofMonth | STR
3 | fYear | STR
4 | UniqueCarrier | STR
5 | fDayOfWeek | STR
6 | fMonth | STR
7 | IsDepDelayed | STR
Output schema​
To view the output schema of the experiment:
Input:
experiment.output_schema
Output:
| name | type
---+----------+---------
0 | Distance | FLOAT64
Scoring runtimes​
You can list the available scoring runtimes that might be used when deploying the experiment:
Input:
scoring_runtimes = experiment.scoring_runtimes
scoring_runtimes
Output:
| artifact_type | runtime_uid | runtime_name
---+-----------------+---------------------------------------+----------------------------------------------
0 | h2o3_mojo | h2o3_mojo_runtime | H2O-3 MOJO Scorer
1 | h2o3_mojo | h2o3_mojo_runtime_shapley_transformed | H2O-3 MOJO Scorer (Shapley transformed only)
To view details of a specific scoring runtime:
Input:
scoring_runtimes[0]
Output:
<class 'h2o_mlops._runtimes.MLOpsScoringRuntime(
runtime='h2o3_mojo_runtime',
artifact_type='h2o3_mojo',
artifact_processor='h2o3_mojo_extractor',
model_type='h2o3_mojo',
)'>
Compute Kubernetes options​
To compute Kubernetes options for an experiment runtime:
Input:
experiment.compute_k8s_options(
runtime_uid="h2o3_mojo_runtime", workers=1
)
Output:
KubernetesOptions(
replicas=1,
requests={'cpu': '500m', 'memory': '128Mi'},
limits={},
affinity=None,
toleration=None
)
Update an experiment​
You can update only the name
and description
fields of an experiment.
Make sure to retrieve the experiment instance before updating it. See Retrieve an experiment.
Input:
experiment.update(name="new-experiment")
experiment
Output:
<class 'h2o_mlops._experiments.MLOpsExperiment(
uid='d9a47c99-c66c-4ff9-b2b6-30faf5f413ef',
name='new-experiment',
description='Test experiment',
is_registered=True,
owner_username='test.user@test.com',
created_time=datetime.datetime(2025, 5, 22, 7, 2, 48, 185159, tzinfo=tzutc()),
last_modified_time=datetime.datetime(2025, 5, 22, 7, 3, 26, 278369, tzinfo=tzutc())
)'>
Add comments to an experiment​
You can add one or more comments to an experiment to share information with collaborators.
experiment.comments.add("Comment 01")
experiment.comments.add("Comment 02")
To list all comments:
Input:
experiment.comments.list()
Output:
| created_time | author_username | message
---+------------------------+--------------------+------------
0 | 2025-05-22 07:03:30 AM | test.user@test.com | Comment 01
1 | 2025-05-22 07:03:31 AM | test.user@test.com | Comment 02
Manage experiment tags​
You can create tags and add them to experiments to group related experiments. For example, you can create a tag called Telco
for telecommunication-related experiments and later retrieve them as a group.
Create a tag​
To create a new tag in a project:
tag1 = project.tags.create(label="tag1")
List tags​
To list all tags in a project:
Input:
project.tags.list()
Output:
| label | uid
---+---------+--------------------------------------
0 | tag1 | 31fc1901-1134-4384-ac07-e0965f8e30c7
Get a specific tag​
To retrieve a tag by its label:
Input:
tag1 = project.tags.get(label="tag1")
tag1
Output:
<class 'h2o_mlops._projects.MLOpsProjectTag(
uid='31fc1901-1134-4384-ac07-e0965f8e30c7',
label='tag1',
parent_project_uid='e37a6146-5248-4754-9d93-68a9798babb2',
created_time=datetime.datetime(2025, 5, 22, 7, 3, 35, 596458, tzinfo=tzutc()),
)'>
Add tag​
To add an existing tag to an experiment:
experiment.tags.add(label="tag1")
To add a new tag to an experiment without creating it first:
experiment.tags.add(label="tag2")
To list and verify all tags in an experiment:
Input:
experiment.tags.list()
Output:
| label | uid
---+---------+--------------------------------------
0 | tag1 | 31fc1901-1134-4384-ac07-e0965f8e30c7
1 | tag2 | b541b0b1-6371-4106-8095-94c9c25f2f0a
Update a tag​
To update a tag’s label and view the updated list:
Input:
tag1.update(label="new-tag1")
experiment.tags.list() # or project.tags.list()
Output:
| label | uid
---+----------+--------------------------------------
0 | tag2 | b541b0b1-6371-4106-8095-94c9c25f2f0a
1 | new-tag1 | 31fc1901-1134-4384-ac07-e0965f8e30c7
Remove a tag​
To remove a tag from an experiment:
Input:
experiment.tags.remove(label="new-tag1")
experiment.tags.list()
Output:
| label | uid
---+---------+--------------------------------------
0 | tag2 | b541b0b1-6371-4106-8095-94c9c25f2f0a
This removes the tag only from the experiment, not from the project.
To view all tags in a project after performing the above removal, use the following method:
Input:
project.tags.list()
This displays the list of tags currently available in the project.
Output:
| label | uid
---+----------+--------------------------------------
0 | tag2 | b541b0b1-6371-4106-8095-94c9c25f2f0a
1 | new-tag1 | 31fc1901-1134-4384-ac07-e0965f8e30c7
Delete a tag​
To delete a tag from a project:
Input:
tag1.delete()
project.tags.list()
Output:
| label | uid
---+---------+--------------------------------------
0 | tag2 | b541b0b1-6371-4106-8095-94c9c25f2f0a
You cannot delete a tag from a project if it has already been added to an experiment.
Delete and restore experiments​
This section describes how to delete and restore experiments.
Delete using an experiment instance​
If you already have a reference to the experiment
object, use the delete()
method:
Input:
experiment.delete()
project.experiments.list()
Output:
| name | uid | tags
---+--------+-------+--------
Restore using an experiment instance​
If you already have a reference to the experiment
object, use the restore()
method:
Input:
experiment.restore()
project.experiments.list()
Output:
| name | uid | tags
---+------------------------+--------------------------------------+--------
0 | new-experiment | d9a47c99-c66c-4ff9-b2b6-30faf5f413ef | tag2
Delete using experiment UIDs​
You can also delete multiple experiments at once by specifying their UIDs:
Input:
project.experiments.delete(uids=["d9a47c99-c66c-4ff9-b2b6-30faf5f413ef"])
You can also pass a list of MLOpsExperiment
instances or a _utils.Table
containing experiments.
Example:
project.experiments.delete(experiments=[experiment])
Output:
| experiment_uid | is_deleted | message | project_uid
---+--------------------------------------+--------------+-----------+--------------------------------------
0 | d9a47c99-c66c-4ff9-b2b6-30faf5f413ef | True | | e37a6146-5248-4754-9d93-68a9798babb2
Restore using experiment UIDs​
You can also restore multiple experiments at once by specifying their UIDs:
Input:
project.experiments.restore(uids=["d9a47c99-c66c-4ff9-b2b6-30faf5f413ef"])
You can also pass a list of MLOpsExperiment
instances or a _utils.Table
containing experiments.
Example: project.experiments.restore(experiments=[experiment])
Output:
| experiment_uid | is_restored | message | project_uid
---+--------------------------------------+---------------+-----------+--------------------------------------
0 | d9a47c99-c66c-4ff9-b2b6-30faf5f413ef | True | | e37a6146-5248-4754-9d93-68a9798babb2
- Submit and view feedback for this page
- Send feedback about H2O MLOps to cloud-feedback@h2o.ai