shap の API リファレンス
shap (shap/shap) の公開 API 76 件 —— クラス 28、関数 27、メソッド 21。実際のソースを静的解析して抽出した正確なシグネチャを掲載しています。
リポジトリ: shap/shap
| 種別 | 件数 |
|---|---|
| クラス | 28 |
| 関数 | 27 |
| メソッド | 21 |
API 一覧
class
shap._explanation.ExplanationA sliceable set of parallel arrays representing a SHAP explanation.
method
shap._explanation.Explanation.cohorts(cohorts:int | list[int] | tuple[int] | np.ndarray) -> CohortsSplit this explanation into several cohorts.
method
shap._explanation.Explanation.hstack(other:Explanation) -> ExplanationStack two explanations column-wise.
method
shap._explanation.Explanation.max(axis:int) -> ExplanationNumpy-style max function.
method
shap._explanation.Explanation.mean(axis:int) -> ExplanationNumpy-style mean function.
method
shap._explanation.Explanation.min(axis:int) -> ExplanationNumpy-style min function.
method
shap._explanation.Explanation.shape() -> tuple[int, ...]Compute the shape over potentially complex data nesting.
method
shap._explanation.Explanation.sum(axis:int | None=None, grouping:dict[str, str] | None=None) -> ExplanationNumpy-style sum function.
method
shap._explanation.Explanation.values()Pass-through from the underlying slicer object.
class
shap._explanation.OpHistoryItemAn operation that has been applied to an Explanation object.
class
shap._serializable.DeserializerLoad data items from an input stream.
class
shap._serializable.SerializableThis is the superclass of all serializable objects.
method
shap._serializable.Serializable.save(out_file)Save the model to the given file stream.
class
shap._serializable.SerializerSave data items to an input stream.
class
shap.actions._action.ActionAbstract action class.
func
shap.datasets.a1a(n_points:int | None=None) -> tuple[ssp.csr_matrix, np.ndarray]Return a sparse dataset in scipy csr matrix format.
func
shap.datasets.adult(display:bool=False, n_points:int | None=None) -> tuple[pd.DataFrame, np.ndarray]Return the Adult census data in a structured format.
func
shap.datasets.cache(url:str, file_name:str | None=None) -> strLoads a file from the URL and caches it locally.
func
shap.datasets.california(n_points:int | None=None) -> tuple[pd.DataFrame, np.ndarray]Return the California housing data in a tabular format.
func
shap.datasets.diabetes(n_points:int | None=None) -> tuple[pd.DataFrame, np.ndarray]Return the diabetes data in a nice package.
func
shap.datasets.imagenet50(resolution:int=224, n_points:int | None=None) -> tuple[np.ndarray, np.ndarray]Return a set of 50 images representative of ImageNet images.
class
shap.explainers._additive.AdditiveExplainerComputes SHAP values for generalized additive models.
method
shap.explainers._additive.AdditiveExplainer.supports_model_with_masker(model:Any, masker:Any) -> boolDetermines if this explainer can handle the given model.
class
shap.explainers._deep.DeepExplainerMeant to approximate SHAP values for deep learning models.
func
shap.explainers._deep.deep_pytorch.linear_1d(module, grad_input, grad_output)No change made to gradients.
func
shap.explainers._deep.deep_pytorch.passthrough(module, grad_input, grad_output)No change made to gradients
class
shap.explainers._exact.ExactExplainerComputes SHAP values via an optimized exact enumeration.
func
shap.explainers._exact.gray_code_indexes(nbits:int) -> npt.NDArray[np.intp]Produces an array of which bits flip at which position.
class
shap.explainers._gpu_tree.GPUTreeExplainerExperimental GPU accelerated version of TreeExplainer.
class
shap.explainers._tree.SingleTreeA single decision tree.
class
shap.explainers._tree.TreeEnsembleAn ensemble of decision trees.
method
shap.explainers._tree.TreeEnsemble.get_transform() -> strA consistent interface to make predictions from this model.
method
shap.explainers._tree.TreeExplainer.supports_model_with_masker(model:Any, masker:Any) -> boolDetermines if this explainer can handle the given model.
class
shap.explainers._tree.XGBTreeModelLoaderThis loads an XGBoost model directly from a raw memory dump.
func
shap.explainers._tree.XGBTreeModelLoader.to_integers(data:list[int]) -> np.ndarrayHandle u8 array from UBJSON.
class
shap.explainers.other._maple.MapleSimply wraps MAPLE into the common SHAP interface.
class
shap.explainers.other._maple.TreeMapleSimply tree MAPLE into the common SHAP interface.
class
shap.explainers.pytree.TreeExplainerA pure Python (slow) implementation of Tree SHAP.
func
shap.links.identity(x:npt.NDArray[Any] | float) -> npt.NDArray[Any] | floatA no-op link function.
method
shap.maskers._composite.Composite.data_transform(*args:Any) -> list[Any]Transform the argument
method
shap.maskers._composite.Composite.mask_shapes(*args:Any) -> list[Any]The shape of the masks we expect.
class
shap.maskers._image.ImageMasks out image regions with blurring or inpainting.
method
shap.maskers._image.Image.save(out_file)Write a Image masker to a file stream.
class
shap.maskers._masker.MaskerThis is the superclass of all maskers.
class
shap.maskers._tabular.TabularA common base class for Independent and Partition.
method
shap.maskers._tabular.Tabular.save(out_file)Write a Tabular masker to a file stream.
class
shap.maskers._text.SimpleTokenizerA basic model agnostic tokenizer.
class
shap.maskers._text.TextThis masks out tokens according to the given tokenizer.
method
shap.maskers._text.Text.load(in_file, instantiate=True)Load a Text masker from a file stream.
method
shap.maskers._text.Text.mask_shapes(s)The shape of the masks we expect.
method
shap.maskers._text.Text.save(out_file)Save a Text masker to a file stream.
method
shap.maskers._text.Text.shape(s)The shape of what we return as a masker.
class
shap.maskers._text.TokenA token representation used for token clustering.
class
shap.models._model.ModelThis is the superclass of all models.
method
shap.models._model.Model.save(out_file:BinaryIO) -> NoneSave the model to the given file stream.
class
shap.models._text_generation.TextGenerationGenerates target sentence/ids using a base model.
class
shap.plots._decision.DecisionPlotResultThe optional return value of decision_plot.
func
shap.plots._decision.multioutput_decision(base_values, shap_values, row_index, **kwargs) -> DecisionPlotResult | NoneDecision plot for multioutput models.
class
shap.plots._force.AdditiveForceVisualizerVisualizer for a single Additive Force plot.
func
shap.plots._force.save_html(out_file, plot, full_html=True)Save html plots to an output file.
func
shap.plots._force_matplotlib.draw_additive_plot(data, figsize, show, text_rotation=0, min_perc=0.05)Draw additive plot.
func
shap.plots._force_matplotlib.draw_bars(out_value, features, feature_type, width_separators, width_bar)Draw the bars and separators.
func
shap.plots._force_matplotlib.format_data(data)Format data.
func
shap.plots._monitoring.monitoring(ind, shap_values, features, feature_names=None, show=True)Create a SHAP monitoring plot.
class
shap.plots._style.StyleOptionsA TypedDict of partial updates to a style configuration
func
shap.plots._style.get_style() -> StyleConfigReturn all currently active global style configuration options.
func
shap.plots._style.load_default_style() -> StyleConfigLoad the default style configuration.
func
shap.plots._style.set_style(_style:StyleConfig | None=None, **options:Unpack[StyleOptions]) -> NoneSet options in the currently active global style configuration.
func
shap.plots._text.values_min_max(values, base_values)Used to pick our axis limits.
func
shap.plots._utils.fill_counts(partition_tree)This updates the
func
shap.plots.colors._colorconv.xyz2rgb(xyz)XYZ to RGB color space conversion.
class
shap.utils._exceptions.ExplainerErrorGeneric errors related to Explainers
func
shap.utils._general.format_value(s:Any, format_str:str) -> strStrips trailing zeros and uses a unicode minus sign.
func
shap.utils._general.ordinal_str(n:int) -> strConverts a number to and ordinal string.
func
shap.utils._general.sample(X:_ArrayT, nsamples:int=100, random_state:int=0) -> _ArrayTPerforms sampling without replacement of the input data ``X``.
func
shap.utils._legacy.convert_to_model(val, keep_index=False)Convert a model to a Model object.
この情報について
掲載しているシグネチャは shap/shap の公開ソースコードを
Python の ast モジュールで静的解析し、引数名・デフォルト値・
型注釈・戻り値型をそのまま抽出したものです。実装コードは保存していません。
詳しくは仕組みの解説をご覧ください。