Skip to content

feature: add joinsource to DataConfig #2718

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

Merged
merged 1 commit into from
Oct 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/sagemaker/clarify.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def __init__(
dataset_type="text/csv",
s3_data_distribution_type="FullyReplicated",
s3_compression_type="None",
joinsource=None,
):
"""Initializes a configuration of both input and output datasets.

Expand All @@ -57,6 +58,11 @@ def __init__(
s3_data_distribution_type (str): Valid options are "FullyReplicated" or
"ShardedByS3Key".
s3_compression_type (str): Valid options are "None" or "Gzip".
joinsource (str): The name or index of the column in the dataset that acts an
identifier column (for instance, while performing a join). This column is only
used as an identifier, and not used for any other computations. This is an
optional field in all cases except when the dataset contains more than one file,
and `save_local_shap_values` is set to true in SHAPConfig.
"""
if dataset_type not in ["text/csv", "application/jsonlines", "application/x-parquet"]:
raise ValueError(
Expand All @@ -77,6 +83,7 @@ def __init__(
_set(features, "features", self.analysis_config)
_set(headers, "headers", self.analysis_config)
_set(label, "label", self.analysis_config)
_set(joinsource, "joinsource_name_or_index", self.analysis_config)

def get_config(self):
"""Returns part of an analysis config dictionary."""
Expand Down
29 changes: 23 additions & 6 deletions tests/unit/test_clarify.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,9 @@ def data_config():
s3_data_input_path="s3://input/train.csv",
s3_output_path="s3://output/analysis_test_result",
label="Label",
headers=[
"Label",
"F1",
"F2",
"F3",
],
headers=["Label", "F1", "F2", "F3", "F4"],
dataset_type="text/csv",
joinsource="F4",
)


Expand Down Expand Up @@ -455,7 +451,9 @@ def test_pre_training_bias(
"F1",
"F2",
"F3",
"F4",
],
"joinsource_name_or_index": "F4",
"label": "Label",
"label_values_or_threshold": [1],
"facet": [{"name_or_index": "F1"}],
Expand Down Expand Up @@ -516,9 +514,11 @@ def test_post_training_bias(
"F1",
"F2",
"F3",
"F4",
],
"label": "Label",
"label_values_or_threshold": [1],
"joinsource_name_or_index": "F4",
"facet": [{"name_or_index": "F1"}],
"group_variable": "F2",
"methods": {"post_training_bias": {"methods": "all"}},
Expand Down Expand Up @@ -646,8 +646,25 @@ def _run_test_explain(
"F1",
"F2",
"F3",
"F4",
],
"label": "Label",
"joinsource_name_or_index": "F4",
"methods": {
"shap": {
"baseline": [
[
0.26124998927116394,
0.2824999988079071,
0.06875000149011612,
]
],
"num_samples": 100,
"agg_method": "mean_sq",
"use_logit": False,
"save_local_shap_values": True,
}
},
"predictor": expected_predictor_config,
}
expected_explanation_configs = {}
Expand Down