@@ -64,25 +64,24 @@ def _fetch_dataframe(self):
64
64
pass
65
65
66
66
def clear_cache (self ):
67
- """Clears the object of all local caches of API methods, so
67
+ """Clear the object of all local caches of API methods, so
68
68
that the next time any properties are accessed they will be refreshed from
69
69
the service.
70
70
"""
71
71
self ._dataframe = None
72
72
73
73
74
74
class HyperparameterTuningJobAnalytics (AnalyticsMetricsBase ):
75
- """Fetches results about this tuning job and makes them accessible for analytics.
75
+ """Fetch results about a hyperparameter tuning job and make them accessible for analytics.
76
76
"""
77
77
78
78
def __init__ (self , hyperparameter_tuning_job_name , sagemaker_session = None ):
79
- """Initialize an ``HyperparameterTuningJobAnalytics`` instance.
79
+ """Initialize a ``HyperparameterTuningJobAnalytics`` instance.
80
80
81
81
Args:
82
- hyperparameter_tuning_job_name (str): name of the HyperparameterTuningJob to
83
- analyze.
82
+ hyperparameter_tuning_job_name (str): name of the HyperparameterTuningJob to analyze.
84
83
sagemaker_session (sagemaker.session.Session): Session object which manages interactions with
85
- Amazon SageMaker APIs and any other AWS services needed. If not specified, the estimator creates one
84
+ Amazon SageMaker APIs and any other AWS services needed. If not specified, one is created
86
85
using the default AWS configuration chain.
87
86
"""
88
87
sagemaker_session = sagemaker_session or Session ()
@@ -100,16 +99,16 @@ def __repr__(self):
100
99
return "<sagemaker.HyperparameterTuningJobAnalytics for %s>" % self .name
101
100
102
101
def clear_cache (self ):
103
- """Clears the object of all local caches of API methods.
102
+ """Clear the object of all local caches of API methods.
104
103
"""
105
104
super (HyperparameterTuningJobAnalytics , self ).clear_cache ()
106
105
self ._tuning_job_describe_result = None
107
106
self ._training_job_summaries = None
108
107
109
108
def _fetch_dataframe (self ):
110
- """Returns a pandas dataframe with all the training jobs, their
111
- hyperparameters, results, and metadata about the training jobs.
112
- Includes a column to indicate that any job was the best seen so far.
109
+ """Return a pandas dataframe with all the training jobs, along with their
110
+ hyperparameters, results, and metadata. This also includes a column to indicate
111
+ if a training job was the best seen so far.
113
112
"""
114
113
def reshape (training_summary ):
115
114
# Helper method to reshape a single training job summary into a dataframe record
@@ -139,8 +138,8 @@ def reshape(training_summary):
139
138
140
139
@property
141
140
def tuning_ranges (self ):
142
- """A dict describing the ranges of all tuned hyperparameters.
143
- Dict's key is the name of the hyper param. Dict's value is the range .
141
+ """A dictionary describing the ranges of all tuned hyperparameters.
142
+ The keys are the names of the hyperparameter, and the values are the ranges .
144
143
"""
145
144
out = {}
146
145
for _ , ranges in self .description ()['HyperParameterTuningJobConfig' ]['ParameterRanges' ].items ():
@@ -149,10 +148,13 @@ def tuning_ranges(self):
149
148
return out
150
149
151
150
def description (self , force_refresh = False ):
152
- """Response to DescribeHyperParameterTuningJob
151
+ """Call `` DescribeHyperParameterTuningJob`` for the hyperparameter tuning job.
153
152
154
153
Args:
155
154
force_refresh (bool): Set to True to fetch the latest data from SageMaker API.
155
+
156
+ Returns:
157
+ dict: The Amazon SageMaker response for ``DescribeHyperParameterTuningJob``.
156
158
"""
157
159
if force_refresh :
158
160
self .clear_cache ()
@@ -163,10 +165,13 @@ def description(self, force_refresh=False):
163
165
return self ._tuning_job_describe_result
164
166
165
167
def training_job_summaries (self , force_refresh = False ):
166
- """A list of everything (paginated) from ListTrainingJobsForTuningJob
168
+ """A (paginated) list of everything from `` ListTrainingJobsForTuningJob``.
167
169
168
170
Args:
169
171
force_refresh (bool): Set to True to fetch the latest data from SageMaker API.
172
+
173
+ Returns:
174
+ dict: The Amazon SageMaker response for ``ListTrainingJobsForTuningJob``.
170
175
"""
171
176
if force_refresh :
172
177
self .clear_cache ()
@@ -191,19 +196,19 @@ def training_job_summaries(self, force_refresh=False):
191
196
192
197
193
198
class TrainingJobAnalytics (AnalyticsMetricsBase ):
194
- """Fetches training curve data from CloudWatch Metrics for a specific training job.
199
+ """Fetch training curve data from CloudWatch Metrics for a specific training job.
195
200
"""
196
201
197
202
CLOUDWATCH_NAMESPACE = '/aws/sagemaker/HyperParameterTuningJobs'
198
203
199
204
def __init__ (self , training_job_name , metric_names , sagemaker_session = None ):
200
- """Initialize an ``TrainingJobAnalytics`` instance.
205
+ """Initialize a ``TrainingJobAnalytics`` instance.
201
206
202
207
Args:
203
208
training_job_name (str): name of the TrainingJob to analyze.
204
209
metric_names (list): string names of all the metrics to collect for this training job
205
210
sagemaker_session (sagemaker.session.Session): Session object which manages interactions with
206
- Amazon SageMaker APIs and any other AWS services needed. If not specified, the estimator creates one
211
+ Amazon SageMaker APIs and any other AWS services needed. If not specified, one is specified
207
212
using the default AWS configuration chain.
208
213
"""
209
214
sagemaker_session = sagemaker_session or Session ()
@@ -223,7 +228,7 @@ def __repr__(self):
223
228
return "<sagemaker.TrainingJobAnalytics for %s>" % self .name
224
229
225
230
def clear_cache (self ):
226
- """Clears the object of all local caches of API methods, so
231
+ """Clear the object of all local caches of API methods, so
227
232
that the next time any properties are accessed they will be refreshed from
228
233
the service.
229
234
"""
@@ -232,7 +237,7 @@ def clear_cache(self):
232
237
self ._time_interval = self ._determine_timeinterval ()
233
238
234
239
def _determine_timeinterval (self ):
235
- """Returns a dict with two datetime objects, start_time and end_time
240
+ """Return a dictionary with two datetime objects, start_time and end_time,
236
241
covering the interval of the training job
237
242
"""
238
243
description = self ._sage_client .describe_training_job (TrainingJobName = self .name )
@@ -249,7 +254,7 @@ def _fetch_dataframe(self):
249
254
return pd .DataFrame (self ._data )
250
255
251
256
def _fetch_metric (self , metric_name ):
252
- """Fetches all the values of a named metric, and adds them to _data
257
+ """Fetch all the values of a named metric, and add them to _data
253
258
"""
254
259
request = {
255
260
'Namespace' : self .CLOUDWATCH_NAMESPACE ,
@@ -284,7 +289,7 @@ def _fetch_metric(self, metric_name):
284
289
self ._add_single_metric (elapsed_seconds , metric_name , value )
285
290
286
291
def _add_single_metric (self , timestamp , metric_name , value ):
287
- """Stores a single metric in the _data dict which can be
292
+ """Store a single metric in the _data dict which can be
288
293
converted to a dataframe.
289
294
"""
290
295
# note that this method is built this way to make it possible to
0 commit comments