peal.explainers.explainer_factory.get_explainer¶
- peal.explainers.explainer_factory.get_explainer(explainer, device='cuda', predictor_datasets=None, **kwargs)[source]¶
Return an explainer built from an instance, a yaml path or a config dict.
- Parameters:
explainer (
ExplainerInterfaceorstrordict) – A ready explainer (returned unchanged), a yaml path or a dict-like config. The config’sexplainer_typeselects the class: the valuesSCE,ACE,TIMEandDAEdistillall instantiateCounterfactualExplainer(explainer_config=..., **kwargs); any other value must be the class name of anExplainerInterfacesubclass discovered underpeal/explainers, which is then called ascls(config=..., device=..., predictor_dataset=predictor_datasets, **kwargs).device (
strortorch.device, optional) – Device handed to non-counterfactual explainers. Default"cuda".predictor_datasets (optional) – Dataset(s) of the predictor, forwarded as
predictor_dataset.**kwargs – Extra constructor arguments forwarded to the explainer class.
- Returns:
The resolved explainer.
- Return type:
ExplainerInterface- Raises:
peal.registry.UnknownComponentError – If the config’s
explainer_typematches neither the legacy names nor a registered or discoverable subclass.