@@ -350,6 +350,7 @@ def __init__(
350
350
env = None ,
351
351
tags = None ,
352
352
network_config = None ,
353
+ job_name_prefix = None ,
353
354
version = None ,
354
355
):
355
356
"""Initializes a ``Processor`` instance, computing bias metrics and model explanations.
@@ -384,9 +385,11 @@ def __init__(
384
385
A :class:`~sagemaker.network.NetworkConfig`
385
386
object that configures network isolation, encryption of
386
387
inter-container traffic, security group IDs, and subnets.
388
+ job_name_prefix (str): Processing job name prefix.
387
389
version (str): Clarify version want to be used.
388
390
"""
389
391
container_uri = image_uris .retrieve ("clarify" , sagemaker_session .boto_region_name , version )
392
+ self .job_name_prefix = job_name_prefix
390
393
super (SageMakerClarifyProcessor , self ).__init__ (
391
394
role ,
392
395
container_uri ,
@@ -500,13 +503,22 @@ def run_pre_training_bias(
500
503
data_config (:class:`~sagemaker.clarify.DataConfig`): Config of the input/output data.
501
504
data_bias_config (:class:`~sagemaker.clarify.BiasConfig`): Config of sensitive groups.
502
505
methods (str or list[str]): Selector of a subset of potential metrics:
503
- ["CI", "DPL", "KL", "JS", "LP", "TVD", "KS", "CDDL"]. Defaults to computing all.
504
- # TODO: Provide a pointer to the official documentation of those.
506
+ ["`CI <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ci.html>`_",
507
+ "`DPL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dpl.html>`_",
508
+ "`KL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-kl.html>`_",
509
+ "`JS <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-js.html>`_",
510
+ "`LP <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-lp.html>`_",
511
+ "`TVD <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-tvd.html>`_",
512
+ "`KS <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ks.html>`_",
513
+ "`CDDL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-cdd.html>`_"].
514
+ Defaults to computing all.
505
515
wait (bool): Whether the call should wait until the job completes (default: True).
506
516
logs (bool): Whether to show the logs produced by the job.
507
517
Only meaningful when ``wait`` is True (default: True).
508
- job_name (str): Processing job name. If not specified, a name is composed of
509
- "Clarify-Pretraining-Bias" and current timestamp.
518
+ job_name (str): Processing job name. When ``job_name`` is not specified, if
519
+ ``job_name_prefix`` in :class:`SageMakerClarifyProcessor` specified, the job name
520
+ will be composed of ``job_name_prefix`` and current timestamp; otherwise use
521
+ "Clarify-Pretraining-Bias" as prefix.
510
522
kms_key (str): The ARN of the KMS key that is used to encrypt the
511
523
user code file (default: None).
512
524
experiment_config (dict[str, str]): Experiment management configuration.
@@ -517,7 +529,10 @@ def run_pre_training_bias(
517
529
analysis_config .update (data_bias_config .get_config ())
518
530
analysis_config ["methods" ] = {"pre_training_bias" : {"methods" : methods }}
519
531
if job_name is None :
520
- job_name = utils .name_from_base ("Clarify-Pretraining-Bias" )
532
+ if self .job_name_prefix :
533
+ job_name = utils .name_from_base (self .job_name_prefix )
534
+ else :
535
+ job_name = utils .name_from_base ("Clarify-Pretraining-Bias" )
521
536
self ._run (data_config , analysis_config , wait , logs , job_name , kms_key , experiment_config )
522
537
523
538
def run_post_training_bias (
@@ -548,14 +563,25 @@ def run_post_training_bias(
548
563
model_predicted_label_config (:class:`~sagemaker.clarify.ModelPredictedLabelConfig`):
549
564
Config of how to extract the predicted label from the model output.
550
565
methods (str or list[str]): Selector of a subset of potential metrics:
551
- # TODO: Provide a pointer to the official documentation of those.
552
- ["DPPL", "DI", "DCA", "DCR", "RD", "DAR", "DRR", "AD", "CDDPL", "TE", "FT"].
566
+ ["`DPPL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dppl.html>`_"
567
+ , "`DI <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-di.html>`_",
568
+ "`DCA <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dca.html>`_",
569
+ "`DCR <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dcr.html>`_",
570
+ "`RD <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-rd.html>`_",
571
+ "`DAR <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dar.html>`_",
572
+ "`DRR <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-drr.html>`_",
573
+ "`AD <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ad.html>`_",
574
+ "`CDDPL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-cddpl.html>`_
575
+ ", "`TE <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-te.html>`_",
576
+ "`FT <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ft.html>`_"].
553
577
Defaults to computing all.
554
578
wait (bool): Whether the call should wait until the job completes (default: True).
555
579
logs (bool): Whether to show the logs produced by the job.
556
580
Only meaningful when ``wait`` is True (default: True).
557
- job_name (str): Processing job name. If not specified, a name is composed of
558
- "Clarify-Posttraining-Bias" and current timestamp.
581
+ job_name (str): Processing job name. When ``job_name`` is not specified, if
582
+ ``job_name_prefix`` in :class:`SageMakerClarifyProcessor` specified, the job name
583
+ will be composed of ``job_name_prefix`` and current timestamp; otherwise use
584
+ "Clarify-Posttraining-Bias" as prefix.
559
585
kms_key (str): The ARN of the KMS key that is used to encrypt the
560
586
user code file (default: None).
561
587
experiment_config (dict[str, str]): Experiment management configuration.
@@ -573,7 +599,10 @@ def run_post_training_bias(
573
599
analysis_config ["predictor" ] = predictor_config
574
600
_set (probability_threshold , "probability_threshold" , analysis_config )
575
601
if job_name is None :
576
- job_name = utils .name_from_base ("Clarify-Posttraining-Bias" )
602
+ if self .job_name_prefix :
603
+ job_name = utils .name_from_base (self .job_name_prefix )
604
+ else :
605
+ job_name = utils .name_from_base ("Clarify-Posttraining-Bias" )
577
606
self ._run (data_config , analysis_config , wait , logs , job_name , kms_key , experiment_config )
578
607
579
608
def run_bias (
@@ -605,18 +634,35 @@ def run_bias(
605
634
model_predicted_label_config (:class:`~sagemaker.clarify.ModelPredictedLabelConfig`):
606
635
Config of how to extract the predicted label from the model output.
607
636
pre_training_methods (str or list[str]): Selector of a subset of potential metrics:
608
- # TODO: Provide a pointer to the official documentation of those.
609
- ["DPPL", "DI", "DCA", "DCR", "RD", "DAR", "DRR", "AD", "CDDPL", "TE", "FT"].
637
+ ["`CI <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ci.html>`_",
638
+ "`DPL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dpl.html>`_",
639
+ "`KL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-kl.html>`_",
640
+ "`JS <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-js.html>`_",
641
+ "`LP <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-lp.html>`_",
642
+ "`TVD <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-tvd.html>`_",
643
+ "`KS <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ks.html>`_",
644
+ "`CDDL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-cdd.html>`_"].
610
645
Defaults to computing all.
611
646
post_training_methods (str or list[str]): Selector of a subset of potential metrics:
612
- # TODO: Provide a pointer to the official documentation of those.
613
- ["DPPL", "DI", "DCA", "DCR", "RD", "DAR", "DRR", "AD", "CDDPL", "TE", "FT"].
647
+ ["`DPPL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dppl.html>`_"
648
+ , "`DI <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-di.html>`_",
649
+ "`DCA <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dca.html>`_",
650
+ "`DCR <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dcr.html>`_",
651
+ "`RD <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-rd.html>`_",
652
+ "`DAR <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-dar.html>`_",
653
+ "`DRR <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-drr.html>`_",
654
+ "`AD <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ad.html>`_",
655
+ "`CDDPL <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-cddpl.html>`_
656
+ ", "`TE <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-te.html>`_",
657
+ "`FT <https://docs.aws.amazon.com/sagemaker/latest/dg/clarify-post-training-bias-metric-ft.html>`_"].
614
658
Defaults to computing all.
615
659
wait (bool): Whether the call should wait until the job completes (default: True).
616
660
logs (bool): Whether to show the logs produced by the job.
617
661
Only meaningful when ``wait`` is True (default: True).
618
- job_name (str): Processing job name. If not specified, a name is composed of
619
- "Clarify-Bias" and current timestamp.
662
+ job_name (str): Processing job name. When ``job_name`` is not specified, if
663
+ ``job_name_prefix`` in :class:`SageMakerClarifyProcessor` specified, the job name
664
+ will be composed of ``job_name_prefix`` and current timestamp; otherwise use
665
+ "Clarify-Bias" as prefix.
620
666
kms_key (str): The ARN of the KMS key that is used to encrypt the
621
667
user code file (default: None).
622
668
experiment_config (dict[str, str]): Experiment management configuration.
@@ -641,7 +687,10 @@ def run_bias(
641
687
"post_training_bias" : {"methods" : post_training_methods },
642
688
}
643
689
if job_name is None :
644
- job_name = utils .name_from_base ("Clarify-Bias" )
690
+ if self .job_name_prefix :
691
+ job_name = utils .name_from_base (self .job_name_prefix )
692
+ else :
693
+ job_name = utils .name_from_base ("Clarify-Bias" )
645
694
self ._run (data_config , analysis_config , wait , logs , job_name , kms_key , experiment_config )
646
695
647
696
def run_explainability (
@@ -681,8 +730,10 @@ def run_explainability(
681
730
wait (bool): Whether the call should wait until the job completes (default: True).
682
731
logs (bool): Whether to show the logs produced by the job.
683
732
Only meaningful when ``wait`` is True (default: True).
684
- job_name (str): Processing job name. If not specified, a name is composed of
685
- "Clarify-Explainability" and current timestamp.
733
+ job_name (str): Processing job name. When ``job_name`` is not specified, if
734
+ ``job_name_prefix`` in :class:`SageMakerClarifyProcessor` specified, the job name
735
+ will be composed of ``job_name_prefix`` and current timestamp; otherwise use
736
+ "Clarify-Explainability" as prefix.
686
737
kms_key (str): The ARN of the KMS key that is used to encrypt the
687
738
user code file (default: None).
688
739
experiment_config (dict[str, str]): Experiment management configuration.
@@ -700,7 +751,10 @@ def run_explainability(
700
751
analysis_config ["methods" ] = explainability_config .get_explainability_config ()
701
752
analysis_config ["predictor" ] = predictor_config
702
753
if job_name is None :
703
- job_name = utils .name_from_base ("Clarify-Explainability" )
754
+ if self .job_name_prefix :
755
+ job_name = utils .name_from_base (self .job_name_prefix )
756
+ else :
757
+ job_name = utils .name_from_base ("Clarify-Explainability" )
704
758
self ._run (data_config , analysis_config , wait , logs , job_name , kms_key , experiment_config )
705
759
706
760
0 commit comments