Skip to content

Commit ba4028a

Browse files
Merge pull request #5 from aws/master
2 parents aa54685 + 2594ffb commit ba4028a

File tree

7 files changed

+55
-21
lines changed

7 files changed

+55
-21
lines changed

.github/ISSUE_TEMPLATE/bug_report.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Bug report
33
about: File a report to help us reproduce and fix the problem
44
title: ''
5-
labels: ''
5+
labels: 'bug'
66
assignees: ''
77

88
---

.github/ISSUE_TEMPLATE/feature_request.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name: Feature request
33
about: Suggest new functionality for this library
44
title: ''
5-
labels: ''
5+
labels: 'feature request'
66
assignees: ''
77

88
---

CHANGELOG.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
# Changelog
22

3+
## v2.59.7 (2021-10-04)
4+
5+
### Bug Fixes and Other Changes
6+
7+
* update feature request label
8+
* update bug template
9+
10+
## v2.59.6 (2021-09-30)
11+
12+
### Bug Fixes and Other Changes
13+
14+
* ParamValidationError when scheduling a Clarify model monitor
15+
16+
## v2.59.5 (2021-09-29)
17+
18+
### Bug Fixes and Other Changes
19+
20+
* support maps in step parameters
21+
322
## v2.59.4 (2021-09-27)
423

524
### Bug Fixes and Other Changes

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.59.5.dev0
1+
2.59.8.dev0

src/sagemaker/clarify.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def __init__(
228228
probability_threshold=None,
229229
label_headers=None,
230230
):
231-
"""Initializes a model output config to extract the predicted label.
231+
"""Initializes a model output config to extract the predicted label or predicted score(s).
232232
233233
The following examples show different parameter configurations depending on the endpoint:
234234
* Regression Task: The model returns the score, e.g. 1.2. we don't need to specify
@@ -255,11 +255,11 @@ def __init__(
255255
'label_headers=['cat','dog','fish']' and infer the predicted label to be 'fish.'
256256
257257
Args:
258-
label (str or int or list[int]): Optional index or JSONPath location in the model
259-
output for the prediction. In case, this is a predicted label of the same type as
260-
the label in the dataset no further arguments need to be specified.
261-
probability (str or int or list[int]): Optional index or JSONPath location in the model
262-
output for the predicted scores.
258+
label (str or int): Index or JSONPath location in the model output for the prediction.
259+
In case, this is a predicted label of the same type as the label in the dataset,
260+
no further arguments need to be specified.
261+
probability (str or int): Index or JSONPath location in the model output
262+
for the predicted score(s).
263263
probability_threshold (float): An optional value for binary prediction tasks in which
264264
the model returns a probability, to indicate the threshold to convert the
265265
prediction to a boolean value. Default is 0.5.

src/sagemaker/model_monitor/clarify_model_monitoring.py

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -476,9 +476,15 @@ def suggest_baseline(
476476
features_attribute=data_config.features,
477477
)
478478
if model_predicted_label_config is not None:
479-
latest_baselining_job_config.inference_attribute = model_predicted_label_config.label
479+
latest_baselining_job_config.inference_attribute = (
480+
model_predicted_label_config.label
481+
if model_predicted_label_config.label is None
482+
else str(model_predicted_label_config.label)
483+
)
480484
latest_baselining_job_config.probability_attribute = (
481485
model_predicted_label_config.probability
486+
if model_predicted_label_config.probability is None
487+
else str(model_predicted_label_config.probability)
482488
)
483489
latest_baselining_job_config.probability_threshold_attribute = (
484490
model_predicted_label_config.probability_threshold
@@ -827,8 +833,9 @@ def suggest_baseline(
827833
specific explainability method. Currently, only SHAP is supported.
828834
model_config (:class:`~sagemaker.clarify.ModelConfig`): Config of the model and its
829835
endpoint to be created.
830-
model_scores: Index or JSONPath location in the model output for the predicted scores
831-
to be explained. This is not required if the model output is a single score.
836+
model_scores (int or str): Index or JSONPath location in the model output for the
837+
predicted scores to be explained. This is not required if the model output is
838+
a single score.
832839
wait (bool): Whether the call should wait until the job completes (default: False).
833840
logs (bool): Whether to show the logs produced by the job.
834841
Only meaningful when wait is True (default: False).
@@ -865,7 +872,7 @@ def suggest_baseline(
865872
headers=headers,
866873
),
867874
features_attribute=data_config.features,
868-
inference_attribute=model_scores,
875+
inference_attribute=model_scores if model_scores is None else str(model_scores),
869876
)
870877
self.latest_baselining_job_name = baselining_job_name
871878
self.latest_baselining_job = ClarifyBaseliningJob(

tests/unit/sagemaker/monitor/test_clarify_model_monitor.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@
9393
OUTPUT_S3_URI = "s3://bucket/output"
9494
CONSTRAINTS = Constraints("", "s3://bucket/analysis.json")
9595
FEATURES_ATTRIBUTE = "features"
96-
INFERENCE_ATTRIBUTE = "predicted_label"
97-
PROBABILITY_ATTRIBUTE = "probabilities"
96+
INFERENCE_ATTRIBUTE = 0
97+
PROBABILITY_ATTRIBUTE = 1
9898
PROBABILITY_THRESHOLD_ATTRIBUTE = 0.6
9999
APP_SPECIFICATION = {
100100
"ConfigUri": ANALYSIS_CONFIG_S3_URI,
@@ -131,8 +131,8 @@
131131
"StartTimeOffset": START_TIME_OFFSET,
132132
"EndTimeOffset": END_TIME_OFFSET,
133133
"FeaturesAttribute": FEATURES_ATTRIBUTE,
134-
"InferenceAttribute": INFERENCE_ATTRIBUTE,
135-
"ProbabilityAttribute": PROBABILITY_ATTRIBUTE,
134+
"InferenceAttribute": str(INFERENCE_ATTRIBUTE),
135+
"ProbabilityAttribute": str(PROBABILITY_ATTRIBUTE),
136136
"ProbabilityThresholdAttribute": PROBABILITY_THRESHOLD_ATTRIBUTE,
137137
},
138138
"GroundTruthS3Input": {"S3Uri": GROUND_TRUTH_S3_URI},
@@ -155,7 +155,7 @@
155155
"S3InputMode": S3_INPUT_MODE,
156156
"S3DataDistributionType": S3_DATA_DISTRIBUTION_TYPE,
157157
"FeaturesAttribute": FEATURES_ATTRIBUTE,
158-
"InferenceAttribute": INFERENCE_ATTRIBUTE,
158+
"InferenceAttribute": str(INFERENCE_ATTRIBUTE),
159159
}
160160
}
161161
EXPLAINABILITY_JOB_DEFINITION = {
@@ -665,6 +665,13 @@ def test_model_bias_monitor_suggest_baseline(
665665
sagemaker_session=sagemaker_session,
666666
analysis_config=None, # will pick up config from baselining job
667667
baseline_job_name=BASELINING_JOB_NAME,
668+
endpoint_input=EndpointInput(
669+
endpoint_name=ENDPOINT_NAME,
670+
destination=ENDPOINT_INPUT_LOCAL_PATH,
671+
start_time_offset=START_TIME_OFFSET,
672+
end_time_offset=END_TIME_OFFSET,
673+
# will pick up attributes from baselining job
674+
),
668675
)
669676

670677
# update schedule
@@ -837,8 +844,8 @@ def _test_model_bias_monitor_create_schedule(
837844
start_time_offset=START_TIME_OFFSET,
838845
end_time_offset=END_TIME_OFFSET,
839846
features_attribute=FEATURES_ATTRIBUTE,
840-
inference_attribute=INFERENCE_ATTRIBUTE,
841-
probability_attribute=PROBABILITY_ATTRIBUTE,
847+
inference_attribute=str(INFERENCE_ATTRIBUTE),
848+
probability_attribute=str(PROBABILITY_ATTRIBUTE),
842849
probability_threshold_attribute=PROBABILITY_THRESHOLD_ATTRIBUTE,
843850
),
844851
):
@@ -1074,6 +1081,7 @@ def test_model_explainability_monitor_suggest_baseline(
10741081
analysis_config=None, # will pick up config from baselining job
10751082
baseline_job_name=BASELINING_JOB_NAME,
10761083
endpoint_input=ENDPOINT_NAME,
1084+
# will pick up attributes from baselining job
10771085
)
10781086

10791087
# update schedule
@@ -1253,7 +1261,7 @@ def _test_model_explainability_monitor_create_schedule(
12531261
endpoint_name=ENDPOINT_NAME,
12541262
destination=ENDPOINT_INPUT_LOCAL_PATH,
12551263
features_attribute=FEATURES_ATTRIBUTE,
1256-
inference_attribute=INFERENCE_ATTRIBUTE,
1264+
inference_attribute=str(INFERENCE_ATTRIBUTE),
12571265
),
12581266
):
12591267
# create schedule

0 commit comments

Comments
 (0)