dianna.visualization.text ========================= .. py:module:: dianna.visualization.text Functions --------- .. autoapisummary:: dianna.visualization.text.highlight_text dianna.visualization.text._get_text_color Module Contents --------------- .. py:function:: highlight_text(explanation, input_tokens=None, show_plot=True, output_filename=None, colormap='bwr', alpha=1.0, heatmap_range=(-1, 1)) Highlights a given text based on values in a given explanation object. :param explanation: list of tuples of (word, index of word in original data, importance) :param input_tokens: list of all tokens (including those without importance) :param show_plot: Shows plot if true (for testing or writing plots to disk instead) :param output_filename: Name of the file to save the plot to (optional). :param colormap: color map for the heatmap plot (see mpl.Axes.imshow documentation for options). :param alpha: alpha value for the heatmap plot. :param heatmap_range: a tuple (vmin, vmax) to set the range of the heatmap. :returns: None .. py:function:: _get_text_color(importance, vmin, vmax, colormap, alpha) Assign a color to a text based on its importance. :param importance: The importance of the text (between vmin and vmax) :type importance: float :param vmin: The minimum value of the importance range :type vmin: float :param vmax: The maximum value of the importance range :type vmax: float :param colormap: color map for the heatmap plot (see mpl.Axes.imshow documentation for options). :type colormap: str :param alpha: alpha value for the color. :type alpha: float :returns: (r, g, b, alpha) values of the color. :rtype: tuple