10
10
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF
11
11
# ANY KIND, either express or implied. See the License for the specific
12
12
# language governing permissions and limitations under the License.
13
- """Placeholder docstring. """
13
+ """Placeholder docstring"""
14
14
from __future__ import print_function , absolute_import
15
15
16
16
from abc import ABCMeta , abstractmethod
38
38
39
39
class AnalyticsMetricsBase (with_metaclass (ABCMeta , object )):
40
40
"""Base class for tuning job or training job analytics classes.
41
+
41
42
Understands common functionality like persistence and caching.
42
43
"""
43
44
@@ -54,8 +55,9 @@ def export_csv(self, filename):
54
55
55
56
def dataframe (self , force_refresh = False ):
56
57
"""A pandas dataframe with lots of interesting results about this object.
57
- Created by calling SageMaker List and Describe APIs and
58
- converting them into a convenient tabular summary.
58
+
59
+ Created by calling SageMaker List and Describe APIs and converting them into a
60
+ convenient tabular summary.
59
61
60
62
Args:
61
63
force_refresh (bool): Set to True to fetch the latest data from
@@ -73,8 +75,8 @@ def _fetch_dataframe(self):
73
75
74
76
def clear_cache (self ):
75
77
"""Clear the object of all local caches of API methods.
76
- So that the next time any properties are accessed they will be refreshed from the
77
- service.
78
+
79
+ So that the next time any properties are accessed they will be refreshed from the service.
78
80
"""
79
81
self ._dataframe = None
80
82
@@ -103,7 +105,7 @@ def __init__(self, hyperparameter_tuning_job_name, sagemaker_session=None):
103
105
104
106
@property
105
107
def name (self ):
106
- """Name of the HyperparameterTuningJob being analyzed. """
108
+ """Name of the HyperparameterTuningJob being analyzed"""
107
109
return self ._tuning_job_name
108
110
109
111
def __repr__ (self ):
@@ -156,6 +158,7 @@ def reshape(training_summary):
156
158
@property
157
159
def tuning_ranges (self ):
158
160
"""A dictionary describing the ranges of all tuned hyperparameters.
161
+
159
162
The keys are the names of the hyperparameter, and the values are the ranges.
160
163
161
164
The output can take one of two forms:
@@ -207,7 +210,7 @@ def tuning_ranges(self):
207
210
}
208
211
209
212
def _prepare_parameter_ranges (self , parameter_ranges ):
210
- """Convert parameter ranges a dictionary using the parameter range names as the keys. """
213
+ """Convert parameter ranges a dictionary using the parameter range names as the keys"""
211
214
out = {}
212
215
for _ , ranges in parameter_ranges .items ():
213
216
for param in ranges :
@@ -313,7 +316,7 @@ def __init__(
313
316
314
317
@property
315
318
def name (self ):
316
- """Name of the TrainingJob being analyzed. """
319
+ """Name of the TrainingJob being analyzed"""
317
320
return self ._training_job_name
318
321
319
322
def __repr__ (self ):
@@ -360,7 +363,7 @@ def _fetch_dataframe(self):
360
363
return pd .DataFrame (self ._data )
361
364
362
365
def _fetch_metric (self , metric_name ):
363
- """Fetch all the values of a named metric, and add them to _data.
366
+ """Fetch all the values of a named metric, and add them to _data
364
367
365
368
Args:
366
369
metric_name: The metric name to fetch.
@@ -564,6 +567,7 @@ def clear_cache(self):
564
567
565
568
def _reshape_parameters (self , parameters ):
566
569
"""Reshape trial component parameters to a pandas column.
570
+
567
571
Args:
568
572
parameters: trial component parameters
569
573
Returns:
@@ -578,6 +582,7 @@ def _reshape_parameters(self, parameters):
578
582
579
583
def _reshape_metrics (self , metrics ):
580
584
"""Reshape trial component metrics to a pandas column.
585
+
581
586
Args:
582
587
metrics: trial component metrics
583
588
Returns:
@@ -598,6 +603,7 @@ def _reshape_metrics(self, metrics):
598
603
599
604
def _reshape_artifacts (self , artifacts , _artifact_names ):
600
605
"""Reshape trial component input/output artifacts to a pandas column.
606
+
601
607
Args:
602
608
artifacts: trial component input/output artifacts
603
609
Returns:
@@ -631,6 +637,7 @@ def _reshape_parents(self, parents):
631
637
632
638
def _reshape (self , trial_component ):
633
639
"""Reshape trial component data to pandas columns.
640
+
634
641
Args:
635
642
trial_component: dict representing a trial component
636
643
Returns:
@@ -660,9 +667,8 @@ def _reshape(self, trial_component):
660
667
return out
661
668
662
669
def _fetch_dataframe (self ):
663
- """Return a pandas dataframe with all the trial_components,
664
- along with their parameters and metrics.
665
- """
670
+ """Return a pandas dataframe includes all the trial_components."""
671
+
666
672
df = pd .DataFrame ([self ._reshape (component ) for component in self ._get_trial_components ()])
667
673
return df
668
674
0 commit comments