Skip to content

Commit 372c1bd

Browse files
xgchenaJoseJuan98
authored andcommitted
fix: Correct SageMaker Clarify API docstrings by changing JSONPath to JMESPath (aws#3511)
1 parent e150ef4 commit 372c1bd

File tree

4 files changed

+39
-34
lines changed

4 files changed

+39
-34
lines changed

src/sagemaker/clarify.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,11 @@ def __init__(
330330
s3_analysis_config_output_path (str): S3 prefix to store the analysis config output.
331331
If this field is None, then the ``s3_output_path`` will be used
332332
to store the ``analysis_config`` output.
333-
label (str): Target attribute of the model required by bias metrics.
334-
Specified as column name or index for CSV dataset or as JSONPath for JSONLines.
333+
label (str): Target attribute of the model required by bias metrics. Specified as
334+
column name or index for CSV dataset or as JMESPath expression for JSONLines.
335335
*Required parameter* except for when the input dataset does not contain the label.
336-
features (List[str]): JSONPath for locating the feature columns for bias metrics if the
337-
dataset format is JSONLines.
336+
features (List[str]): JMESPath expression to locate the feature columns for
337+
bias metrics if the dataset format is JSONLines.
338338
dataset_type (str): Format of the dataset. Valid values are ``"text/csv"`` for CSV,
339339
``"application/jsonlines"`` for JSONLines, and
340340
``"application/x-parquet"`` for Parquet.
@@ -716,11 +716,11 @@ def __init__(
716716
``label_headers=['cat','dog','fish']`` and infer the predicted label to be ``'fish'``.
717717
718718
Args:
719-
label (str or int): Index or JSONPath location in the model output for the prediction.
720-
In case, this is a predicted label of the same type as the label in the dataset,
721-
no further arguments need to be specified.
722-
probability (str or int): Index or JSONPath location in the model output
723-
for the predicted score(s).
719+
label (str or int): Index or JMESPath expression to locate the prediction
720+
in the model output. In case, this is a predicted label of the same type
721+
as the label in the dataset, no further arguments need to be specified.
722+
probability (str or int): Index or JMESPath expression to locate the predicted score(s)
723+
in the model output.
724724
probability_threshold (float): An optional value for binary prediction tasks in which
725725
the model returns a probability, to indicate the threshold to convert the
726726
prediction to a boolean value. Default is ``0.5``.
@@ -1645,9 +1645,9 @@ def run_explainability(
16451645
You can request multiple methods at once by passing in a list of
16461646
`~sagemaker.clarify.ExplainabilityConfig`.
16471647
model_scores (int or str or :class:`~sagemaker.clarify.ModelPredictedLabelConfig`):
1648-
Index or JSONPath to locate the predicted scores in the model output. This is not
1649-
required if the model output is a single score. Alternatively, it can be an instance
1650-
of :class:`~sagemaker.clarify.SageMakerClarifyProcessor`
1648+
Index or JMESPath expression to locate the predicted scores in the model output.
1649+
This is not required if the model output is a single score. Alternatively,
1650+
it can be an instance of :class:`~sagemaker.clarify.SageMakerClarifyProcessor`
16511651
to provide more parameters like ``label_headers``.
16521652
wait (bool): Whether the call should wait until the job completes (default: True).
16531653
logs (bool): Whether to show the logs produced by the job.
@@ -1774,9 +1774,9 @@ def run_bias_and_explainability(
17741774
str or
17751775
:class:`~sagemaker.clarify.ModelPredictedLabelConfig`
17761776
):
1777-
Index or JSONPath to locate the predicted scores in the model output. This is not
1778-
required if the model output is a single score. Alternatively, it can be an instance
1779-
of :class:`~sagemaker.clarify.SageMakerClarifyProcessor`
1777+
Index or JMESPath expression to locate the predicted scores in the model output.
1778+
This is not required if the model output is a single score. Alternatively,
1779+
it can be an instance of :class:`~sagemaker.clarify.SageMakerClarifyProcessor`
17801780
to provide more parameters like ``label_headers``.
17811781
wait (bool): Whether the call should wait until the job completes (default: True).
17821782
logs (bool): Whether to show the logs produced by the job.

src/sagemaker/model_monitor/clarify_model_monitoring.py

+12-11
Original file line numberDiff line numberDiff line change
@@ -842,8 +842,8 @@ def __init__(self, bias_config, headers=None, label=None):
842842
bias_config (sagemaker.clarify.BiasConfig): Config object related to bias
843843
configurations.
844844
headers (list[str]): A list of column names in the input dataset.
845-
label (str): Target attribute for the model required by bias metrics.
846-
Specified as column name or index for CSV dataset, or as JSONPath for JSONLines.
845+
label (str): Target attribute for the model required by bias metrics. Specified as
846+
column name or index for CSV dataset, or as JMESPath expression for JSONLines.
847847
"""
848848
self.analysis_config = bias_config.get_config()
849849
if headers is not None:
@@ -889,9 +889,10 @@ def suggest_baseline(
889889
model_config (:class:`~sagemaker.clarify.ModelConfig`): Config of the model and its
890890
endpoint to be created.
891891
model_scores (int or str or :class:`~sagemaker.clarify.ModelPredictedLabelConfig`):
892-
Index or JSONPath to locate the predicted scores in the model output. This is not
893-
required if the model output is a single score. Alternatively, it can be an instance
894-
of ModelPredictedLabelConfig to provide more parameters like label_headers.
892+
Index or JMESPath expression to locate the predicted scores in the model output.
893+
This is not required if the model output is a single score. Alternatively,
894+
it can be an instance of ModelPredictedLabelConfig to provide more parameters
895+
like label_headers.
895896
wait (bool): Whether the call should wait until the job completes (default: False).
896897
logs (bool): Whether to show the logs produced by the job.
897898
Only meaningful when wait is True (default: False).
@@ -1302,12 +1303,12 @@ def __init__(
13021303
Args:
13031304
analysis_config (BiasAnalysisConfig or ExplainabilityAnalysisConfig): analysis config
13041305
from configurations of the baselining job.
1305-
features_attribute (str): JSONpath to locate features in predictor request payload.
1306-
Only required when predictor content type is JSONlines.
1307-
inference_attribute (str): Index, header or JSONpath to locate predicted label in
1308-
predictor response payload.
1309-
probability_attribute (str): Index or JSONpath location in the model output for
1310-
probabilities or scores to be used for explainability.
1306+
features_attribute (str): JMESPath expression to locate features in predictor request
1307+
payload. Only required when predictor content type is JSONlines.
1308+
inference_attribute (str): Index, header or JMESPath expression to locate predicted
1309+
label in predictor response payload.
1310+
probability_attribute (str): Index or JMESPath expression to locate probabilities or
1311+
scores in the model output for computing feature attribution.
13111312
probability_threshold_attribute (float): Value to indicate the threshold to select
13121313
the binary label in the case of binary classification. Default is 0.5.
13131314
"""

src/sagemaker/model_monitor/model_monitoring.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -1061,12 +1061,13 @@ def _generate_env_map(
10611061
dataset_format (dict): The format of the baseline_dataset.
10621062
dataset_source_container_path (str): The path to the dataset source.
10631063
inference_attribute (str): Index or JSONpath to locate predicted label(s).
1064-
Only used for ModelQualityMonitor, ModelBiasMonitor, and ModelExplainabilityMonitor
1064+
Only used for ModelQualityMonitor.
10651065
probability_attribute (str or int): Index or JSONpath to locate probabilities.
1066-
Only used for ModelQualityMonitor, ModelBiasMonitor and ModelExplainabilityMonitor
1067-
ground_truth_attribute (str): Index or JSONpath to locate actual label(s).
1066+
Only used for ModelQualityMonitor.
1067+
ground_truth_attribute (str): Index to locate actual label(s).
1068+
Only used for ModelQualityMonitor.
10681069
probability_threshold_attribute (float): threshold to convert probabilities to binaries
1069-
Only used for ModelQualityMonitor, ModelBiasMonitor and ModelExplainabilityMonitor
1070+
Only used for ModelQualityMonitor.
10701071
10711072
Returns:
10721073
dict: Dictionary of environment keys and values.
@@ -2600,10 +2601,13 @@ def suggest_baseline(
26002601
problem_type (str): The type of problem of this model quality monitoring. Valid
26012602
values are "Regression", "BinaryClassification", "MulticlassClassification".
26022603
inference_attribute (str): Index or JSONpath to locate predicted label(s).
2604+
Only used for ModelQualityMonitor.
26032605
probability_attribute (str or int): Index or JSONpath to locate probabilities.
2604-
ground_truth_attribute (str): Index or JSONpath to locate actual label(s).
2606+
Only used for ModelQualityMonitor.
2607+
ground_truth_attribute (str): Index to locate actual label(s).
2608+
Only used for ModelQualityMonitor.
26052609
probability_threshold_attribute (float): threshold to convert probabilities to binaries
2606-
Only used for ModelQualityMonitor, ModelBiasMonitor and ModelExplainabilityMonitor
2610+
Only used for ModelQualityMonitor.
26072611
post_analytics_processor_script (str): The path to the record post-analytics processor
26082612
script. This can be a local path or an S3 uri.
26092613
output_s3_uri (str): Desired S3 destination Destination of the constraint_violations

src/sagemaker/workflow/clarify_check_step.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ class ModelExplainabilityCheckConfig(ClarifyCheckConfig):
132132
model_config (ModelConfig): Config of the model and its endpoint to be created.
133133
explainability_config (SHAPConfig): Config of the specific explainability method.
134134
Currently, only SHAP is supported.
135-
model_scores (str or int or ModelPredictedLabelConfig): Index or JSONPath location
136-
in the model output for the predicted scores to be explained (default: None).
135+
model_scores (str or int or ModelPredictedLabelConfig): Index or JMESPath expression
136+
to locate the predicted scores in the model output (default: None).
137137
This is not required if the model output is a single score. Alternatively,
138138
an instance of ModelPredictedLabelConfig can be provided
139139
but this field CANNOT be any type of the `PipelineVariable`.

0 commit comments

Comments
 (0)