Skip to content

Commit 76acb64

Browse files
authored
Add more examples for experiment and trial (#64)
* Add more examples for experiment and trial * fix a typo
1 parent 1163b94 commit 76acb64

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

src/smexperiments/experiment.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@ class Experiment(_base_types.Record):
2424
add a new trial to an Experiment by calling :meth:`~smexperiments.experiment.Experiment.create_trial`.
2525
To remove a Trial from an experiment, delete the trial.
2626
27+
Examples:
28+
.. code-block:: python
29+
30+
from smexperiments import experiment
31+
32+
my_experiment = experiment.Experiment.create(experiment_name='AutoML')
33+
my_trial = my_experiment.create_trial(trial_name='random-forest')
34+
35+
for exp in experiment.Experiment.list():
36+
print(exp)
37+
for trial in my_experiment.list_trials():
38+
print(trial)
39+
40+
my_trial.delete()
41+
my_experiment.delete()
42+
2743
Attributes:
2844
experiment_name (str): The name of the experiment. The name must be unique within an account.
2945
description (str): A description of the experiment.

src/smexperiments/trial.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,25 @@ class Trial(_base_types.Record):
2121
2222
Consists of a list of trial component objects, which document individual activities within the workflow.
2323
24+
Examples:
25+
.. code-block:: python
26+
27+
from smexperiments import trial, experiment, tracker
28+
29+
my_experiment = experiment.Experiment.create(experiment_name='AutoML')
30+
my_trial = trial.Trial.create('AutoML')
31+
32+
my_tracker = tracker.Tracker.create()
33+
# log hyper parameter of learning rate
34+
my_tracker.log_parameter('learning_rate', 0.01)
35+
my_trial.add_trial_component(my_tracker)
36+
37+
for trial_component in my_trial.list_trial_components():
38+
print(trial_component)
39+
40+
my_trial.remove_trial_component(my_tracker)
41+
my_trial.delete()
42+
2443
Attributes:
2544
trial_name (str): The name of the trial.
2645
experiment_name (str): The name of the trial's experiment.

0 commit comments

Comments
 (0)