Skip to content

Added bias_and_explainability to SageMakerClarifyProcessor #3282

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

dosatos
Copy link
Contributor

@dosatos dosatos commented Aug 5, 2022

Issue #, if available:

Description of changes:
Added a public method to run both Bias and Explainability in a single job processing

Testing done:

Merge Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your pull request.

General

  • I have read the CONTRIBUTING doc
  • I certify that the changes I am introducing will be backword compatible, and I have discussed concerns about this, if any, with the Python SDK team
  • I used the commit message format described in CONTRIBUTING
  • I have passed the region in to all S3 and STS clients that I've initialized as part of this change.
  • I have updated any necessary documentation, including READMEs and API docs (if appropriate)

Tests

  • I have added tests that prove my fix is effective or that my feature works (if appropriate)
  • I have added unit and/or integration tests as appropriate to ensure backward compatibility of the changes
  • I have checked that my tests are not configured for a specific region or account (if appropriate)
  • I have used unique_name_from_base to create resource names in integ tests (if appropriate)

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@dosatos dosatos changed the title Clarify/bias and explainability api Added bias_and_explainability to SageMakerClarifyProcessor Aug 5, 2022
experiment_config,
)

def run_bias_and_explainability(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we see if we can override the existing run() method for this purpose?

Copy link
Contributor Author

@dosatos dosatos Aug 8, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that for run() we have different input schema

def run(
        self,
        inputs: Optional[List["ProcessingInput"]] = None,
        outputs: Optional[List["ProcessingOutput"]] = None,
        arguments: Optional[List[Union[str, PipelineVariable]]] = None,
        wait: bool = True,
        logs: bool = True,
        job_name: Optional[str] = None,
        experiment_config: Optional[Dict[str, str]] = None,
        kms_key: Optional[str] = None,
    ):

Signature of method 'SageMakerClarifyProcessor.run()' does not match signature of the base method in class 'Processor'

We could potentially expose the config generator, but I do not think that's improves customer experience. Let's leave everything as-is - the intetrace/arguments that the customer already knows

@dosatos dosatos force-pushed the clarify/bias_and_explainability_api branch 3 times, most recently from 49a596e to 8eb4b01 Compare August 8, 2022 15:49
@dosatos
Copy link
Contributor Author

dosatos commented Aug 8, 2022

I will apply formatting after the PR #3271 gets merged - it partially improves the style already

@dosatos dosatos force-pushed the clarify/bias_and_explainability_api branch from 8eb4b01 to 2bb714f Compare August 8, 2022 15:51
@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: 295fe83
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-slow-tests
  • Commit ID: 295fe83
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-local-mode-tests
  • Commit ID: 295fe83
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: 295fe83
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: 295fe83
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@dosatos dosatos force-pushed the clarify/bias_and_explainability_api branch 2 times, most recently from 3300f60 to 121ca9d Compare August 12, 2022 10:48
@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: d54f2bf
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@dosatos dosatos force-pushed the clarify/bias_and_explainability_api branch from d54f2bf to 5dcaca3 Compare August 12, 2022 10:55
@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: 5dcaca3
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-local-mode-tests
  • Commit ID: 5dcaca3
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: 5dcaca3
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: 5dcaca3
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@dosatos dosatos force-pushed the clarify/bias_and_explainability_api branch from 5dcaca3 to 4fa6f98 Compare August 12, 2022 12:33
@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: 4fa6f98
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@dosatos dosatos force-pushed the clarify/bias_and_explainability_api branch from 4fa6f98 to 67708bf Compare August 12, 2022 13:02
@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: 67708bf
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: 6f82a43
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: 6f82a43
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@dosatos dosatos force-pushed the clarify/bias_and_explainability_api branch from 6f82a43 to b2e72d6 Compare August 12, 2022 13:32
@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: b2e72d6
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@dosatos dosatos force-pushed the clarify/bias_and_explainability_api branch from b2e72d6 to 48131a5 Compare August 12, 2022 13:37
@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: 48131a5
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: fb6f568
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: fb6f568
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@dosatos dosatos force-pushed the clarify/bias_and_explainability_api branch 3 times, most recently from b323930 to 76eb325 Compare August 12, 2022 14:00
@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: 76eb325
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: 76eb325
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@dosatos dosatos force-pushed the clarify/bias_and_explainability_api branch from 76eb325 to 6fc02f4 Compare August 12, 2022 14:13
@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: 6fc02f4
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: 6fc02f4
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: 6fc02f4
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@codecov-commenter
Copy link

codecov-commenter commented Aug 12, 2022

Codecov Report

Merging #3282 (2dc3867) into master (38b4916) will decrease coverage by 0.35%.
The diff coverage is 96.03%.

@@            Coverage Diff             @@
##           master    #3282      +/-   ##
==========================================
- Coverage   89.40%   89.04%   -0.36%     
==========================================
  Files         848      203     -645     
  Lines       72563    18345   -54218     
==========================================
- Hits        64877    16336   -48541     
+ Misses       7686     2009    -5677     
Impacted Files Coverage Δ
src/sagemaker/jumpstart/types.py 94.37% <0.00%> (ø)
src/sagemaker/processing.py 94.33% <ø> (ø)
...agemaker/serverless/serverless_inference_config.py 100.00% <ø> (ø)
src/sagemaker/transformer.py 94.47% <ø> (ø)
src/sagemaker/workflow/step_collections.py 93.87% <ø> (ø)
src/sagemaker/job.py 90.00% <75.00%> (-0.55%) ⬇️
src/sagemaker/tensorflow/estimator.py 92.18% <75.00%> (-0.56%) ⬇️
src/sagemaker/estimator.py 89.24% <76.47%> (-0.35%) ⬇️
src/sagemaker/chainer/model.py 96.49% <88.88%> (-1.07%) ⬇️
src/sagemaker/mxnet/model.py 98.41% <90.00%> (+2.04%) ⬆️
... and 705 more

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-local-mode-tests
  • Commit ID: 6fc02f4
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-slow-tests
  • Commit ID: 6fc02f4
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

Copy link
Contributor

@larroy larroy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the change in general, minor issues.

model_predicted_label_config: ModelPredictedLabelConfig,
explainability_config: Union[ExplainabilityConfig, List[ExplainabilityConfig]],
bias_config: BiasConfig,
pre_training_methods: Union[str, List[str]] = "all",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a big fan of these Union types, I see the intention, but is it worth it to save the user typing [] ? I would prefer if it's a plain list and we check that is not empty. Open to discuss about this and be convinced of the opposite though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you saying that, instead of making the user to pass "all", we can make it ["all"]?
Actually, I did it this way to be consistent with the current implementation - i.e. with how we expose methods yet.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean explainability_config: Union[ExplainabilityConfig, List[ExplainabilityConfig]],

Copy link
Member

@keerthanvasist keerthanvasist Aug 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So it was initially only ExplainabilityConfig, and we only had SHAPConfig. But then we added PDPConfig, and we wanted to let customers be allowed to choose both of them in a single job. So, we made into List[ExplainabilityConfig] but also kept the original single ExplainabilityConfig as well to maintain backward compatibility.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this was like that and you just annotated the same type, thanks for catching up with this.

@shreyapandit
Copy link
Contributor

I have restarted PR and Local Mode tests, notebook failures are expected and I can override them. Please have 1 approval from @larroy or @keerthanvasist for us to be able to merge

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: 6fc02f4
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@dosatos dosatos force-pushed the clarify/bias_and_explainability_api branch from 6fc02f4 to 2dc3867 Compare August 16, 2022 09:46
@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-unit-tests
  • Commit ID: 2dc3867
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-local-mode-tests
  • Commit ID: 2dc3867
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-pr
  • Commit ID: 2dc3867
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-notebook-tests
  • Commit ID: 2dc3867
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@sagemaker-bot
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: sagemaker-python-sdk-slow-tests
  • Commit ID: 2dc3867
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

model_predicted_label_config: ModelPredictedLabelConfig,
explainability_config: Union[ExplainabilityConfig, List[ExplainabilityConfig]],
bias_config: BiasConfig,
pre_training_methods: Union[str, List[str]] = "all",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see this was like that and you just annotated the same type, thanks for catching up with this.

analysis_config, model_config, model_predicted_label_config
)
return analysis_config

@classmethod
def explainability(
cls,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to maintain consistency, can you use self instead of cls?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the comment, Keerthan.self implies creation of an instance, cls does not require an instance
This should also be driven by pep8.

@dosatos
Copy link
Contributor Author

dosatos commented Aug 18, 2022

The changes in this PR were also present in this one: #3296

Thus, cancelling the PR

@dosatos dosatos closed this Aug 18, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants