dianna ====== .. py:module:: dianna .. autoapi-nested-parse:: DIANNA: Deep Insight And Neural Network Analysis. Modern scientific challenges are often tackled with (Deep) Neural Networks (DNN). Despite their high predictive accuracy, DNNs lack inherent explainability. Many DNN users, especially scientists, do not harvest DNNs power because of lack of trust and understanding of their working. Meanwhile, the eXplainable AI (XAI) methods offer some post-hoc interpretability and insight into the DNN reasoning. This is done by quantifying the relevance of individual features (image pixels, words in text, etc.) with respect to the prediction. These "relevance heatmaps" indicate how the network has reached its decision directly in the input modality (images, text, speech etc.) of the data. There are many Open Source Software (OSS) implementations of these methods, alas, supporting a single DNN format and the libraries are known mostly by the AI experts. The DIANNA library supports the best XAI methods in the context of scientific usage providing their OSS implementation based on the ONNX standard and demonstrations on benchmark datasets. Representing visually the captured knowledge by the AI system can become a source of (scientific) insights. See https://github.com/dianna-ai/dianna Submodules ---------- .. toctree:: :maxdepth: 1 /autoapi/dianna/_logging_utils/index /autoapi/dianna/cli/index /autoapi/dianna/utils/index /autoapi/dianna/visualization/index Attributes ---------- .. autoapisummary:: dianna.__author__ dianna.__email__ dianna.__version__ Functions --------- .. autoapisummary:: dianna.explain_timeseries dianna.explain_image dianna.explain_text dianna.explain_tabular dianna._get_explainer Package Contents ---------------- .. py:data:: __author__ :value: 'DIANNA Team' .. py:data:: __email__ :value: 'dianna-ai@esciencecenter.nl' .. py:data:: __version__ :value: '1.7.0' .. py:function:: explain_timeseries(model_or_function: Union[collections.abc.Callable, str], input_timeseries: numpy.ndarray, method: str, labels: collections.abc.Iterable[int], **kwargs) -> numpy.ndarray Explain timeseries data given a model and a chosen method. :param model_or_function: The function that runs the model to be explained _or_ the path to a ONNX model on disk. :type model_or_function: callable or str :param input_timeseries: Timeseries data to be explained :type input_timeseries: np.ndarray :param method: One of the supported methods: RISE, LIME or KernelSHAP :type method: str :param labels: Labels to be explained :type labels: Iterable(int) :param kwargs: key word arguments :returns: One heatmap per class. :rtype: np.ndarray .. py:function:: explain_image(model_or_function: Union[collections.abc.Callable, str], input_image: numpy.ndarray, method: str, labels: collections.abc.Iterable[int], **kwargs) -> numpy.ndarray Explain an image (input_data) given a model and a chosen method. :param model_or_function: The function that runs the model to be explained _or_ the path to a ONNX model on disk. :type model_or_function: callable or str :param input_image: Image data to be explained :type input_image: np.ndarray :param method: One of the supported methods: RISE, LIME or KernelSHAP :type method: str :param labels: Labels to be explained :type labels: Iterable(int) :param kwargs: These keyword parameters are passed on :returns: An array containing the heat maps for each class. :rtype: np.ndarray .. py:function:: explain_text(model_or_function: Union[collections.abc.Callable, str], input_text: str, tokenizer, method: str, labels: collections.abc.Iterable[int], **kwargs) -> list Explain text (input_text) given a model and a chosen method. :param model_or_function: The function that runs the model to be explained _or_ the path to a ONNX model on disk. :type model_or_function: callable or str :param input_text: Text to be explained :type input_text: str :param tokenizer: Tokenizer class with tokenize and convert_tokens_to_string methods, and mask_token attribute :param method: One of the supported methods: RISE or LIME :type method: str :param labels: Labels to be explained :type labels: Iterable(int) :param kwargs: These keyword parameters are passed on :returns: List of tuples (word, index of word in raw text, importance for target class) for each class. :rtype: list .. py:function:: explain_tabular(model_or_function: Union[collections.abc.Callable, str], input_tabular: numpy.ndarray, method: str, labels=None, **kwargs) -> numpy.ndarray Explain tabular (input_text) given a model and a chosen method. :param model_or_function: The function that runs the model to be explained _or_ the path to a ONNX model on disk. :type model_or_function: callable or str :param input_tabular: Tabular data to be explained :type input_tabular: np.ndarray :param method: One of the supported methods: RISE, LIME or KernelSHAP :type method: str :param labels: Labels to be explained :type labels: Iterable(int), optional :param kwargs: These keyword parameters are passed on :returns: An array containing the heat maps for each class. :rtype: np.ndarray .. py:function:: _get_explainer(method, kwargs, modality)