partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | const_shuffle | Shuffle an array in-place with a fixed seed. | shap/benchmark/measures.py | def const_shuffle(arr, seed=23980):
""" Shuffle an array in-place with a fixed seed.
"""
old_seed = np.random.seed()
np.random.seed(seed)
np.random.shuffle(arr)
np.random.seed(old_seed) | def const_shuffle(arr, seed=23980):
""" Shuffle an array in-place with a fixed seed.
"""
old_seed = np.random.seed()
np.random.seed(seed)
np.random.shuffle(arr)
np.random.seed(old_seed) | [
"Shuffle",
"an",
"array",
"in",
"-",
"place",
"with",
"a",
"fixed",
"seed",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/measures.py#L410-L416 | [
"def",
"const_shuffle",
"(",
"arr",
",",
"seed",
"=",
"23980",
")",
":",
"old_seed",
"=",
"np",
".",
"random",
".",
"seed",
"(",
")",
"np",
".",
"random",
".",
"seed",
"(",
"seed",
")",
"np",
".",
"random",
".",
"shuffle",
"(",
"arr",
")",
"np",
... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | MimicExplainer.shap_values | Estimate the SHAP values for a set of samples.
Parameters
----------
X : numpy.array or pandas.DataFrame
A matrix of samples (# samples x # features) on which to explain the model's output.
Returns
-------
For a models with a single output this returns a mat... | shap/explainers/mimic.py | def shap_values(self, X, **kwargs):
""" Estimate the SHAP values for a set of samples.
Parameters
----------
X : numpy.array or pandas.DataFrame
A matrix of samples (# samples x # features) on which to explain the model's output.
Returns
-------
For ... | def shap_values(self, X, **kwargs):
""" Estimate the SHAP values for a set of samples.
Parameters
----------
X : numpy.array or pandas.DataFrame
A matrix of samples (# samples x # features) on which to explain the model's output.
Returns
-------
For ... | [
"Estimate",
"the",
"SHAP",
"values",
"for",
"a",
"set",
"of",
"samples",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/mimic.py#L75-L102 | [
"def",
"shap_values",
"(",
"self",
",",
"X",
",",
"*",
"*",
"kwargs",
")",
":",
"phi",
"=",
"None",
"if",
"self",
".",
"mimic_model_type",
"==",
"\"xgboost\"",
":",
"if",
"not",
"str",
"(",
"type",
"(",
"X",
")",
")",
".",
"endswith",
"(",
"\"xgboo... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | image_plot | Plots SHAP values for image inputs. | shap/plots/image.py | def image_plot(shap_values, x, labels=None, show=True, width=20, aspect=0.2, hspace=0.2, labelpad=None):
""" Plots SHAP values for image inputs.
"""
multi_output = True
if type(shap_values) != list:
multi_output = False
shap_values = [shap_values]
# make sure labels
if labels i... | def image_plot(shap_values, x, labels=None, show=True, width=20, aspect=0.2, hspace=0.2, labelpad=None):
""" Plots SHAP values for image inputs.
"""
multi_output = True
if type(shap_values) != list:
multi_output = False
shap_values = [shap_values]
# make sure labels
if labels i... | [
"Plots",
"SHAP",
"values",
"for",
"image",
"inputs",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/plots/image.py#L10-L72 | [
"def",
"image_plot",
"(",
"shap_values",
",",
"x",
",",
"labels",
"=",
"None",
",",
"show",
"=",
"True",
",",
"width",
"=",
"20",
",",
"aspect",
"=",
"0.2",
",",
"hspace",
"=",
"0.2",
",",
"labelpad",
"=",
"None",
")",
":",
"multi_output",
"=",
"Tr... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | hclust_ordering | A leaf ordering is under-defined, this picks the ordering that keeps nearby samples similar. | shap/common.py | def hclust_ordering(X, metric="sqeuclidean"):
""" A leaf ordering is under-defined, this picks the ordering that keeps nearby samples similar.
"""
# compute a hierarchical clustering
D = sp.spatial.distance.pdist(X, metric)
cluster_matrix = sp.cluster.hierarchy.complete(D)
# merge clus... | def hclust_ordering(X, metric="sqeuclidean"):
""" A leaf ordering is under-defined, this picks the ordering that keeps nearby samples similar.
"""
# compute a hierarchical clustering
D = sp.spatial.distance.pdist(X, metric)
cluster_matrix = sp.cluster.hierarchy.complete(D)
# merge clus... | [
"A",
"leaf",
"ordering",
"is",
"under",
"-",
"defined",
"this",
"picks",
"the",
"ordering",
"that",
"keeps",
"nearby",
"samples",
"similar",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/common.py#L215-L247 | [
"def",
"hclust_ordering",
"(",
"X",
",",
"metric",
"=",
"\"sqeuclidean\"",
")",
":",
"# compute a hierarchical clustering",
"D",
"=",
"sp",
".",
"spatial",
".",
"distance",
".",
"pdist",
"(",
"X",
",",
"metric",
")",
"cluster_matrix",
"=",
"sp",
".",
"cluste... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | approximate_interactions | Order other features by how much interaction they seem to have with the feature at the given index.
This just bins the SHAP values for a feature along that feature's value. For true Shapley interaction
index values for SHAP see the interaction_contribs option implemented in XGBoost. | shap/common.py | def approximate_interactions(index, shap_values, X, feature_names=None):
""" Order other features by how much interaction they seem to have with the feature at the given index.
This just bins the SHAP values for a feature along that feature's value. For true Shapley interaction
index values for SHAP see th... | def approximate_interactions(index, shap_values, X, feature_names=None):
""" Order other features by how much interaction they seem to have with the feature at the given index.
This just bins the SHAP values for a feature along that feature's value. For true Shapley interaction
index values for SHAP see th... | [
"Order",
"other",
"features",
"by",
"how",
"much",
"interaction",
"they",
"seem",
"to",
"have",
"with",
"the",
"feature",
"at",
"the",
"given",
"index",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/common.py#L271-L318 | [
"def",
"approximate_interactions",
"(",
"index",
",",
"shap_values",
",",
"X",
",",
"feature_names",
"=",
"None",
")",
":",
"# convert from DataFrames if we got any",
"if",
"str",
"(",
"type",
"(",
"X",
")",
")",
".",
"endswith",
"(",
"\"'pandas.core.frame.DataFra... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | _human_score_map | Converts human agreement differences to numerical scores for coloring. | shap/benchmark/plots.py | def _human_score_map(human_consensus, methods_attrs):
""" Converts human agreement differences to numerical scores for coloring.
"""
v = 1 - min(np.sum(np.abs(methods_attrs - human_consensus)) / (np.abs(human_consensus).sum() + 1), 1.0)
return v | def _human_score_map(human_consensus, methods_attrs):
""" Converts human agreement differences to numerical scores for coloring.
"""
v = 1 - min(np.sum(np.abs(methods_attrs - human_consensus)) / (np.abs(human_consensus).sum() + 1), 1.0)
return v | [
"Converts",
"human",
"agreement",
"differences",
"to",
"numerical",
"scores",
"for",
"coloring",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/plots.py#L370-L375 | [
"def",
"_human_score_map",
"(",
"human_consensus",
",",
"methods_attrs",
")",
":",
"v",
"=",
"1",
"-",
"min",
"(",
"np",
".",
"sum",
"(",
"np",
".",
"abs",
"(",
"methods_attrs",
"-",
"human_consensus",
")",
")",
"/",
"(",
"np",
".",
"abs",
"(",
"huma... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | draw_bars | Draw the bars and separators. | shap/plots/force_matplotlib.py | def draw_bars(out_value, features, feature_type, width_separators, width_bar):
"""Draw the bars and separators."""
rectangle_list = []
separator_list = []
pre_val = out_value
for index, features in zip(range(len(features)), features):
if feature_type == 'positive':
left_boun... | def draw_bars(out_value, features, feature_type, width_separators, width_bar):
"""Draw the bars and separators."""
rectangle_list = []
separator_list = []
pre_val = out_value
for index, features in zip(range(len(features)), features):
if feature_type == 'positive':
left_boun... | [
"Draw",
"the",
"bars",
"and",
"separators",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/plots/force_matplotlib.py#L15-L77 | [
"def",
"draw_bars",
"(",
"out_value",
",",
"features",
",",
"feature_type",
",",
"width_separators",
",",
"width_bar",
")",
":",
"rectangle_list",
"=",
"[",
"]",
"separator_list",
"=",
"[",
"]",
"pre_val",
"=",
"out_value",
"for",
"index",
",",
"features",
"... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | format_data | Format data. | shap/plots/force_matplotlib.py | def format_data(data):
"""Format data."""
# Format negative features
neg_features = np.array([[data['features'][x]['effect'],
data['features'][x]['value'],
data['featureNames'][x]]
for x in data['features'].keys() if da... | def format_data(data):
"""Format data."""
# Format negative features
neg_features = np.array([[data['features'][x]['effect'],
data['features'][x]['value'],
data['featureNames'][x]]
for x in data['features'].keys() if da... | [
"Format",
"data",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/plots/force_matplotlib.py#L199-L253 | [
"def",
"format_data",
"(",
"data",
")",
":",
"# Format negative features",
"neg_features",
"=",
"np",
".",
"array",
"(",
"[",
"[",
"data",
"[",
"'features'",
"]",
"[",
"x",
"]",
"[",
"'effect'",
"]",
",",
"data",
"[",
"'features'",
"]",
"[",
"x",
"]",
... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | draw_additive_plot | Draw additive plot. | shap/plots/force_matplotlib.py | def draw_additive_plot(data, figsize, show, text_rotation=0):
"""Draw additive plot."""
# Turn off interactive plot
if show == False:
plt.ioff()
# Format data
neg_features, total_neg, pos_features, total_pos = format_data(data)
# Compute overall metrics
base_value = data['b... | def draw_additive_plot(data, figsize, show, text_rotation=0):
"""Draw additive plot."""
# Turn off interactive plot
if show == False:
plt.ioff()
# Format data
neg_features, total_neg, pos_features, total_pos = format_data(data)
# Compute overall metrics
base_value = data['b... | [
"Draw",
"additive",
"plot",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/plots/force_matplotlib.py#L333-L397 | [
"def",
"draw_additive_plot",
"(",
"data",
",",
"figsize",
",",
"show",
",",
"text_rotation",
"=",
"0",
")",
":",
"# Turn off interactive plot",
"if",
"show",
"==",
"False",
":",
"plt",
".",
"ioff",
"(",
")",
"# Format data",
"neg_features",
",",
"total_neg",
... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | try_run_setup | Fails gracefully when various install steps don't work. | setup.py | def try_run_setup(**kwargs):
""" Fails gracefully when various install steps don't work.
"""
try:
run_setup(**kwargs)
except Exception as e:
print(str(e))
if "xgboost" in str(e).lower():
kwargs["test_xgboost"] = False
print("Couldn't install XGBoost for t... | def try_run_setup(**kwargs):
""" Fails gracefully when various install steps don't work.
"""
try:
run_setup(**kwargs)
except Exception as e:
print(str(e))
if "xgboost" in str(e).lower():
kwargs["test_xgboost"] = False
print("Couldn't install XGBoost for t... | [
"Fails",
"gracefully",
"when",
"various",
"install",
"steps",
"don",
"t",
"work",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/setup.py#L101-L122 | [
"def",
"try_run_setup",
"(",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"run_setup",
"(",
"*",
"*",
"kwargs",
")",
"except",
"Exception",
"as",
"e",
":",
"print",
"(",
"str",
"(",
"e",
")",
")",
"if",
"\"xgboost\"",
"in",
"str",
"(",
"e",
")",
"."... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | deeplift_grad | The backward hook which computes the deeplift
gradient for an nn.Module | shap/explainers/deep/deep_pytorch.py | def deeplift_grad(module, grad_input, grad_output):
"""The backward hook which computes the deeplift
gradient for an nn.Module
"""
# first, get the module type
module_type = module.__class__.__name__
# first, check the module is supported
if module_type in op_handler:
if op_handler[m... | def deeplift_grad(module, grad_input, grad_output):
"""The backward hook which computes the deeplift
gradient for an nn.Module
"""
# first, get the module type
module_type = module.__class__.__name__
# first, check the module is supported
if module_type in op_handler:
if op_handler[m... | [
"The",
"backward",
"hook",
"which",
"computes",
"the",
"deeplift",
"gradient",
"for",
"an",
"nn",
".",
"Module"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/deep/deep_pytorch.py#L194-L206 | [
"def",
"deeplift_grad",
"(",
"module",
",",
"grad_input",
",",
"grad_output",
")",
":",
"# first, get the module type",
"module_type",
"=",
"module",
".",
"__class__",
".",
"__name__",
"# first, check the module is supported",
"if",
"module_type",
"in",
"op_handler",
":... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | add_interim_values | The forward hook used to save interim tensors, detached
from the graph. Used to calculate the multipliers | shap/explainers/deep/deep_pytorch.py | def add_interim_values(module, input, output):
"""The forward hook used to save interim tensors, detached
from the graph. Used to calculate the multipliers
"""
try:
del module.x
except AttributeError:
pass
try:
del module.y
except AttributeError:
pass
modu... | def add_interim_values(module, input, output):
"""The forward hook used to save interim tensors, detached
from the graph. Used to calculate the multipliers
"""
try:
del module.x
except AttributeError:
pass
try:
del module.y
except AttributeError:
pass
modu... | [
"The",
"forward",
"hook",
"used",
"to",
"save",
"interim",
"tensors",
"detached",
"from",
"the",
"graph",
".",
"Used",
"to",
"calculate",
"the",
"multipliers"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/deep/deep_pytorch.py#L209-L245 | [
"def",
"add_interim_values",
"(",
"module",
",",
"input",
",",
"output",
")",
":",
"try",
":",
"del",
"module",
".",
"x",
"except",
"AttributeError",
":",
"pass",
"try",
":",
"del",
"module",
".",
"y",
"except",
"AttributeError",
":",
"pass",
"module_type"... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | get_target_input | A forward hook which saves the tensor - attached to its graph.
Used if we want to explain the interim outputs of a model | shap/explainers/deep/deep_pytorch.py | def get_target_input(module, input, output):
"""A forward hook which saves the tensor - attached to its graph.
Used if we want to explain the interim outputs of a model
"""
try:
del module.target_input
except AttributeError:
pass
setattr(module, 'target_input', input) | def get_target_input(module, input, output):
"""A forward hook which saves the tensor - attached to its graph.
Used if we want to explain the interim outputs of a model
"""
try:
del module.target_input
except AttributeError:
pass
setattr(module, 'target_input', input) | [
"A",
"forward",
"hook",
"which",
"saves",
"the",
"tensor",
"-",
"attached",
"to",
"its",
"graph",
".",
"Used",
"if",
"we",
"want",
"to",
"explain",
"the",
"interim",
"outputs",
"of",
"a",
"model"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/deep/deep_pytorch.py#L248-L256 | [
"def",
"get_target_input",
"(",
"module",
",",
"input",
",",
"output",
")",
":",
"try",
":",
"del",
"module",
".",
"target_input",
"except",
"AttributeError",
":",
"pass",
"setattr",
"(",
"module",
",",
"'target_input'",
",",
"input",
")"
] | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | PyTorchDeepExplainer.add_handles | Add handles to all non-container layers in the model.
Recursively for non-container layers | shap/explainers/deep/deep_pytorch.py | def add_handles(self, model, forward_handle, backward_handle):
"""
Add handles to all non-container layers in the model.
Recursively for non-container layers
"""
handles_list = []
for child in model.children():
if 'nn.modules.container' in str(type(child)):
... | def add_handles(self, model, forward_handle, backward_handle):
"""
Add handles to all non-container layers in the model.
Recursively for non-container layers
"""
handles_list = []
for child in model.children():
if 'nn.modules.container' in str(type(child)):
... | [
"Add",
"handles",
"to",
"all",
"non",
"-",
"container",
"layers",
"in",
"the",
"model",
".",
"Recursively",
"for",
"non",
"-",
"container",
"layers"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/deep/deep_pytorch.py#L64-L76 | [
"def",
"add_handles",
"(",
"self",
",",
"model",
",",
"forward_handle",
",",
"backward_handle",
")",
":",
"handles_list",
"=",
"[",
"]",
"for",
"child",
"in",
"model",
".",
"children",
"(",
")",
":",
"if",
"'nn.modules.container'",
"in",
"str",
"(",
"type"... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | PyTorchDeepExplainer.remove_attributes | Removes the x and y attributes which were added by the forward handles
Recursively searches for non-container layers | shap/explainers/deep/deep_pytorch.py | def remove_attributes(self, model):
"""
Removes the x and y attributes which were added by the forward handles
Recursively searches for non-container layers
"""
for child in model.children():
if 'nn.modules.container' in str(type(child)):
self.remove_a... | def remove_attributes(self, model):
"""
Removes the x and y attributes which were added by the forward handles
Recursively searches for non-container layers
"""
for child in model.children():
if 'nn.modules.container' in str(type(child)):
self.remove_a... | [
"Removes",
"the",
"x",
"and",
"y",
"attributes",
"which",
"were",
"added",
"by",
"the",
"forward",
"handles",
"Recursively",
"searches",
"for",
"non",
"-",
"container",
"layers"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/deep/deep_pytorch.py#L78-L94 | [
"def",
"remove_attributes",
"(",
"self",
",",
"model",
")",
":",
"for",
"child",
"in",
"model",
".",
"children",
"(",
")",
":",
"if",
"'nn.modules.container'",
"in",
"str",
"(",
"type",
"(",
"child",
")",
")",
":",
"self",
".",
"remove_attributes",
"(",
... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | get_xgboost_json | This gets a JSON dump of an XGBoost model while ensuring the features names are their indexes. | shap/explainers/tree.py | def get_xgboost_json(model):
""" This gets a JSON dump of an XGBoost model while ensuring the features names are their indexes.
"""
fnames = model.feature_names
model.feature_names = None
json_trees = model.get_dump(with_stats=True, dump_format="json")
model.feature_names = fnames
# this fi... | def get_xgboost_json(model):
""" This gets a JSON dump of an XGBoost model while ensuring the features names are their indexes.
"""
fnames = model.feature_names
model.feature_names = None
json_trees = model.get_dump(with_stats=True, dump_format="json")
model.feature_names = fnames
# this fi... | [
"This",
"gets",
"a",
"JSON",
"dump",
"of",
"an",
"XGBoost",
"model",
"while",
"ensuring",
"the",
"features",
"names",
"are",
"their",
"indexes",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/tree.py#L907-L919 | [
"def",
"get_xgboost_json",
"(",
"model",
")",
":",
"fnames",
"=",
"model",
".",
"feature_names",
"model",
".",
"feature_names",
"=",
"None",
"json_trees",
"=",
"model",
".",
"get_dump",
"(",
"with_stats",
"=",
"True",
",",
"dump_format",
"=",
"\"json\"",
")"... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | TreeExplainer.__dynamic_expected_value | This computes the expected value conditioned on the given label value. | shap/explainers/tree.py | def __dynamic_expected_value(self, y):
""" This computes the expected value conditioned on the given label value.
"""
return self.model.predict(self.data, np.ones(self.data.shape[0]) * y, output=self.model_output).mean(0) | def __dynamic_expected_value(self, y):
""" This computes the expected value conditioned on the given label value.
"""
return self.model.predict(self.data, np.ones(self.data.shape[0]) * y, output=self.model_output).mean(0) | [
"This",
"computes",
"the",
"expected",
"value",
"conditioned",
"on",
"the",
"given",
"label",
"value",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/tree.py#L125-L129 | [
"def",
"__dynamic_expected_value",
"(",
"self",
",",
"y",
")",
":",
"return",
"self",
".",
"model",
".",
"predict",
"(",
"self",
".",
"data",
",",
"np",
".",
"ones",
"(",
"self",
".",
"data",
".",
"shape",
"[",
"0",
"]",
")",
"*",
"y",
",",
"outp... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | TreeExplainer.shap_values | Estimate the SHAP values for a set of samples.
Parameters
----------
X : numpy.array, pandas.DataFrame or catboost.Pool (for catboost)
A matrix of samples (# samples x # features) on which to explain the model's output.
y : numpy.array
An array of label values f... | shap/explainers/tree.py | def shap_values(self, X, y=None, tree_limit=None, approximate=False):
""" Estimate the SHAP values for a set of samples.
Parameters
----------
X : numpy.array, pandas.DataFrame or catboost.Pool (for catboost)
A matrix of samples (# samples x # features) on which to explain t... | def shap_values(self, X, y=None, tree_limit=None, approximate=False):
""" Estimate the SHAP values for a set of samples.
Parameters
----------
X : numpy.array, pandas.DataFrame or catboost.Pool (for catboost)
A matrix of samples (# samples x # features) on which to explain t... | [
"Estimate",
"the",
"SHAP",
"values",
"for",
"a",
"set",
"of",
"samples",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/tree.py#L131-L263 | [
"def",
"shap_values",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
",",
"tree_limit",
"=",
"None",
",",
"approximate",
"=",
"False",
")",
":",
"# see if we have a default tree_limit in place.",
"if",
"tree_limit",
"is",
"None",
":",
"tree_limit",
"=",
"-",
... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | TreeExplainer.shap_interaction_values | Estimate the SHAP interaction values for a set of samples.
Parameters
----------
X : numpy.array, pandas.DataFrame or catboost.Pool (for catboost)
A matrix of samples (# samples x # features) on which to explain the model's output.
y : numpy.array
An array of la... | shap/explainers/tree.py | def shap_interaction_values(self, X, y=None, tree_limit=None):
""" Estimate the SHAP interaction values for a set of samples.
Parameters
----------
X : numpy.array, pandas.DataFrame or catboost.Pool (for catboost)
A matrix of samples (# samples x # features) on which to expl... | def shap_interaction_values(self, X, y=None, tree_limit=None):
""" Estimate the SHAP interaction values for a set of samples.
Parameters
----------
X : numpy.array, pandas.DataFrame or catboost.Pool (for catboost)
A matrix of samples (# samples x # features) on which to expl... | [
"Estimate",
"the",
"SHAP",
"interaction",
"values",
"for",
"a",
"set",
"of",
"samples",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/tree.py#L265-L358 | [
"def",
"shap_interaction_values",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
",",
"tree_limit",
"=",
"None",
")",
":",
"assert",
"self",
".",
"model_output",
"==",
"\"margin\"",
",",
"\"Only model_output = \\\"margin\\\" is supported for SHAP interaction values right... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | TreeEnsemble.get_transform | A consistent interface to make predictions from this model. | shap/explainers/tree.py | def get_transform(self, model_output):
""" A consistent interface to make predictions from this model.
"""
if model_output == "margin":
transform = "identity"
elif model_output == "probability":
if self.tree_output == "log_odds":
transform = "logis... | def get_transform(self, model_output):
""" A consistent interface to make predictions from this model.
"""
if model_output == "margin":
transform = "identity"
elif model_output == "probability":
if self.tree_output == "log_odds":
transform = "logis... | [
"A",
"consistent",
"interface",
"to",
"make",
"predictions",
"from",
"this",
"model",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/tree.py#L633-L653 | [
"def",
"get_transform",
"(",
"self",
",",
"model_output",
")",
":",
"if",
"model_output",
"==",
"\"margin\"",
":",
"transform",
"=",
"\"identity\"",
"elif",
"model_output",
"==",
"\"probability\"",
":",
"if",
"self",
".",
"tree_output",
"==",
"\"log_odds\"",
":"... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | TreeEnsemble.predict | A consistent interface to make predictions from this model.
Parameters
----------
tree_limit : None (default) or int
Limit the number of trees used by the model. By default None means no use the limit of the
original model, and -1 means no limit. | shap/explainers/tree.py | def predict(self, X, y=None, output="margin", tree_limit=None):
""" A consistent interface to make predictions from this model.
Parameters
----------
tree_limit : None (default) or int
Limit the number of trees used by the model. By default None means no use the limit of th... | def predict(self, X, y=None, output="margin", tree_limit=None):
""" A consistent interface to make predictions from this model.
Parameters
----------
tree_limit : None (default) or int
Limit the number of trees used by the model. By default None means no use the limit of th... | [
"A",
"consistent",
"interface",
"to",
"make",
"predictions",
"from",
"this",
"model",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/tree.py#L655-L716 | [
"def",
"predict",
"(",
"self",
",",
"X",
",",
"y",
"=",
"None",
",",
"output",
"=",
"\"margin\"",
",",
"tree_limit",
"=",
"None",
")",
":",
"# see if we have a default tree_limit in place.",
"if",
"tree_limit",
"is",
"None",
":",
"tree_limit",
"=",
"-",
"1",... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | GradientExplainer.shap_values | Return the values for the model applied to X.
Parameters
----------
X : list,
if framework == 'tensorflow': numpy.array, or pandas.DataFrame
if framework == 'pytorch': torch.tensor
A tensor (or list of tensors) of samples (where X.shape[0] == # samples) on wh... | shap/explainers/gradient.py | def shap_values(self, X, nsamples=200, ranked_outputs=None, output_rank_order="max", rseed=None):
""" Return the values for the model applied to X.
Parameters
----------
X : list,
if framework == 'tensorflow': numpy.array, or pandas.DataFrame
if framework == 'pyt... | def shap_values(self, X, nsamples=200, ranked_outputs=None, output_rank_order="max", rseed=None):
""" Return the values for the model applied to X.
Parameters
----------
X : list,
if framework == 'tensorflow': numpy.array, or pandas.DataFrame
if framework == 'pyt... | [
"Return",
"the",
"values",
"for",
"the",
"model",
"applied",
"to",
"X",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/gradient.py#L75-L112 | [
"def",
"shap_values",
"(",
"self",
",",
"X",
",",
"nsamples",
"=",
"200",
",",
"ranked_outputs",
"=",
"None",
",",
"output_rank_order",
"=",
"\"max\"",
",",
"rseed",
"=",
"None",
")",
":",
"return",
"self",
".",
"explainer",
".",
"shap_values",
"(",
"X",... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | force_plot | Visualize the given SHAP values with an additive force layout.
Parameters
----------
base_value : float
This is the reference value that the feature contributions start from. For SHAP values it should
be the value of explainer.expected_value.
shap_values : numpy.array
Matri... | shap/plots/force.py | def force_plot(base_value, shap_values, features=None, feature_names=None, out_names=None, link="identity",
plot_cmap="RdBu", matplotlib=False, show=True, figsize=(20,3), ordering_keys=None, ordering_keys_time_format=None,
text_rotation=0):
""" Visualize the given SHAP values with an a... | def force_plot(base_value, shap_values, features=None, feature_names=None, out_names=None, link="identity",
plot_cmap="RdBu", matplotlib=False, show=True, figsize=(20,3), ordering_keys=None, ordering_keys_time_format=None,
text_rotation=0):
""" Visualize the given SHAP values with an a... | [
"Visualize",
"the",
"given",
"SHAP",
"values",
"with",
"an",
"additive",
"force",
"layout",
".",
"Parameters",
"----------",
"base_value",
":",
"float",
"This",
"is",
"the",
"reference",
"value",
"that",
"the",
"feature",
"contributions",
"start",
"from",
".",
... | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/plots/force.py#L27-L171 | [
"def",
"force_plot",
"(",
"base_value",
",",
"shap_values",
",",
"features",
"=",
"None",
",",
"feature_names",
"=",
"None",
",",
"out_names",
"=",
"None",
",",
"link",
"=",
"\"identity\"",
",",
"plot_cmap",
"=",
"\"RdBu\"",
",",
"matplotlib",
"=",
"False",
... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | save_html | Save html plots to an output file. | shap/plots/force.py | def save_html(out_file, plot_html):
""" Save html plots to an output file.
"""
internal_open = False
if type(out_file) == str:
out_file = open(out_file, "w")
internal_open = True
out_file.write("<html><head><script>\n")
# dump the js code
bundle_path = os.path.join(os.path.... | def save_html(out_file, plot_html):
""" Save html plots to an output file.
"""
internal_open = False
if type(out_file) == str:
out_file = open(out_file, "w")
internal_open = True
out_file.write("<html><head><script>\n")
# dump the js code
bundle_path = os.path.join(os.path.... | [
"Save",
"html",
"plots",
"to",
"an",
"output",
"file",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/plots/force.py#L217-L239 | [
"def",
"save_html",
"(",
"out_file",
",",
"plot_html",
")",
":",
"internal_open",
"=",
"False",
"if",
"type",
"(",
"out_file",
")",
"==",
"str",
":",
"out_file",
"=",
"open",
"(",
"out_file",
",",
"\"w\"",
")",
"internal_open",
"=",
"True",
"out_file",
"... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | tensors_blocked_by_false | Follows a set of ops assuming their value is False and find blocked Switch paths.
This is used to prune away parts of the model graph that are only used during the training
phase (like dropout, batch norm, etc.). | shap/explainers/deep/deep_tf.py | def tensors_blocked_by_false(ops):
""" Follows a set of ops assuming their value is False and find blocked Switch paths.
This is used to prune away parts of the model graph that are only used during the training
phase (like dropout, batch norm, etc.).
"""
blocked = []
def recurse(op):
i... | def tensors_blocked_by_false(ops):
""" Follows a set of ops assuming their value is False and find blocked Switch paths.
This is used to prune away parts of the model graph that are only used during the training
phase (like dropout, batch norm, etc.).
"""
blocked = []
def recurse(op):
i... | [
"Follows",
"a",
"set",
"of",
"ops",
"assuming",
"their",
"value",
"is",
"False",
"and",
"find",
"blocked",
"Switch",
"paths",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/deep/deep_tf.py#L290-L307 | [
"def",
"tensors_blocked_by_false",
"(",
"ops",
")",
":",
"blocked",
"=",
"[",
"]",
"def",
"recurse",
"(",
"op",
")",
":",
"if",
"op",
".",
"type",
"==",
"\"Switch\"",
":",
"blocked",
".",
"append",
"(",
"op",
".",
"outputs",
"[",
"1",
"]",
")",
"# ... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | softmax | Just decompose softmax into its components and recurse, we can handle all of them :)
We assume the 'axis' is the last dimension because the TF codebase swaps the 'axis' to
the last dimension before the softmax op if 'axis' is not already the last dimension.
We also don't subtract the max before tf.exp for ... | shap/explainers/deep/deep_tf.py | def softmax(explainer, op, *grads):
""" Just decompose softmax into its components and recurse, we can handle all of them :)
We assume the 'axis' is the last dimension because the TF codebase swaps the 'axis' to
the last dimension before the softmax op if 'axis' is not already the last dimension.
We al... | def softmax(explainer, op, *grads):
""" Just decompose softmax into its components and recurse, we can handle all of them :)
We assume the 'axis' is the last dimension because the TF codebase swaps the 'axis' to
the last dimension before the softmax op if 'axis' is not already the last dimension.
We al... | [
"Just",
"decompose",
"softmax",
"into",
"its",
"components",
"and",
"recurse",
"we",
"can",
"handle",
"all",
"of",
"them",
":",
")"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/deep/deep_tf.py#L335-L363 | [
"def",
"softmax",
"(",
"explainer",
",",
"op",
",",
"*",
"grads",
")",
":",
"in0",
"=",
"op",
".",
"inputs",
"[",
"0",
"]",
"in0_max",
"=",
"tf",
".",
"reduce_max",
"(",
"in0",
",",
"axis",
"=",
"-",
"1",
",",
"keepdims",
"=",
"True",
",",
"nam... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | TFDeepExplainer._variable_inputs | Return which inputs of this operation are variable (i.e. depend on the model inputs). | shap/explainers/deep/deep_tf.py | def _variable_inputs(self, op):
""" Return which inputs of this operation are variable (i.e. depend on the model inputs).
"""
if op.name not in self._vinputs:
self._vinputs[op.name] = np.array([t.op in self.between_ops or t in self.model_inputs for t in op.inputs])
return sel... | def _variable_inputs(self, op):
""" Return which inputs of this operation are variable (i.e. depend on the model inputs).
"""
if op.name not in self._vinputs:
self._vinputs[op.name] = np.array([t.op in self.between_ops or t in self.model_inputs for t in op.inputs])
return sel... | [
"Return",
"which",
"inputs",
"of",
"this",
"operation",
"are",
"variable",
"(",
"i",
".",
"e",
".",
"depend",
"on",
"the",
"model",
"inputs",
")",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/deep/deep_tf.py#L171-L176 | [
"def",
"_variable_inputs",
"(",
"self",
",",
"op",
")",
":",
"if",
"op",
".",
"name",
"not",
"in",
"self",
".",
"_vinputs",
":",
"self",
".",
"_vinputs",
"[",
"op",
".",
"name",
"]",
"=",
"np",
".",
"array",
"(",
"[",
"t",
".",
"op",
"in",
"sel... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | TFDeepExplainer.phi_symbolic | Get the SHAP value computation graph for a given model output. | shap/explainers/deep/deep_tf.py | def phi_symbolic(self, i):
""" Get the SHAP value computation graph for a given model output.
"""
if self.phi_symbolics[i] is None:
# replace the gradients for all the non-linear activations
# we do this by hacking our way into the registry (TODO: find a public API for t... | def phi_symbolic(self, i):
""" Get the SHAP value computation graph for a given model output.
"""
if self.phi_symbolics[i] is None:
# replace the gradients for all the non-linear activations
# we do this by hacking our way into the registry (TODO: find a public API for t... | [
"Get",
"the",
"SHAP",
"value",
"computation",
"graph",
"for",
"a",
"given",
"model",
"output",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/deep/deep_tf.py#L178-L214 | [
"def",
"phi_symbolic",
"(",
"self",
",",
"i",
")",
":",
"if",
"self",
".",
"phi_symbolics",
"[",
"i",
"]",
"is",
"None",
":",
"# replace the gradients for all the non-linear activations",
"# we do this by hacking our way into the registry (TODO: find a public API for this if it... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | TFDeepExplainer.run | Runs the model while also setting the learning phase flags to False. | shap/explainers/deep/deep_tf.py | def run(self, out, model_inputs, X):
""" Runs the model while also setting the learning phase flags to False.
"""
feed_dict = dict(zip(model_inputs, X))
for t in self.learning_phase_flags:
feed_dict[t] = False
return self.session.run(out, feed_dict) | def run(self, out, model_inputs, X):
""" Runs the model while also setting the learning phase flags to False.
"""
feed_dict = dict(zip(model_inputs, X))
for t in self.learning_phase_flags:
feed_dict[t] = False
return self.session.run(out, feed_dict) | [
"Runs",
"the",
"model",
"while",
"also",
"setting",
"the",
"learning",
"phase",
"flags",
"to",
"False",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/deep/deep_tf.py#L276-L282 | [
"def",
"run",
"(",
"self",
",",
"out",
",",
"model_inputs",
",",
"X",
")",
":",
"feed_dict",
"=",
"dict",
"(",
"zip",
"(",
"model_inputs",
",",
"X",
")",
")",
"for",
"t",
"in",
"self",
".",
"learning_phase_flags",
":",
"feed_dict",
"[",
"t",
"]",
"... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | TFDeepExplainer.custom_grad | Passes a gradient op creation request to the correct handler. | shap/explainers/deep/deep_tf.py | def custom_grad(self, op, *grads):
""" Passes a gradient op creation request to the correct handler.
"""
return op_handlers[op.type](self, op, *grads) | def custom_grad(self, op, *grads):
""" Passes a gradient op creation request to the correct handler.
"""
return op_handlers[op.type](self, op, *grads) | [
"Passes",
"a",
"gradient",
"op",
"creation",
"request",
"to",
"the",
"correct",
"handler",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/deep/deep_tf.py#L284-L287 | [
"def",
"custom_grad",
"(",
"self",
",",
"op",
",",
"*",
"grads",
")",
":",
"return",
"op_handlers",
"[",
"op",
".",
"type",
"]",
"(",
"self",
",",
"op",
",",
"*",
"grads",
")"
] | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | run_remote_experiments | Use ssh to run the experiments on remote machines in parallel.
Parameters
----------
experiments : iterable
Output of shap.benchmark.experiments(...).
thread_hosts : list of strings
Each host has the format "host_name:path_to_python_binary" and can appear multiple times
in the ... | shap/benchmark/experiments.py | def run_remote_experiments(experiments, thread_hosts, rate_limit=10):
""" Use ssh to run the experiments on remote machines in parallel.
Parameters
----------
experiments : iterable
Output of shap.benchmark.experiments(...).
thread_hosts : list of strings
Each host has the format "... | def run_remote_experiments(experiments, thread_hosts, rate_limit=10):
""" Use ssh to run the experiments on remote machines in parallel.
Parameters
----------
experiments : iterable
Output of shap.benchmark.experiments(...).
thread_hosts : list of strings
Each host has the format "... | [
"Use",
"ssh",
"to",
"run",
"the",
"experiments",
"on",
"remote",
"machines",
"in",
"parallel",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/experiments.py#L322-L372 | [
"def",
"run_remote_experiments",
"(",
"experiments",
",",
"thread_hosts",
",",
"rate_limit",
"=",
"10",
")",
":",
"global",
"ssh_conn_per_min_limit",
"ssh_conn_per_min_limit",
"=",
"rate_limit",
"# first we kill any remaining workers from previous runs",
"# note we don't check_ca... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | monitoring_plot | Create a SHAP monitoring plot.
(Note this function is preliminary and subject to change!!)
A SHAP monitoring plot is meant to display the behavior of a model
over time. Often the shap_values given to this plot explain the loss
of a model, so changes in a feature's impact on the model's loss over
... | shap/plots/monitoring.py | def monitoring_plot(ind, shap_values, features, feature_names=None):
""" Create a SHAP monitoring plot.
(Note this function is preliminary and subject to change!!)
A SHAP monitoring plot is meant to display the behavior of a model
over time. Often the shap_values given to this plot explain the loss... | def monitoring_plot(ind, shap_values, features, feature_names=None):
""" Create a SHAP monitoring plot.
(Note this function is preliminary and subject to change!!)
A SHAP monitoring plot is meant to display the behavior of a model
over time. Often the shap_values given to this plot explain the loss... | [
"Create",
"a",
"SHAP",
"monitoring",
"plot",
".",
"(",
"Note",
"this",
"function",
"is",
"preliminary",
"and",
"subject",
"to",
"change!!",
")",
"A",
"SHAP",
"monitoring",
"plot",
"is",
"meant",
"to",
"display",
"the",
"behavior",
"of",
"a",
"model",
"over... | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/plots/monitoring.py#L20-L78 | [
"def",
"monitoring_plot",
"(",
"ind",
",",
"shap_values",
",",
"features",
",",
"feature_names",
"=",
"None",
")",
":",
"if",
"str",
"(",
"type",
"(",
"features",
")",
")",
".",
"endswith",
"(",
"\"'pandas.core.frame.DataFrame'>\"",
")",
":",
"if",
"feature_... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | kmeans | Summarize a dataset with k mean samples weighted by the number of data points they
each represent.
Parameters
----------
X : numpy.array or pandas.DataFrame
Matrix of data samples to summarize (# samples x # features)
k : int
Number of means to use for approximation.
round_val... | shap/explainers/kernel.py | def kmeans(X, k, round_values=True):
""" Summarize a dataset with k mean samples weighted by the number of data points they
each represent.
Parameters
----------
X : numpy.array or pandas.DataFrame
Matrix of data samples to summarize (# samples x # features)
k : int
Number of m... | def kmeans(X, k, round_values=True):
""" Summarize a dataset with k mean samples weighted by the number of data points they
each represent.
Parameters
----------
X : numpy.array or pandas.DataFrame
Matrix of data samples to summarize (# samples x # features)
k : int
Number of m... | [
"Summarize",
"a",
"dataset",
"with",
"k",
"mean",
"samples",
"weighted",
"by",
"the",
"number",
"of",
"data",
"points",
"they",
"each",
"represent",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/kernel.py#L18-L50 | [
"def",
"kmeans",
"(",
"X",
",",
"k",
",",
"round_values",
"=",
"True",
")",
":",
"group_names",
"=",
"[",
"str",
"(",
"i",
")",
"for",
"i",
"in",
"range",
"(",
"X",
".",
"shape",
"[",
"1",
"]",
")",
"]",
"if",
"str",
"(",
"type",
"(",
"X",
... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | KernelExplainer.shap_values | Estimate the SHAP values for a set of samples.
Parameters
----------
X : numpy.array or pandas.DataFrame or any scipy.sparse matrix
A matrix of samples (# samples x # features) on which to explain the model's output.
nsamples : "auto" or int
Number of times to r... | shap/explainers/kernel.py | def shap_values(self, X, **kwargs):
""" Estimate the SHAP values for a set of samples.
Parameters
----------
X : numpy.array or pandas.DataFrame or any scipy.sparse matrix
A matrix of samples (# samples x # features) on which to explain the model's output.
nsamples ... | def shap_values(self, X, **kwargs):
""" Estimate the SHAP values for a set of samples.
Parameters
----------
X : numpy.array or pandas.DataFrame or any scipy.sparse matrix
A matrix of samples (# samples x # features) on which to explain the model's output.
nsamples ... | [
"Estimate",
"the",
"SHAP",
"values",
"for",
"a",
"set",
"of",
"samples",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/kernel.py#L132-L225 | [
"def",
"shap_values",
"(",
"self",
",",
"X",
",",
"*",
"*",
"kwargs",
")",
":",
"# convert dataframes",
"if",
"str",
"(",
"type",
"(",
"X",
")",
")",
".",
"endswith",
"(",
"\"pandas.core.series.Series'>\"",
")",
":",
"X",
"=",
"X",
".",
"values",
"elif... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | embedding_plot | Use the SHAP values as an embedding which we project to 2D for visualization.
Parameters
----------
ind : int or string
If this is an int it is the index of the feature to use to color the embedding.
If this is a string it is either the name of the feature, or it can have the
form "... | shap/plots/embedding.py | def embedding_plot(ind, shap_values, feature_names=None, method="pca", alpha=1.0, show=True):
""" Use the SHAP values as an embedding which we project to 2D for visualization.
Parameters
----------
ind : int or string
If this is an int it is the index of the feature to use to color the embeddin... | def embedding_plot(ind, shap_values, feature_names=None, method="pca", alpha=1.0, show=True):
""" Use the SHAP values as an embedding which we project to 2D for visualization.
Parameters
----------
ind : int or string
If this is an int it is the index of the feature to use to color the embeddin... | [
"Use",
"the",
"SHAP",
"values",
"as",
"an",
"embedding",
"which",
"we",
"project",
"to",
"2D",
"for",
"visualization",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/plots/embedding.py#L14-L78 | [
"def",
"embedding_plot",
"(",
"ind",
",",
"shap_values",
",",
"feature_names",
"=",
"None",
",",
"method",
"=",
"\"pca\"",
",",
"alpha",
"=",
"1.0",
",",
"show",
"=",
"True",
")",
":",
"if",
"feature_names",
"is",
"None",
":",
"feature_names",
"=",
"[",
... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | dependence_plot | Create a SHAP dependence plot, colored by an interaction feature.
Plots the value of the feature on the x-axis and the SHAP value of the same feature
on the y-axis. This shows how the model depends on the given feature, and is like a
richer extenstion of the classical parital dependence plots. Vertical dis... | shap/plots/dependence.py | def dependence_plot(ind, shap_values, features, feature_names=None, display_features=None,
interaction_index="auto",
color="#1E88E5", axis_color="#333333", cmap=colors.red_blue,
dot_size=16, x_jitter=0, alpha=1, title=None, xmin=None, xmax=None, show=True):
... | def dependence_plot(ind, shap_values, features, feature_names=None, display_features=None,
interaction_index="auto",
color="#1E88E5", axis_color="#333333", cmap=colors.red_blue,
dot_size=16, x_jitter=0, alpha=1, title=None, xmin=None, xmax=None, show=True):
... | [
"Create",
"a",
"SHAP",
"dependence",
"plot",
"colored",
"by",
"an",
"interaction",
"feature",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/plots/dependence.py#L15-L275 | [
"def",
"dependence_plot",
"(",
"ind",
",",
"shap_values",
",",
"features",
",",
"feature_names",
"=",
"None",
",",
"display_features",
"=",
"None",
",",
"interaction_index",
"=",
"\"auto\"",
",",
"color",
"=",
"\"#1E88E5\"",
",",
"axis_color",
"=",
"\"#333333\""... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | runtime | Runtime
transform = "negate"
sort_order = 1 | shap/benchmark/metrics.py | def runtime(X, y, model_generator, method_name):
""" Runtime
transform = "negate"
sort_order = 1
"""
old_seed = np.random.seed()
np.random.seed(3293)
# average the method scores over several train/test splits
method_reps = []
for i in range(1):
X_train, X_test, y_train, _ =... | def runtime(X, y, model_generator, method_name):
""" Runtime
transform = "negate"
sort_order = 1
"""
old_seed = np.random.seed()
np.random.seed(3293)
# average the method scores over several train/test splits
method_reps = []
for i in range(1):
X_train, X_test, y_train, _ =... | [
"Runtime",
"transform",
"=",
"negate",
"sort_order",
"=",
"1"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L22-L54 | [
"def",
"runtime",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
")",
":",
"old_seed",
"=",
"np",
".",
"random",
".",
"seed",
"(",
")",
"np",
".",
"random",
".",
"seed",
"(",
"3293",
")",
"# average the method scores over several train/test ... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | local_accuracy | Local Accuracy
transform = "identity"
sort_order = 2 | shap/benchmark/metrics.py | def local_accuracy(X, y, model_generator, method_name):
""" Local Accuracy
transform = "identity"
sort_order = 2
"""
def score_map(true, pred):
""" Converts local accuracy from % of standard deviation to numerical scores for coloring.
"""
v = min(1.0, np.std(pred - true) / ... | def local_accuracy(X, y, model_generator, method_name):
""" Local Accuracy
transform = "identity"
sort_order = 2
"""
def score_map(true, pred):
""" Converts local accuracy from % of standard deviation to numerical scores for coloring.
"""
v = min(1.0, np.std(pred - true) / ... | [
"Local",
"Accuracy",
"transform",
"=",
"identity",
"sort_order",
"=",
"2"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L56-L90 | [
"def",
"local_accuracy",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
")",
":",
"def",
"score_map",
"(",
"true",
",",
"pred",
")",
":",
"\"\"\" Converts local accuracy from % of standard deviation to numerical scores for coloring.\n \"\"\"",
"v",
... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | keep_negative_mask | Keep Negative (mask)
xlabel = "Max fraction of features kept"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 5 | shap/benchmark/metrics.py | def keep_negative_mask(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Negative (mask)
xlabel = "Max fraction of features kept"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 5
"""
return __run_measure(measures.keep_mask, X, y, model_generator, method_n... | def keep_negative_mask(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Negative (mask)
xlabel = "Max fraction of features kept"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 5
"""
return __run_measure(measures.keep_mask, X, y, model_generator, method_n... | [
"Keep",
"Negative",
"(",
"mask",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"kept",
"ylabel",
"=",
"Negative",
"mean",
"model",
"output",
"transform",
"=",
"negate",
"sort_order",
"=",
"5"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L135-L142 | [
"def",
"keep_negative_mask",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"keep_mask",
",",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name"... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | keep_absolute_mask__r2 | Keep Absolute (mask)
xlabel = "Max fraction of features kept"
ylabel = "R^2"
transform = "identity"
sort_order = 6 | shap/benchmark/metrics.py | def keep_absolute_mask__r2(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Absolute (mask)
xlabel = "Max fraction of features kept"
ylabel = "R^2"
transform = "identity"
sort_order = 6
"""
return __run_measure(measures.keep_mask, X, y, model_generator, method_name, 0, num_fcoun... | def keep_absolute_mask__r2(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Absolute (mask)
xlabel = "Max fraction of features kept"
ylabel = "R^2"
transform = "identity"
sort_order = 6
"""
return __run_measure(measures.keep_mask, X, y, model_generator, method_name, 0, num_fcoun... | [
"Keep",
"Absolute",
"(",
"mask",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"kept",
"ylabel",
"=",
"R^2",
"transform",
"=",
"identity",
"sort_order",
"=",
"6"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L144-L151 | [
"def",
"keep_absolute_mask__r2",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"keep_mask",
",",
"X",
",",
"y",
",",
"model_generator",
",",
"method_n... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | remove_positive_mask | Remove Positive (mask)
xlabel = "Max fraction of features removed"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 7 | shap/benchmark/metrics.py | def remove_positive_mask(X, y, model_generator, method_name, num_fcounts=11):
""" Remove Positive (mask)
xlabel = "Max fraction of features removed"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 7
"""
return __run_measure(measures.remove_mask, X, y, model_generator,... | def remove_positive_mask(X, y, model_generator, method_name, num_fcounts=11):
""" Remove Positive (mask)
xlabel = "Max fraction of features removed"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 7
"""
return __run_measure(measures.remove_mask, X, y, model_generator,... | [
"Remove",
"Positive",
"(",
"mask",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"removed",
"ylabel",
"=",
"Negative",
"mean",
"model",
"output",
"transform",
"=",
"negate",
"sort_order",
"=",
"7"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L162-L169 | [
"def",
"remove_positive_mask",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"remove_mask",
",",
"X",
",",
"y",
",",
"model_generator",
",",
"method_n... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | remove_absolute_mask__r2 | Remove Absolute (mask)
xlabel = "Max fraction of features removed"
ylabel = "1 - R^2"
transform = "one_minus"
sort_order = 9 | shap/benchmark/metrics.py | def remove_absolute_mask__r2(X, y, model_generator, method_name, num_fcounts=11):
""" Remove Absolute (mask)
xlabel = "Max fraction of features removed"
ylabel = "1 - R^2"
transform = "one_minus"
sort_order = 9
"""
return __run_measure(measures.remove_mask, X, y, model_generator, method_name... | def remove_absolute_mask__r2(X, y, model_generator, method_name, num_fcounts=11):
""" Remove Absolute (mask)
xlabel = "Max fraction of features removed"
ylabel = "1 - R^2"
transform = "one_minus"
sort_order = 9
"""
return __run_measure(measures.remove_mask, X, y, model_generator, method_name... | [
"Remove",
"Absolute",
"(",
"mask",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"removed",
"ylabel",
"=",
"1",
"-",
"R^2",
"transform",
"=",
"one_minus",
"sort_order",
"=",
"9"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L180-L187 | [
"def",
"remove_absolute_mask__r2",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"remove_mask",
",",
"X",
",",
"y",
",",
"model_generator",
",",
"meth... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | keep_negative_resample | Keep Negative (resample)
xlabel = "Max fraction of features kept"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 11 | shap/benchmark/metrics.py | def keep_negative_resample(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Negative (resample)
xlabel = "Max fraction of features kept"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 11
"""
return __run_measure(measures.keep_resample, X, y, model_genera... | def keep_negative_resample(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Negative (resample)
xlabel = "Max fraction of features kept"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 11
"""
return __run_measure(measures.keep_resample, X, y, model_genera... | [
"Keep",
"Negative",
"(",
"resample",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"kept",
"ylabel",
"=",
"Negative",
"mean",
"model",
"output",
"transform",
"=",
"negate",
"sort_order",
"=",
"11"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L207-L214 | [
"def",
"keep_negative_resample",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"keep_resample",
",",
"X",
",",
"y",
",",
"model_generator",
",",
"meth... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | keep_absolute_resample__r2 | Keep Absolute (resample)
xlabel = "Max fraction of features kept"
ylabel = "R^2"
transform = "identity"
sort_order = 12 | shap/benchmark/metrics.py | def keep_absolute_resample__r2(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Absolute (resample)
xlabel = "Max fraction of features kept"
ylabel = "R^2"
transform = "identity"
sort_order = 12
"""
return __run_measure(measures.keep_resample, X, y, model_generator, method_name,... | def keep_absolute_resample__r2(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Absolute (resample)
xlabel = "Max fraction of features kept"
ylabel = "R^2"
transform = "identity"
sort_order = 12
"""
return __run_measure(measures.keep_resample, X, y, model_generator, method_name,... | [
"Keep",
"Absolute",
"(",
"resample",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"kept",
"ylabel",
"=",
"R^2",
"transform",
"=",
"identity",
"sort_order",
"=",
"12"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L216-L223 | [
"def",
"keep_absolute_resample__r2",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"keep_resample",
",",
"X",
",",
"y",
",",
"model_generator",
",",
"... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | keep_absolute_resample__roc_auc | Keep Absolute (resample)
xlabel = "Max fraction of features kept"
ylabel = "ROC AUC"
transform = "identity"
sort_order = 12 | shap/benchmark/metrics.py | def keep_absolute_resample__roc_auc(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Absolute (resample)
xlabel = "Max fraction of features kept"
ylabel = "ROC AUC"
transform = "identity"
sort_order = 12
"""
return __run_measure(measures.keep_resample, X, y, model_generator, met... | def keep_absolute_resample__roc_auc(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Absolute (resample)
xlabel = "Max fraction of features kept"
ylabel = "ROC AUC"
transform = "identity"
sort_order = 12
"""
return __run_measure(measures.keep_resample, X, y, model_generator, met... | [
"Keep",
"Absolute",
"(",
"resample",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"kept",
"ylabel",
"=",
"ROC",
"AUC",
"transform",
"=",
"identity",
"sort_order",
"=",
"12"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L225-L232 | [
"def",
"keep_absolute_resample__roc_auc",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"keep_resample",
",",
"X",
",",
"y",
",",
"model_generator",
","... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | remove_positive_resample | Remove Positive (resample)
xlabel = "Max fraction of features removed"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 13 | shap/benchmark/metrics.py | def remove_positive_resample(X, y, model_generator, method_name, num_fcounts=11):
""" Remove Positive (resample)
xlabel = "Max fraction of features removed"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 13
"""
return __run_measure(measures.remove_resample, X, y, mod... | def remove_positive_resample(X, y, model_generator, method_name, num_fcounts=11):
""" Remove Positive (resample)
xlabel = "Max fraction of features removed"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 13
"""
return __run_measure(measures.remove_resample, X, y, mod... | [
"Remove",
"Positive",
"(",
"resample",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"removed",
"ylabel",
"=",
"Negative",
"mean",
"model",
"output",
"transform",
"=",
"negate",
"sort_order",
"=",
"13"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L234-L241 | [
"def",
"remove_positive_resample",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"remove_resample",
",",
"X",
",",
"y",
",",
"model_generator",
",",
"... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | remove_absolute_resample__r2 | Remove Absolute (resample)
xlabel = "Max fraction of features removed"
ylabel = "1 - R^2"
transform = "one_minus"
sort_order = 15 | shap/benchmark/metrics.py | def remove_absolute_resample__r2(X, y, model_generator, method_name, num_fcounts=11):
""" Remove Absolute (resample)
xlabel = "Max fraction of features removed"
ylabel = "1 - R^2"
transform = "one_minus"
sort_order = 15
"""
return __run_measure(measures.remove_resample, X, y, model_generator... | def remove_absolute_resample__r2(X, y, model_generator, method_name, num_fcounts=11):
""" Remove Absolute (resample)
xlabel = "Max fraction of features removed"
ylabel = "1 - R^2"
transform = "one_minus"
sort_order = 15
"""
return __run_measure(measures.remove_resample, X, y, model_generator... | [
"Remove",
"Absolute",
"(",
"resample",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"removed",
"ylabel",
"=",
"1",
"-",
"R^2",
"transform",
"=",
"one_minus",
"sort_order",
"=",
"15"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L252-L259 | [
"def",
"remove_absolute_resample__r2",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"remove_resample",
",",
"X",
",",
"y",
",",
"model_generator",
",",... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | remove_absolute_resample__roc_auc | Remove Absolute (resample)
xlabel = "Max fraction of features removed"
ylabel = "1 - ROC AUC"
transform = "one_minus"
sort_order = 15 | shap/benchmark/metrics.py | def remove_absolute_resample__roc_auc(X, y, model_generator, method_name, num_fcounts=11):
""" Remove Absolute (resample)
xlabel = "Max fraction of features removed"
ylabel = "1 - ROC AUC"
transform = "one_minus"
sort_order = 15
"""
return __run_measure(measures.remove_resample, X, y, model_... | def remove_absolute_resample__roc_auc(X, y, model_generator, method_name, num_fcounts=11):
""" Remove Absolute (resample)
xlabel = "Max fraction of features removed"
ylabel = "1 - ROC AUC"
transform = "one_minus"
sort_order = 15
"""
return __run_measure(measures.remove_resample, X, y, model_... | [
"Remove",
"Absolute",
"(",
"resample",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"removed",
"ylabel",
"=",
"1",
"-",
"ROC",
"AUC",
"transform",
"=",
"one_minus",
"sort_order",
"=",
"15"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L261-L268 | [
"def",
"remove_absolute_resample__roc_auc",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"remove_resample",
",",
"X",
",",
"y",
",",
"model_generator",
... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | keep_negative_impute | Keep Negative (impute)
xlabel = "Max fraction of features kept"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 17 | shap/benchmark/metrics.py | def keep_negative_impute(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Negative (impute)
xlabel = "Max fraction of features kept"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 17
"""
return __run_measure(measures.keep_impute, X, y, model_generator, m... | def keep_negative_impute(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Negative (impute)
xlabel = "Max fraction of features kept"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 17
"""
return __run_measure(measures.keep_impute, X, y, model_generator, m... | [
"Keep",
"Negative",
"(",
"impute",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"kept",
"ylabel",
"=",
"Negative",
"mean",
"model",
"output",
"transform",
"=",
"negate",
"sort_order",
"=",
"17"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L279-L286 | [
"def",
"keep_negative_impute",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"keep_impute",
",",
"X",
",",
"y",
",",
"model_generator",
",",
"method_n... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | keep_absolute_impute__r2 | Keep Absolute (impute)
xlabel = "Max fraction of features kept"
ylabel = "R^2"
transform = "identity"
sort_order = 18 | shap/benchmark/metrics.py | def keep_absolute_impute__r2(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Absolute (impute)
xlabel = "Max fraction of features kept"
ylabel = "R^2"
transform = "identity"
sort_order = 18
"""
return __run_measure(measures.keep_impute, X, y, model_generator, method_name, 0, nu... | def keep_absolute_impute__r2(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Absolute (impute)
xlabel = "Max fraction of features kept"
ylabel = "R^2"
transform = "identity"
sort_order = 18
"""
return __run_measure(measures.keep_impute, X, y, model_generator, method_name, 0, nu... | [
"Keep",
"Absolute",
"(",
"impute",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"kept",
"ylabel",
"=",
"R^2",
"transform",
"=",
"identity",
"sort_order",
"=",
"18"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L288-L295 | [
"def",
"keep_absolute_impute__r2",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"keep_impute",
",",
"X",
",",
"y",
",",
"model_generator",
",",
"meth... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | keep_absolute_impute__roc_auc | Keep Absolute (impute)
xlabel = "Max fraction of features kept"
ylabel = "ROC AUC"
transform = "identity"
sort_order = 19 | shap/benchmark/metrics.py | def keep_absolute_impute__roc_auc(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Absolute (impute)
xlabel = "Max fraction of features kept"
ylabel = "ROC AUC"
transform = "identity"
sort_order = 19
"""
return __run_measure(measures.keep_mask, X, y, model_generator, method_name... | def keep_absolute_impute__roc_auc(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Absolute (impute)
xlabel = "Max fraction of features kept"
ylabel = "ROC AUC"
transform = "identity"
sort_order = 19
"""
return __run_measure(measures.keep_mask, X, y, model_generator, method_name... | [
"Keep",
"Absolute",
"(",
"impute",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"kept",
"ylabel",
"=",
"ROC",
"AUC",
"transform",
"=",
"identity",
"sort_order",
"=",
"19"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L297-L304 | [
"def",
"keep_absolute_impute__roc_auc",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"keep_mask",
",",
"X",
",",
"y",
",",
"model_generator",
",",
"m... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | remove_positive_impute | Remove Positive (impute)
xlabel = "Max fraction of features removed"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 7 | shap/benchmark/metrics.py | def remove_positive_impute(X, y, model_generator, method_name, num_fcounts=11):
""" Remove Positive (impute)
xlabel = "Max fraction of features removed"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 7
"""
return __run_measure(measures.remove_impute, X, y, model_gene... | def remove_positive_impute(X, y, model_generator, method_name, num_fcounts=11):
""" Remove Positive (impute)
xlabel = "Max fraction of features removed"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 7
"""
return __run_measure(measures.remove_impute, X, y, model_gene... | [
"Remove",
"Positive",
"(",
"impute",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"removed",
"ylabel",
"=",
"Negative",
"mean",
"model",
"output",
"transform",
"=",
"negate",
"sort_order",
"=",
"7"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L306-L313 | [
"def",
"remove_positive_impute",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"remove_impute",
",",
"X",
",",
"y",
",",
"model_generator",
",",
"meth... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | remove_absolute_impute__r2 | Remove Absolute (impute)
xlabel = "Max fraction of features removed"
ylabel = "1 - R^2"
transform = "one_minus"
sort_order = 9 | shap/benchmark/metrics.py | def remove_absolute_impute__r2(X, y, model_generator, method_name, num_fcounts=11):
""" Remove Absolute (impute)
xlabel = "Max fraction of features removed"
ylabel = "1 - R^2"
transform = "one_minus"
sort_order = 9
"""
return __run_measure(measures.remove_impute, X, y, model_generator, metho... | def remove_absolute_impute__r2(X, y, model_generator, method_name, num_fcounts=11):
""" Remove Absolute (impute)
xlabel = "Max fraction of features removed"
ylabel = "1 - R^2"
transform = "one_minus"
sort_order = 9
"""
return __run_measure(measures.remove_impute, X, y, model_generator, metho... | [
"Remove",
"Absolute",
"(",
"impute",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"removed",
"ylabel",
"=",
"1",
"-",
"R^2",
"transform",
"=",
"one_minus",
"sort_order",
"=",
"9"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L324-L331 | [
"def",
"remove_absolute_impute__r2",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"remove_impute",
",",
"X",
",",
"y",
",",
"model_generator",
",",
"... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | remove_absolute_impute__roc_auc | Remove Absolute (impute)
xlabel = "Max fraction of features removed"
ylabel = "1 - ROC AUC"
transform = "one_minus"
sort_order = 9 | shap/benchmark/metrics.py | def remove_absolute_impute__roc_auc(X, y, model_generator, method_name, num_fcounts=11):
""" Remove Absolute (impute)
xlabel = "Max fraction of features removed"
ylabel = "1 - ROC AUC"
transform = "one_minus"
sort_order = 9
"""
return __run_measure(measures.remove_mask, X, y, model_generator... | def remove_absolute_impute__roc_auc(X, y, model_generator, method_name, num_fcounts=11):
""" Remove Absolute (impute)
xlabel = "Max fraction of features removed"
ylabel = "1 - ROC AUC"
transform = "one_minus"
sort_order = 9
"""
return __run_measure(measures.remove_mask, X, y, model_generator... | [
"Remove",
"Absolute",
"(",
"impute",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"removed",
"ylabel",
"=",
"1",
"-",
"ROC",
"AUC",
"transform",
"=",
"one_minus",
"sort_order",
"=",
"9"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L333-L340 | [
"def",
"remove_absolute_impute__roc_auc",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"remove_mask",
",",
"X",
",",
"y",
",",
"model_generator",
",",
... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | keep_negative_retrain | Keep Negative (retrain)
xlabel = "Max fraction of features kept"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 7 | shap/benchmark/metrics.py | def keep_negative_retrain(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Negative (retrain)
xlabel = "Max fraction of features kept"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 7
"""
return __run_measure(measures.keep_retrain, X, y, model_generator,... | def keep_negative_retrain(X, y, model_generator, method_name, num_fcounts=11):
""" Keep Negative (retrain)
xlabel = "Max fraction of features kept"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 7
"""
return __run_measure(measures.keep_retrain, X, y, model_generator,... | [
"Keep",
"Negative",
"(",
"retrain",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"kept",
"ylabel",
"=",
"Negative",
"mean",
"model",
"output",
"transform",
"=",
"negate",
"sort_order",
"=",
"7"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L351-L358 | [
"def",
"keep_negative_retrain",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"keep_retrain",
",",
"X",
",",
"y",
",",
"model_generator",
",",
"method... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | remove_positive_retrain | Remove Positive (retrain)
xlabel = "Max fraction of features removed"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 11 | shap/benchmark/metrics.py | def remove_positive_retrain(X, y, model_generator, method_name, num_fcounts=11):
""" Remove Positive (retrain)
xlabel = "Max fraction of features removed"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 11
"""
return __run_measure(measures.remove_retrain, X, y, model_... | def remove_positive_retrain(X, y, model_generator, method_name, num_fcounts=11):
""" Remove Positive (retrain)
xlabel = "Max fraction of features removed"
ylabel = "Negative mean model output"
transform = "negate"
sort_order = 11
"""
return __run_measure(measures.remove_retrain, X, y, model_... | [
"Remove",
"Positive",
"(",
"retrain",
")",
"xlabel",
"=",
"Max",
"fraction",
"of",
"features",
"removed",
"ylabel",
"=",
"Negative",
"mean",
"model",
"output",
"transform",
"=",
"negate",
"sort_order",
"=",
"11"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L360-L367 | [
"def",
"remove_positive_retrain",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_measure",
"(",
"measures",
".",
"remove_retrain",
",",
"X",
",",
"y",
",",
"model_generator",
",",
"me... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | batch_remove_absolute_retrain__r2 | Batch Remove Absolute (retrain)
xlabel = "Fraction of features removed"
ylabel = "1 - R^2"
transform = "one_minus"
sort_order = 13 | shap/benchmark/metrics.py | def batch_remove_absolute_retrain__r2(X, y, model_generator, method_name, num_fcounts=11):
""" Batch Remove Absolute (retrain)
xlabel = "Fraction of features removed"
ylabel = "1 - R^2"
transform = "one_minus"
sort_order = 13
"""
return __run_batch_abs_metric(measures.batch_remove_retrain, X... | def batch_remove_absolute_retrain__r2(X, y, model_generator, method_name, num_fcounts=11):
""" Batch Remove Absolute (retrain)
xlabel = "Fraction of features removed"
ylabel = "1 - R^2"
transform = "one_minus"
sort_order = 13
"""
return __run_batch_abs_metric(measures.batch_remove_retrain, X... | [
"Batch",
"Remove",
"Absolute",
"(",
"retrain",
")",
"xlabel",
"=",
"Fraction",
"of",
"features",
"removed",
"ylabel",
"=",
"1",
"-",
"R^2",
"transform",
"=",
"one_minus",
"sort_order",
"=",
"13"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L394-L401 | [
"def",
"batch_remove_absolute_retrain__r2",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_batch_abs_metric",
"(",
"measures",
".",
"batch_remove_retrain",
",",
"X",
",",
"y",
",",
"model... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | batch_keep_absolute_retrain__r2 | Batch Keep Absolute (retrain)
xlabel = "Fraction of features kept"
ylabel = "R^2"
transform = "identity"
sort_order = 13 | shap/benchmark/metrics.py | def batch_keep_absolute_retrain__r2(X, y, model_generator, method_name, num_fcounts=11):
""" Batch Keep Absolute (retrain)
xlabel = "Fraction of features kept"
ylabel = "R^2"
transform = "identity"
sort_order = 13
"""
return __run_batch_abs_metric(measures.batch_keep_retrain, X, y, model_gen... | def batch_keep_absolute_retrain__r2(X, y, model_generator, method_name, num_fcounts=11):
""" Batch Keep Absolute (retrain)
xlabel = "Fraction of features kept"
ylabel = "R^2"
transform = "identity"
sort_order = 13
"""
return __run_batch_abs_metric(measures.batch_keep_retrain, X, y, model_gen... | [
"Batch",
"Keep",
"Absolute",
"(",
"retrain",
")",
"xlabel",
"=",
"Fraction",
"of",
"features",
"kept",
"ylabel",
"=",
"R^2",
"transform",
"=",
"identity",
"sort_order",
"=",
"13"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L403-L410 | [
"def",
"batch_keep_absolute_retrain__r2",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_batch_abs_metric",
"(",
"measures",
".",
"batch_keep_retrain",
",",
"X",
",",
"y",
",",
"model_gen... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | batch_remove_absolute_retrain__roc_auc | Batch Remove Absolute (retrain)
xlabel = "Fraction of features removed"
ylabel = "1 - ROC AUC"
transform = "one_minus"
sort_order = 13 | shap/benchmark/metrics.py | def batch_remove_absolute_retrain__roc_auc(X, y, model_generator, method_name, num_fcounts=11):
""" Batch Remove Absolute (retrain)
xlabel = "Fraction of features removed"
ylabel = "1 - ROC AUC"
transform = "one_minus"
sort_order = 13
"""
return __run_batch_abs_metric(measures.batch_remove_r... | def batch_remove_absolute_retrain__roc_auc(X, y, model_generator, method_name, num_fcounts=11):
""" Batch Remove Absolute (retrain)
xlabel = "Fraction of features removed"
ylabel = "1 - ROC AUC"
transform = "one_minus"
sort_order = 13
"""
return __run_batch_abs_metric(measures.batch_remove_r... | [
"Batch",
"Remove",
"Absolute",
"(",
"retrain",
")",
"xlabel",
"=",
"Fraction",
"of",
"features",
"removed",
"ylabel",
"=",
"1",
"-",
"ROC",
"AUC",
"transform",
"=",
"one_minus",
"sort_order",
"=",
"13"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L412-L419 | [
"def",
"batch_remove_absolute_retrain__roc_auc",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_batch_abs_metric",
"(",
"measures",
".",
"batch_remove_retrain",
",",
"X",
",",
"y",
",",
"... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | batch_keep_absolute_retrain__roc_auc | Batch Keep Absolute (retrain)
xlabel = "Fraction of features kept"
ylabel = "ROC AUC"
transform = "identity"
sort_order = 13 | shap/benchmark/metrics.py | def batch_keep_absolute_retrain__roc_auc(X, y, model_generator, method_name, num_fcounts=11):
""" Batch Keep Absolute (retrain)
xlabel = "Fraction of features kept"
ylabel = "ROC AUC"
transform = "identity"
sort_order = 13
"""
return __run_batch_abs_metric(measures.batch_keep_retrain, X, y, ... | def batch_keep_absolute_retrain__roc_auc(X, y, model_generator, method_name, num_fcounts=11):
""" Batch Keep Absolute (retrain)
xlabel = "Fraction of features kept"
ylabel = "ROC AUC"
transform = "identity"
sort_order = 13
"""
return __run_batch_abs_metric(measures.batch_keep_retrain, X, y, ... | [
"Batch",
"Keep",
"Absolute",
"(",
"retrain",
")",
"xlabel",
"=",
"Fraction",
"of",
"features",
"kept",
"ylabel",
"=",
"ROC",
"AUC",
"transform",
"=",
"identity",
"sort_order",
"=",
"13"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L421-L428 | [
"def",
"batch_keep_absolute_retrain__roc_auc",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
",",
"num_fcounts",
"=",
"11",
")",
":",
"return",
"__run_batch_abs_metric",
"(",
"measures",
".",
"batch_keep_retrain",
",",
"X",
",",
"y",
",",
"mode... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | __score_method | Test an explanation method. | shap/benchmark/metrics.py | def __score_method(X, y, fcounts, model_generator, score_function, method_name, nreps=10, test_size=100, cache_dir="/tmp"):
""" Test an explanation method.
"""
old_seed = np.random.seed()
np.random.seed(3293)
# average the method scores over several train/test splits
method_reps = []
data... | def __score_method(X, y, fcounts, model_generator, score_function, method_name, nreps=10, test_size=100, cache_dir="/tmp"):
""" Test an explanation method.
"""
old_seed = np.random.seed()
np.random.seed(3293)
# average the method scores over several train/test splits
method_reps = []
data... | [
"Test",
"an",
"explanation",
"method",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L446-L495 | [
"def",
"__score_method",
"(",
"X",
",",
"y",
",",
"fcounts",
",",
"model_generator",
",",
"score_function",
",",
"method_name",
",",
"nreps",
"=",
"10",
",",
"test_size",
"=",
"100",
",",
"cache_dir",
"=",
"\"/tmp\"",
")",
":",
"old_seed",
"=",
"np",
"."... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | human_and_00 | AND (false/false)
This tests how well a feature attribution method agrees with human intuition
for an AND operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
... | shap/benchmark/metrics.py | def human_and_00(X, y, model_generator, method_name):
""" AND (false/false)
This tests how well a feature attribution method agrees with human intuition
for an AND operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
... | def human_and_00(X, y, model_generator, method_name):
""" AND (false/false)
This tests how well a feature attribution method agrees with human intuition
for an AND operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
... | [
"AND",
"(",
"false",
"/",
"false",
")"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L578-L592 | [
"def",
"human_and_00",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
")",
":",
"return",
"_human_and",
"(",
"X",
",",
"model_generator",
",",
"method_name",
",",
"False",
",",
"False",
")"
] | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | human_and_01 | AND (false/true)
This tests how well a feature attribution method agrees with human intuition
for an AND operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
i... | shap/benchmark/metrics.py | def human_and_01(X, y, model_generator, method_name):
""" AND (false/true)
This tests how well a feature attribution method agrees with human intuition
for an AND operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
... | def human_and_01(X, y, model_generator, method_name):
""" AND (false/true)
This tests how well a feature attribution method agrees with human intuition
for an AND operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
... | [
"AND",
"(",
"false",
"/",
"true",
")"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L594-L608 | [
"def",
"human_and_01",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
")",
":",
"return",
"_human_and",
"(",
"X",
",",
"model_generator",
",",
"method_name",
",",
"False",
",",
"True",
")"
] | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | human_and_11 | AND (true/true)
This tests how well a feature attribution method agrees with human intuition
for an AND operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if... | shap/benchmark/metrics.py | def human_and_11(X, y, model_generator, method_name):
""" AND (true/true)
This tests how well a feature attribution method agrees with human intuition
for an AND operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
... | def human_and_11(X, y, model_generator, method_name):
""" AND (true/true)
This tests how well a feature attribution method agrees with human intuition
for an AND operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
... | [
"AND",
"(",
"true",
"/",
"true",
")"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L610-L624 | [
"def",
"human_and_11",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
")",
":",
"return",
"_human_and",
"(",
"X",
",",
"model_generator",
",",
"method_name",
",",
"True",
",",
"True",
")"
] | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | human_or_00 | OR (false/false)
This tests how well a feature attribution method agrees with human intuition
for an OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if... | shap/benchmark/metrics.py | def human_or_00(X, y, model_generator, method_name):
""" OR (false/false)
This tests how well a feature attribution method agrees with human intuition
for an OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
w... | def human_or_00(X, y, model_generator, method_name):
""" OR (false/false)
This tests how well a feature attribution method agrees with human intuition
for an OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
w... | [
"OR",
"(",
"false",
"/",
"false",
")"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L649-L663 | [
"def",
"human_or_00",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
")",
":",
"return",
"_human_or",
"(",
"X",
",",
"model_generator",
",",
"method_name",
",",
"False",
",",
"False",
")"
] | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | human_or_01 | OR (false/true)
This tests how well a feature attribution method agrees with human intuition
for an OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if ... | shap/benchmark/metrics.py | def human_or_01(X, y, model_generator, method_name):
""" OR (false/true)
This tests how well a feature attribution method agrees with human intuition
for an OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
wh... | def human_or_01(X, y, model_generator, method_name):
""" OR (false/true)
This tests how well a feature attribution method agrees with human intuition
for an OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
wh... | [
"OR",
"(",
"false",
"/",
"true",
")"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L665-L679 | [
"def",
"human_or_01",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
")",
":",
"return",
"_human_or",
"(",
"X",
",",
"model_generator",
",",
"method_name",
",",
"False",
",",
"True",
")"
] | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | human_or_11 | OR (true/true)
This tests how well a feature attribution method agrees with human intuition
for an OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if c... | shap/benchmark/metrics.py | def human_or_11(X, y, model_generator, method_name):
""" OR (true/true)
This tests how well a feature attribution method agrees with human intuition
for an OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
whe... | def human_or_11(X, y, model_generator, method_name):
""" OR (true/true)
This tests how well a feature attribution method agrees with human intuition
for an OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
whe... | [
"OR",
"(",
"true",
"/",
"true",
")"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L681-L695 | [
"def",
"human_or_11",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
")",
":",
"return",
"_human_or",
"(",
"X",
",",
"model_generator",
",",
"method_name",
",",
"True",
",",
"True",
")"
] | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | human_xor_00 | XOR (false/false)
This tests how well a feature attribution method agrees with human intuition
for an eXclusive OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 po... | shap/benchmark/metrics.py | def human_xor_00(X, y, model_generator, method_name):
""" XOR (false/false)
This tests how well a feature attribution method agrees with human intuition
for an eXclusive OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following fu... | def human_xor_00(X, y, model_generator, method_name):
""" XOR (false/false)
This tests how well a feature attribution method agrees with human intuition
for an eXclusive OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following fu... | [
"XOR",
"(",
"false",
"/",
"false",
")"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L720-L734 | [
"def",
"human_xor_00",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
")",
":",
"return",
"_human_xor",
"(",
"X",
",",
"model_generator",
",",
"method_name",
",",
"False",
",",
"False",
")"
] | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | human_xor_01 | XOR (false/true)
This tests how well a feature attribution method agrees with human intuition
for an eXclusive OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 poi... | shap/benchmark/metrics.py | def human_xor_01(X, y, model_generator, method_name):
""" XOR (false/true)
This tests how well a feature attribution method agrees with human intuition
for an eXclusive OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following fun... | def human_xor_01(X, y, model_generator, method_name):
""" XOR (false/true)
This tests how well a feature attribution method agrees with human intuition
for an eXclusive OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following fun... | [
"XOR",
"(",
"false",
"/",
"true",
")"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L736-L750 | [
"def",
"human_xor_01",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
")",
":",
"return",
"_human_xor",
"(",
"X",
",",
"model_generator",
",",
"method_name",
",",
"False",
",",
"True",
")"
] | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | human_xor_11 | XOR (true/true)
This tests how well a feature attribution method agrees with human intuition
for an eXclusive OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 poin... | shap/benchmark/metrics.py | def human_xor_11(X, y, model_generator, method_name):
""" XOR (true/true)
This tests how well a feature attribution method agrees with human intuition
for an eXclusive OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following func... | def human_xor_11(X, y, model_generator, method_name):
""" XOR (true/true)
This tests how well a feature attribution method agrees with human intuition
for an eXclusive OR operation combined with linear effects. This metric deals
specifically with the question of credit allocation for the following func... | [
"XOR",
"(",
"true",
"/",
"true",
")"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L752-L766 | [
"def",
"human_xor_11",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
")",
":",
"return",
"_human_xor",
"(",
"X",
",",
"model_generator",
",",
"method_name",
",",
"True",
",",
"True",
")"
] | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | human_sum_00 | SUM (false/false)
This tests how well a feature attribution method agrees with human intuition
for a SUM operation. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if cough: +2 points
trans... | shap/benchmark/metrics.py | def human_sum_00(X, y, model_generator, method_name):
""" SUM (false/false)
This tests how well a feature attribution method agrees with human intuition
for a SUM operation. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are tr... | def human_sum_00(X, y, model_generator, method_name):
""" SUM (false/false)
This tests how well a feature attribution method agrees with human intuition
for a SUM operation. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are tr... | [
"SUM",
"(",
"false",
"/",
"false",
")"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L791-L804 | [
"def",
"human_sum_00",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
")",
":",
"return",
"_human_sum",
"(",
"X",
",",
"model_generator",
",",
"method_name",
",",
"False",
",",
"False",
")"
] | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | human_sum_01 | SUM (false/true)
This tests how well a feature attribution method agrees with human intuition
for a SUM operation. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if cough: +2 points
transf... | shap/benchmark/metrics.py | def human_sum_01(X, y, model_generator, method_name):
""" SUM (false/true)
This tests how well a feature attribution method agrees with human intuition
for a SUM operation. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are tru... | def human_sum_01(X, y, model_generator, method_name):
""" SUM (false/true)
This tests how well a feature attribution method agrees with human intuition
for a SUM operation. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are tru... | [
"SUM",
"(",
"false",
"/",
"true",
")"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L806-L819 | [
"def",
"human_sum_01",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
")",
":",
"return",
"_human_sum",
"(",
"X",
",",
"model_generator",
",",
"method_name",
",",
"False",
",",
"True",
")"
] | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | human_sum_11 | SUM (true/true)
This tests how well a feature attribution method agrees with human intuition
for a SUM operation. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true:
if fever: +2 points
if cough: +2 points
transfo... | shap/benchmark/metrics.py | def human_sum_11(X, y, model_generator, method_name):
""" SUM (true/true)
This tests how well a feature attribution method agrees with human intuition
for a SUM operation. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true... | def human_sum_11(X, y, model_generator, method_name):
""" SUM (true/true)
This tests how well a feature attribution method agrees with human intuition
for a SUM operation. This metric deals
specifically with the question of credit allocation for the following function
when all three inputs are true... | [
"SUM",
"(",
"true",
"/",
"true",
")"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/metrics.py#L821-L834 | [
"def",
"human_sum_11",
"(",
"X",
",",
"y",
",",
"model_generator",
",",
"method_name",
")",
":",
"return",
"_human_sum",
"(",
"X",
",",
"model_generator",
",",
"method_name",
",",
"True",
",",
"True",
")"
] | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | LinearExplainer._estimate_transforms | Uses block matrix inversion identities to quickly estimate transforms.
After a bit of matrix math we can isolate a transform matrix (# features x # features)
that is independent of any sample we are explaining. It is the result of averaging over
all feature permutations, but we just use a fixed... | shap/explainers/linear.py | def _estimate_transforms(self, nsamples):
""" Uses block matrix inversion identities to quickly estimate transforms.
After a bit of matrix math we can isolate a transform matrix (# features x # features)
that is independent of any sample we are explaining. It is the result of averaging over
... | def _estimate_transforms(self, nsamples):
""" Uses block matrix inversion identities to quickly estimate transforms.
After a bit of matrix math we can isolate a transform matrix (# features x # features)
that is independent of any sample we are explaining. It is the result of averaging over
... | [
"Uses",
"block",
"matrix",
"inversion",
"identities",
"to",
"quickly",
"estimate",
"transforms",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/linear.py#L113-L175 | [
"def",
"_estimate_transforms",
"(",
"self",
",",
"nsamples",
")",
":",
"M",
"=",
"len",
"(",
"self",
".",
"coef",
")",
"mean_transform",
"=",
"np",
".",
"zeros",
"(",
"(",
"M",
",",
"M",
")",
")",
"x_transform",
"=",
"np",
".",
"zeros",
"(",
"(",
... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | LinearExplainer.shap_values | Estimate the SHAP values for a set of samples.
Parameters
----------
X : numpy.array or pandas.DataFrame
A matrix of samples (# samples x # features) on which to explain the model's output.
Returns
-------
For models with a single output this returns a matri... | shap/explainers/linear.py | def shap_values(self, X):
""" Estimate the SHAP values for a set of samples.
Parameters
----------
X : numpy.array or pandas.DataFrame
A matrix of samples (# samples x # features) on which to explain the model's output.
Returns
-------
For models wit... | def shap_values(self, X):
""" Estimate the SHAP values for a set of samples.
Parameters
----------
X : numpy.array or pandas.DataFrame
A matrix of samples (# samples x # features) on which to explain the model's output.
Returns
-------
For models wit... | [
"Estimate",
"the",
"SHAP",
"values",
"for",
"a",
"set",
"of",
"samples",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/linear.py#L177-L215 | [
"def",
"shap_values",
"(",
"self",
",",
"X",
")",
":",
"# convert dataframes",
"if",
"str",
"(",
"type",
"(",
"X",
")",
")",
".",
"endswith",
"(",
"\"pandas.core.series.Series'>\"",
")",
":",
"X",
"=",
"X",
".",
"values",
"elif",
"str",
"(",
"type",
"(... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | independentlinear60__ffnn | 4-Layer Neural Network | shap/benchmark/models.py | def independentlinear60__ffnn():
""" 4-Layer Neural Network
"""
from keras.models import Sequential
from keras.layers import Dense
model = Sequential()
model.add(Dense(32, activation='relu', input_dim=60))
model.add(Dense(20, activation='relu'))
model.add(Dense(20, activation='relu'))
... | def independentlinear60__ffnn():
""" 4-Layer Neural Network
"""
from keras.models import Sequential
from keras.layers import Dense
model = Sequential()
model.add(Dense(32, activation='relu', input_dim=60))
model.add(Dense(20, activation='relu'))
model.add(Dense(20, activation='relu'))
... | [
"4",
"-",
"Layer",
"Neural",
"Network"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/models.py#L114-L130 | [
"def",
"independentlinear60__ffnn",
"(",
")",
":",
"from",
"keras",
".",
"models",
"import",
"Sequential",
"from",
"keras",
".",
"layers",
"import",
"Dense",
"model",
"=",
"Sequential",
"(",
")",
"model",
".",
"add",
"(",
"Dense",
"(",
"32",
",",
"activati... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | cric__lasso | Lasso Regression | shap/benchmark/models.py | def cric__lasso():
""" Lasso Regression
"""
model = sklearn.linear_model.LogisticRegression(penalty="l1", C=0.002)
# we want to explain the raw probability outputs of the trees
model.predict = lambda X: model.predict_proba(X)[:,1]
return model | def cric__lasso():
""" Lasso Regression
"""
model = sklearn.linear_model.LogisticRegression(penalty="l1", C=0.002)
# we want to explain the raw probability outputs of the trees
model.predict = lambda X: model.predict_proba(X)[:,1]
return model | [
"Lasso",
"Regression"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/models.py#L133-L141 | [
"def",
"cric__lasso",
"(",
")",
":",
"model",
"=",
"sklearn",
".",
"linear_model",
".",
"LogisticRegression",
"(",
"penalty",
"=",
"\"l1\"",
",",
"C",
"=",
"0.002",
")",
"# we want to explain the raw probability outputs of the trees",
"model",
".",
"predict",
"=",
... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | cric__ridge | Ridge Regression | shap/benchmark/models.py | def cric__ridge():
""" Ridge Regression
"""
model = sklearn.linear_model.LogisticRegression(penalty="l2")
# we want to explain the raw probability outputs of the trees
model.predict = lambda X: model.predict_proba(X)[:,1]
return model | def cric__ridge():
""" Ridge Regression
"""
model = sklearn.linear_model.LogisticRegression(penalty="l2")
# we want to explain the raw probability outputs of the trees
model.predict = lambda X: model.predict_proba(X)[:,1]
return model | [
"Ridge",
"Regression"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/models.py#L143-L151 | [
"def",
"cric__ridge",
"(",
")",
":",
"model",
"=",
"sklearn",
".",
"linear_model",
".",
"LogisticRegression",
"(",
"penalty",
"=",
"\"l2\"",
")",
"# we want to explain the raw probability outputs of the trees",
"model",
".",
"predict",
"=",
"lambda",
"X",
":",
"mode... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | cric__decision_tree | Decision Tree | shap/benchmark/models.py | def cric__decision_tree():
""" Decision Tree
"""
model = sklearn.tree.DecisionTreeClassifier(random_state=0, max_depth=4)
# we want to explain the raw probability outputs of the trees
model.predict = lambda X: model.predict_proba(X)[:,1]
return model | def cric__decision_tree():
""" Decision Tree
"""
model = sklearn.tree.DecisionTreeClassifier(random_state=0, max_depth=4)
# we want to explain the raw probability outputs of the trees
model.predict = lambda X: model.predict_proba(X)[:,1]
return model | [
"Decision",
"Tree"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/models.py#L153-L161 | [
"def",
"cric__decision_tree",
"(",
")",
":",
"model",
"=",
"sklearn",
".",
"tree",
".",
"DecisionTreeClassifier",
"(",
"random_state",
"=",
"0",
",",
"max_depth",
"=",
"4",
")",
"# we want to explain the raw probability outputs of the trees",
"model",
".",
"predict",
... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | cric__random_forest | Random Forest | shap/benchmark/models.py | def cric__random_forest():
""" Random Forest
"""
model = sklearn.ensemble.RandomForestClassifier(100, random_state=0)
# we want to explain the raw probability outputs of the trees
model.predict = lambda X: model.predict_proba(X)[:,1]
return model | def cric__random_forest():
""" Random Forest
"""
model = sklearn.ensemble.RandomForestClassifier(100, random_state=0)
# we want to explain the raw probability outputs of the trees
model.predict = lambda X: model.predict_proba(X)[:,1]
return model | [
"Random",
"Forest"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/models.py#L163-L171 | [
"def",
"cric__random_forest",
"(",
")",
":",
"model",
"=",
"sklearn",
".",
"ensemble",
".",
"RandomForestClassifier",
"(",
"100",
",",
"random_state",
"=",
"0",
")",
"# we want to explain the raw probability outputs of the trees",
"model",
".",
"predict",
"=",
"lambda... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | cric__gbm | Gradient Boosted Trees | shap/benchmark/models.py | def cric__gbm():
""" Gradient Boosted Trees
"""
import xgboost
# max_depth and subsample match the params used for the full cric data in the paper
# learning_rate was set a bit higher to allow for faster runtimes
# n_estimators was chosen based on a train/test split of the data
model = xgbo... | def cric__gbm():
""" Gradient Boosted Trees
"""
import xgboost
# max_depth and subsample match the params used for the full cric data in the paper
# learning_rate was set a bit higher to allow for faster runtimes
# n_estimators was chosen based on a train/test split of the data
model = xgbo... | [
"Gradient",
"Boosted",
"Trees"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/models.py#L173-L187 | [
"def",
"cric__gbm",
"(",
")",
":",
"import",
"xgboost",
"# max_depth and subsample match the params used for the full cric data in the paper",
"# learning_rate was set a bit higher to allow for faster runtimes",
"# n_estimators was chosen based on a train/test split of the data",
"model",
"=",... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | human__decision_tree | Decision Tree | shap/benchmark/models.py | def human__decision_tree():
""" Decision Tree
"""
# build data
N = 1000000
M = 3
X = np.zeros((N,M))
X.shape
y = np.zeros(N)
X[0, 0] = 1
y[0] = 8
X[1, 1] = 1
y[1] = 8
X[2, 0:2] = 1
y[2] = 4
# fit model
xor_model = sklearn.tree.DecisionTreeRegressor(max_d... | def human__decision_tree():
""" Decision Tree
"""
# build data
N = 1000000
M = 3
X = np.zeros((N,M))
X.shape
y = np.zeros(N)
X[0, 0] = 1
y[0] = 8
X[1, 1] = 1
y[1] = 8
X[2, 0:2] = 1
y[2] = 4
# fit model
xor_model = sklearn.tree.DecisionTreeRegressor(max_d... | [
"Decision",
"Tree"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/models.py#L209-L230 | [
"def",
"human__decision_tree",
"(",
")",
":",
"# build data",
"N",
"=",
"1000000",
"M",
"=",
"3",
"X",
"=",
"np",
".",
"zeros",
"(",
"(",
"N",
",",
"M",
")",
")",
"X",
".",
"shape",
"y",
"=",
"np",
".",
"zeros",
"(",
"N",
")",
"X",
"[",
"0",
... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | summary_plot | Create a SHAP summary plot, colored by feature values when they are provided.
Parameters
----------
shap_values : numpy.array
Matrix of SHAP values (# samples x # features)
features : numpy.array or pandas.DataFrame or list
Matrix of feature values (# samples x # features) or a feature... | shap/plots/summary.py | def summary_plot(shap_values, features=None, feature_names=None, max_display=None, plot_type="dot",
color=None, axis_color="#333333", title=None, alpha=1, show=True, sort=True,
color_bar=True, auto_size_plot=True, layered_violin_max_num_bins=20, class_names=None):
"""Create a SHAP ... | def summary_plot(shap_values, features=None, feature_names=None, max_display=None, plot_type="dot",
color=None, axis_color="#333333", title=None, alpha=1, show=True, sort=True,
color_bar=True, auto_size_plot=True, layered_violin_max_num_bins=20, class_names=None):
"""Create a SHAP ... | [
"Create",
"a",
"SHAP",
"summary",
"plot",
"colored",
"by",
"feature",
"values",
"when",
"they",
"are",
"provided",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/plots/summary.py#L18-L409 | [
"def",
"summary_plot",
"(",
"shap_values",
",",
"features",
"=",
"None",
",",
"feature_names",
"=",
"None",
",",
"max_display",
"=",
"None",
",",
"plot_type",
"=",
"\"dot\"",
",",
"color",
"=",
"None",
",",
"axis_color",
"=",
"\"#333333\"",
",",
"title",
"... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | kernel_shap_1000_meanref | Kernel SHAP 1000 mean ref.
color = red_blue_circle(0.5)
linestyle = solid | shap/benchmark/methods.py | def kernel_shap_1000_meanref(model, data):
""" Kernel SHAP 1000 mean ref.
color = red_blue_circle(0.5)
linestyle = solid
"""
return lambda X: KernelExplainer(model.predict, kmeans(data, 1)).shap_values(X, nsamples=1000, l1_reg=0) | def kernel_shap_1000_meanref(model, data):
""" Kernel SHAP 1000 mean ref.
color = red_blue_circle(0.5)
linestyle = solid
"""
return lambda X: KernelExplainer(model.predict, kmeans(data, 1)).shap_values(X, nsamples=1000, l1_reg=0) | [
"Kernel",
"SHAP",
"1000",
"mean",
"ref",
".",
"color",
"=",
"red_blue_circle",
"(",
"0",
".",
"5",
")",
"linestyle",
"=",
"solid"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/methods.py#L35-L40 | [
"def",
"kernel_shap_1000_meanref",
"(",
"model",
",",
"data",
")",
":",
"return",
"lambda",
"X",
":",
"KernelExplainer",
"(",
"model",
".",
"predict",
",",
"kmeans",
"(",
"data",
",",
"1",
")",
")",
".",
"shap_values",
"(",
"X",
",",
"nsamples",
"=",
"... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | sampling_shap_1000 | IME 1000
color = red_blue_circle(0.5)
linestyle = dashed | shap/benchmark/methods.py | def sampling_shap_1000(model, data):
""" IME 1000
color = red_blue_circle(0.5)
linestyle = dashed
"""
return lambda X: SamplingExplainer(model.predict, data).shap_values(X, nsamples=1000) | def sampling_shap_1000(model, data):
""" IME 1000
color = red_blue_circle(0.5)
linestyle = dashed
"""
return lambda X: SamplingExplainer(model.predict, data).shap_values(X, nsamples=1000) | [
"IME",
"1000",
"color",
"=",
"red_blue_circle",
"(",
"0",
".",
"5",
")",
"linestyle",
"=",
"dashed"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/methods.py#L42-L47 | [
"def",
"sampling_shap_1000",
"(",
"model",
",",
"data",
")",
":",
"return",
"lambda",
"X",
":",
"SamplingExplainer",
"(",
"model",
".",
"predict",
",",
"data",
")",
".",
"shap_values",
"(",
"X",
",",
"nsamples",
"=",
"1000",
")"
] | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | tree_shap_independent_200 | TreeExplainer (independent)
color = red_blue_circle(0)
linestyle = dashed | shap/benchmark/methods.py | def tree_shap_independent_200(model, data):
""" TreeExplainer (independent)
color = red_blue_circle(0)
linestyle = dashed
"""
data_subsample = sklearn.utils.resample(data, replace=False, n_samples=min(200, data.shape[0]), random_state=0)
return TreeExplainer(model, data_subsample, feature_depend... | def tree_shap_independent_200(model, data):
""" TreeExplainer (independent)
color = red_blue_circle(0)
linestyle = dashed
"""
data_subsample = sklearn.utils.resample(data, replace=False, n_samples=min(200, data.shape[0]), random_state=0)
return TreeExplainer(model, data_subsample, feature_depend... | [
"TreeExplainer",
"(",
"independent",
")",
"color",
"=",
"red_blue_circle",
"(",
"0",
")",
"linestyle",
"=",
"dashed"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/methods.py#L56-L62 | [
"def",
"tree_shap_independent_200",
"(",
"model",
",",
"data",
")",
":",
"data_subsample",
"=",
"sklearn",
".",
"utils",
".",
"resample",
"(",
"data",
",",
"replace",
"=",
"False",
",",
"n_samples",
"=",
"min",
"(",
"200",
",",
"data",
".",
"shape",
"[",... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | mean_abs_tree_shap | mean(|TreeExplainer|)
color = red_blue_circle(0.25)
linestyle = solid | shap/benchmark/methods.py | def mean_abs_tree_shap(model, data):
""" mean(|TreeExplainer|)
color = red_blue_circle(0.25)
linestyle = solid
"""
def f(X):
v = TreeExplainer(model).shap_values(X)
if isinstance(v, list):
return [np.tile(np.abs(sv).mean(0), (X.shape[0], 1)) for sv in v]
else:
... | def mean_abs_tree_shap(model, data):
""" mean(|TreeExplainer|)
color = red_blue_circle(0.25)
linestyle = solid
"""
def f(X):
v = TreeExplainer(model).shap_values(X)
if isinstance(v, list):
return [np.tile(np.abs(sv).mean(0), (X.shape[0], 1)) for sv in v]
else:
... | [
"mean",
"(",
"|TreeExplainer|",
")",
"color",
"=",
"red_blue_circle",
"(",
"0",
".",
"25",
")",
"linestyle",
"=",
"solid"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/methods.py#L64-L75 | [
"def",
"mean_abs_tree_shap",
"(",
"model",
",",
"data",
")",
":",
"def",
"f",
"(",
"X",
")",
":",
"v",
"=",
"TreeExplainer",
"(",
"model",
")",
".",
"shap_values",
"(",
"X",
")",
"if",
"isinstance",
"(",
"v",
",",
"list",
")",
":",
"return",
"[",
... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | saabas | Saabas
color = red_blue_circle(0)
linestyle = dotted | shap/benchmark/methods.py | def saabas(model, data):
""" Saabas
color = red_blue_circle(0)
linestyle = dotted
"""
return lambda X: TreeExplainer(model).shap_values(X, approximate=True) | def saabas(model, data):
""" Saabas
color = red_blue_circle(0)
linestyle = dotted
"""
return lambda X: TreeExplainer(model).shap_values(X, approximate=True) | [
"Saabas",
"color",
"=",
"red_blue_circle",
"(",
"0",
")",
"linestyle",
"=",
"dotted"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/methods.py#L77-L82 | [
"def",
"saabas",
"(",
"model",
",",
"data",
")",
":",
"return",
"lambda",
"X",
":",
"TreeExplainer",
"(",
"model",
")",
".",
"shap_values",
"(",
"X",
",",
"approximate",
"=",
"True",
")"
] | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | lime_tabular_regression_1000 | LIME Tabular 1000 | shap/benchmark/methods.py | def lime_tabular_regression_1000(model, data):
""" LIME Tabular 1000
"""
return lambda X: other.LimeTabularExplainer(model.predict, data, mode="regression").attributions(X, nsamples=1000) | def lime_tabular_regression_1000(model, data):
""" LIME Tabular 1000
"""
return lambda X: other.LimeTabularExplainer(model.predict, data, mode="regression").attributions(X, nsamples=1000) | [
"LIME",
"Tabular",
"1000"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/methods.py#L91-L94 | [
"def",
"lime_tabular_regression_1000",
"(",
"model",
",",
"data",
")",
":",
"return",
"lambda",
"X",
":",
"other",
".",
"LimeTabularExplainer",
"(",
"model",
".",
"predict",
",",
"data",
",",
"mode",
"=",
"\"regression\"",
")",
".",
"attributions",
"(",
"X",... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | deep_shap | Deep SHAP (DeepLIFT) | shap/benchmark/methods.py | def deep_shap(model, data):
""" Deep SHAP (DeepLIFT)
"""
if isinstance(model, KerasWrap):
model = model.model
explainer = DeepExplainer(model, kmeans(data, 1).data)
def f(X):
phi = explainer.shap_values(X)
if type(phi) is list and len(phi) == 1:
return phi[0]
... | def deep_shap(model, data):
""" Deep SHAP (DeepLIFT)
"""
if isinstance(model, KerasWrap):
model = model.model
explainer = DeepExplainer(model, kmeans(data, 1).data)
def f(X):
phi = explainer.shap_values(X)
if type(phi) is list and len(phi) == 1:
return phi[0]
... | [
"Deep",
"SHAP",
"(",
"DeepLIFT",
")"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/methods.py#L96-L109 | [
"def",
"deep_shap",
"(",
"model",
",",
"data",
")",
":",
"if",
"isinstance",
"(",
"model",
",",
"KerasWrap",
")",
":",
"model",
"=",
"model",
".",
"model",
"explainer",
"=",
"DeepExplainer",
"(",
"model",
",",
"kmeans",
"(",
"data",
",",
"1",
")",
".... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | expected_gradients | Expected Gradients | shap/benchmark/methods.py | def expected_gradients(model, data):
""" Expected Gradients
"""
if isinstance(model, KerasWrap):
model = model.model
explainer = GradientExplainer(model, data)
def f(X):
phi = explainer.shap_values(X)
if type(phi) is list and len(phi) == 1:
return phi[0]
e... | def expected_gradients(model, data):
""" Expected Gradients
"""
if isinstance(model, KerasWrap):
model = model.model
explainer = GradientExplainer(model, data)
def f(X):
phi = explainer.shap_values(X)
if type(phi) is list and len(phi) == 1:
return phi[0]
e... | [
"Expected",
"Gradients"
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/benchmark/methods.py#L111-L124 | [
"def",
"expected_gradients",
"(",
"model",
",",
"data",
")",
":",
"if",
"isinstance",
"(",
"model",
",",
"KerasWrap",
")",
":",
"model",
"=",
"model",
".",
"model",
"explainer",
"=",
"GradientExplainer",
"(",
"model",
",",
"data",
")",
"def",
"f",
"(",
... | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | DeepExplainer.shap_values | Return approximate SHAP values for the model applied to the data given by X.
Parameters
----------
X : list,
if framework == 'tensorflow': numpy.array, or pandas.DataFrame
if framework == 'pytorch': torch.tensor
A tensor (or list of tensors) of samples (where... | shap/explainers/deep/__init__.py | def shap_values(self, X, ranked_outputs=None, output_rank_order='max'):
""" Return approximate SHAP values for the model applied to the data given by X.
Parameters
----------
X : list,
if framework == 'tensorflow': numpy.array, or pandas.DataFrame
if framework ==... | def shap_values(self, X, ranked_outputs=None, output_rank_order='max'):
""" Return approximate SHAP values for the model applied to the data given by X.
Parameters
----------
X : list,
if framework == 'tensorflow': numpy.array, or pandas.DataFrame
if framework ==... | [
"Return",
"approximate",
"SHAP",
"values",
"for",
"the",
"model",
"applied",
"to",
"the",
"data",
"given",
"by",
"X",
"."
] | slundberg/shap | python | https://github.com/slundberg/shap/blob/b280cb81d498b9d98565cad8dd16fc88ae52649f/shap/explainers/deep/__init__.py#L86-L119 | [
"def",
"shap_values",
"(",
"self",
",",
"X",
",",
"ranked_outputs",
"=",
"None",
",",
"output_rank_order",
"=",
"'max'",
")",
":",
"return",
"self",
".",
"explainer",
".",
"shap_values",
"(",
"X",
",",
"ranked_outputs",
",",
"output_rank_order",
")"
] | b280cb81d498b9d98565cad8dd16fc88ae52649f |
train | _agent_import_failed | Returns dummy agent class for if PyTorch etc. is not installed. | python/ray/rllib/agents/mock.py | def _agent_import_failed(trace):
"""Returns dummy agent class for if PyTorch etc. is not installed."""
class _AgentImportFailed(Trainer):
_name = "AgentImportFailed"
_default_config = with_common_config({})
def _setup(self, config):
raise ImportError(trace)
return _Age... | def _agent_import_failed(trace):
"""Returns dummy agent class for if PyTorch etc. is not installed."""
class _AgentImportFailed(Trainer):
_name = "AgentImportFailed"
_default_config = with_common_config({})
def _setup(self, config):
raise ImportError(trace)
return _Age... | [
"Returns",
"dummy",
"agent",
"class",
"for",
"if",
"PyTorch",
"etc",
".",
"is",
"not",
"installed",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/agents/mock.py#L108-L118 | [
"def",
"_agent_import_failed",
"(",
"trace",
")",
":",
"class",
"_AgentImportFailed",
"(",
"Trainer",
")",
":",
"_name",
"=",
"\"AgentImportFailed\"",
"_default_config",
"=",
"with_common_config",
"(",
"{",
"}",
")",
"def",
"_setup",
"(",
"self",
",",
"config",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | run | Executes training.
Args:
run_or_experiment (function|class|str|Experiment): If
function|class|str, this is the algorithm or model to train.
This may refer to the name of a built-on algorithm
(e.g. RLLib's DQN or PPO), a user-defined trainable
function or clas... | python/ray/tune/tune.py | def run(run_or_experiment,
name=None,
stop=None,
config=None,
resources_per_trial=None,
num_samples=1,
local_dir=None,
upload_dir=None,
trial_name_creator=None,
loggers=None,
sync_function=None,
checkpoint_freq=0,
checkpoint... | def run(run_or_experiment,
name=None,
stop=None,
config=None,
resources_per_trial=None,
num_samples=1,
local_dir=None,
upload_dir=None,
trial_name_creator=None,
loggers=None,
sync_function=None,
checkpoint_freq=0,
checkpoint... | [
"Executes",
"training",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/tune.py#L68-L257 | [
"def",
"run",
"(",
"run_or_experiment",
",",
"name",
"=",
"None",
",",
"stop",
"=",
"None",
",",
"config",
"=",
"None",
",",
"resources_per_trial",
"=",
"None",
",",
"num_samples",
"=",
"1",
",",
"local_dir",
"=",
"None",
",",
"upload_dir",
"=",
"None",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | run_experiments | Runs and blocks until all trials finish.
Examples:
>>> experiment_spec = Experiment("experiment", my_func)
>>> run_experiments(experiments=experiment_spec)
>>> experiment_spec = {"experiment": {"run": my_func}}
>>> run_experiments(experiments=experiment_spec)
>>> run_exper... | python/ray/tune/tune.py | def run_experiments(experiments,
search_alg=None,
scheduler=None,
with_server=False,
server_port=TuneServer.DEFAULT_PORT,
verbose=2,
resume=False,
queue_trials=False,
... | def run_experiments(experiments,
search_alg=None,
scheduler=None,
with_server=False,
server_port=TuneServer.DEFAULT_PORT,
verbose=2,
resume=False,
queue_trials=False,
... | [
"Runs",
"and",
"blocks",
"until",
"all",
"trials",
"finish",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/tune/tune.py#L260-L312 | [
"def",
"run_experiments",
"(",
"experiments",
",",
"search_alg",
"=",
"None",
",",
"scheduler",
"=",
"None",
",",
"with_server",
"=",
"False",
",",
"server_port",
"=",
"TuneServer",
".",
"DEFAULT_PORT",
",",
"verbose",
"=",
"2",
",",
"resume",
"=",
"False",
... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | DataOutput._flush | Flushes remaining output records in the output queues to plasma.
None is used as special type of record that is propagated from sources
to sink to notify that the end of data in a stream.
Attributes:
close (bool): A flag denoting whether the channel should be
also mar... | python/ray/experimental/streaming/communication.py | def _flush(self, close=False):
"""Flushes remaining output records in the output queues to plasma.
None is used as special type of record that is propagated from sources
to sink to notify that the end of data in a stream.
Attributes:
close (bool): A flag denoting whether t... | def _flush(self, close=False):
"""Flushes remaining output records in the output queues to plasma.
None is used as special type of record that is propagated from sources
to sink to notify that the end of data in a stream.
Attributes:
close (bool): A flag denoting whether t... | [
"Flushes",
"remaining",
"output",
"records",
"in",
"the",
"output",
"queues",
"to",
"plasma",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/experimental/streaming/communication.py#L205-L233 | [
"def",
"_flush",
"(",
"self",
",",
"close",
"=",
"False",
")",
":",
"for",
"channel",
"in",
"self",
".",
"forward_channels",
":",
"if",
"close",
"is",
"True",
":",
"channel",
".",
"queue",
".",
"put_next",
"(",
"None",
")",
"channel",
".",
"queue",
"... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | get_preprocessor | Returns an appropriate preprocessor class for the given space. | python/ray/rllib/models/preprocessors.py | def get_preprocessor(space):
"""Returns an appropriate preprocessor class for the given space."""
legacy_patch_shapes(space)
obs_shape = space.shape
if isinstance(space, gym.spaces.Discrete):
preprocessor = OneHotPreprocessor
elif obs_shape == ATARI_OBS_SHAPE:
preprocessor = Generi... | def get_preprocessor(space):
"""Returns an appropriate preprocessor class for the given space."""
legacy_patch_shapes(space)
obs_shape = space.shape
if isinstance(space, gym.spaces.Discrete):
preprocessor = OneHotPreprocessor
elif obs_shape == ATARI_OBS_SHAPE:
preprocessor = Generi... | [
"Returns",
"an",
"appropriate",
"preprocessor",
"class",
"for",
"the",
"given",
"space",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/models/preprocessors.py#L242-L261 | [
"def",
"get_preprocessor",
"(",
"space",
")",
":",
"legacy_patch_shapes",
"(",
"space",
")",
"obs_shape",
"=",
"space",
".",
"shape",
"if",
"isinstance",
"(",
"space",
",",
"gym",
".",
"spaces",
".",
"Discrete",
")",
":",
"preprocessor",
"=",
"OneHotPreproce... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | legacy_patch_shapes | Assigns shapes to spaces that don't have shapes.
This is only needed for older gym versions that don't set shapes properly
for Tuple and Discrete spaces. | python/ray/rllib/models/preprocessors.py | def legacy_patch_shapes(space):
"""Assigns shapes to spaces that don't have shapes.
This is only needed for older gym versions that don't set shapes properly
for Tuple and Discrete spaces.
"""
if not hasattr(space, "shape"):
if isinstance(space, gym.spaces.Discrete):
space.shap... | def legacy_patch_shapes(space):
"""Assigns shapes to spaces that don't have shapes.
This is only needed for older gym versions that don't set shapes properly
for Tuple and Discrete spaces.
"""
if not hasattr(space, "shape"):
if isinstance(space, gym.spaces.Discrete):
space.shap... | [
"Assigns",
"shapes",
"to",
"spaces",
"that",
"don",
"t",
"have",
"shapes",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/models/preprocessors.py#L264-L281 | [
"def",
"legacy_patch_shapes",
"(",
"space",
")",
":",
"if",
"not",
"hasattr",
"(",
"space",
",",
"\"shape\"",
")",
":",
"if",
"isinstance",
"(",
"space",
",",
"gym",
".",
"spaces",
".",
"Discrete",
")",
":",
"space",
".",
"shape",
"=",
"(",
")",
"eli... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | GenericPixelPreprocessor.transform | Downsamples images from (210, 160, 3) by the configured factor. | python/ray/rllib/models/preprocessors.py | def transform(self, observation):
"""Downsamples images from (210, 160, 3) by the configured factor."""
self.check_shape(observation)
scaled = observation[25:-25, :, :]
if self._dim < 84:
scaled = cv2.resize(scaled, (84, 84))
# OpenAI: Resize by half, then down to 42x... | def transform(self, observation):
"""Downsamples images from (210, 160, 3) by the configured factor."""
self.check_shape(observation)
scaled = observation[25:-25, :, :]
if self._dim < 84:
scaled = cv2.resize(scaled, (84, 84))
# OpenAI: Resize by half, then down to 42x... | [
"Downsamples",
"images",
"from",
"(",
"210",
"160",
"3",
")",
"by",
"the",
"configured",
"factor",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/models/preprocessors.py#L105-L124 | [
"def",
"transform",
"(",
"self",
",",
"observation",
")",
":",
"self",
".",
"check_shape",
"(",
"observation",
")",
"scaled",
"=",
"observation",
"[",
"25",
":",
"-",
"25",
",",
":",
",",
":",
"]",
"if",
"self",
".",
"_dim",
"<",
"84",
":",
"scaled... | 4eade036a0505e244c976f36aaa2d64386b5129b |
train | MinibatchBuffer.get | Get a new batch from the internal ring buffer.
Returns:
buf: Data item saved from inqueue.
released: True if the item is now removed from the ring buffer. | python/ray/rllib/optimizers/aso_minibatch_buffer.py | def get(self):
"""Get a new batch from the internal ring buffer.
Returns:
buf: Data item saved from inqueue.
released: True if the item is now removed from the ring buffer.
"""
if self.ttl[self.idx] <= 0:
self.buffers[self.idx] = self.inqueue.get(timeou... | def get(self):
"""Get a new batch from the internal ring buffer.
Returns:
buf: Data item saved from inqueue.
released: True if the item is now removed from the ring buffer.
"""
if self.ttl[self.idx] <= 0:
self.buffers[self.idx] = self.inqueue.get(timeou... | [
"Get",
"a",
"new",
"batch",
"from",
"the",
"internal",
"ring",
"buffer",
"."
] | ray-project/ray | python | https://github.com/ray-project/ray/blob/4eade036a0505e244c976f36aaa2d64386b5129b/python/ray/rllib/optimizers/aso_minibatch_buffer.py#L30-L48 | [
"def",
"get",
"(",
"self",
")",
":",
"if",
"self",
".",
"ttl",
"[",
"self",
".",
"idx",
"]",
"<=",
"0",
":",
"self",
".",
"buffers",
"[",
"self",
".",
"idx",
"]",
"=",
"self",
".",
"inqueue",
".",
"get",
"(",
"timeout",
"=",
"300.0",
")",
"se... | 4eade036a0505e244c976f36aaa2d64386b5129b |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.