pdstools.plots.plots_plotly

Module Contents

Classes

class ADMVisualisations
static distribution_graph(df, title)
static post_plot(fig, name, query=None, title=None, file_title=None, file_path='.', show_each=False, image_format=None, to_html=False, **kwargs)
PerformanceSuccessRateBubbleChart(df, add_bottom_left_text=True, facet=None, context_keys=None, **kwargs)

Creates bubble chart similar to ADM OOTB reports

Parameters:
  • last (bool) – Whether to only include the last snapshot for each model

  • add_bottom_left_text (bool) – Whether to subtitle text to indicate how many models are at 0,50

  • to_html (bool) – Whether to write image to html, with title file_title at path file_path

  • file_title (Optional[str]) – The title of the image when written to html

  • file_path (Optional[str]) – The location the file will be written when written to html

  • query (Union[str, dict]) – The query to supply to _apply_query If a string, uses the default Pandas query function Else, a dict of lists where the key is column name in the dataframe and the corresponding value is a list of values to keep in the dataframe

  • show_each (bool) – Whether to show each file when multiple facets are used

  • facets (Optional[Union[list, str]]) – Whether to create a chart for multiple facets or subsets. For example, if facets == ‘Channel’, a bubble plot is made for each channel Depending on show_each, every chart is either shown or not If more than one facet is visualised, they are returned in a list

Return type:

px.Figure

OverTime(df, metric='Performance', by='ModelID', facet=None, mode='diff', **kwargs)

Shows metric of models over time

Parameters:

query (Union[str, dict]) – The query to supply to _apply_query If a string, uses the default Pandas query function Else, a dict of lists where the key is column name in the dataframe and the corresponding value is a list of values to keep in the dataframe

Return type:

plt.figure

PropositionSuccessRates(df, metric='SuccessRate', by='Name', show_error=True, facet=None, **kwargs)

Shows all latest proposition success rates

A bar plot to show the success rate of all latest model instances (propositions) For reading simplicity, latest success rate is also annotated next to each bar

Parameters:

query (Union[str, dict]) – The query to supply to _apply_query If a string, uses the default Pandas query function Else, a dict of lists where the key is column name in the dataframe and the corresponding value is a list of values to keep in the dataframe

Return type:

plt.figure

ScoreDistribution(df, facet_val, **kwargs)

Show score distribution similar to ADM out-of-the-box report

Shows a score distribution graph per model. If certain models selected, only those models will be shown. the only difference between this graph and the one shown on ADM report is that, here the raw number of responses are shown on left y-axis whereas in ADM reports, the percentage of responses are shown

Parameters:
  • show_zero_responses (bool) – Whether to include bins with no responses at all

  • query (Union[str, dict]) – The query to supply to _apply_query If a string, uses the default Pandas query function Else, a dict of lists where the key is column name in the dataframe and the corresponding value is a list of values to keep in the dataframe

Return type:

plt.figure

PredictorBinning(df, facet_val, **kwargs)

Show predictor graphs for a given model

For a given model (query) shows all its predictors’ graphs. If certain predictors selected, only those predictor graphs will be shown

Parameters:
  • predictors (list) – List of predictors to show their graphs, optional

  • modelid (str) – Model IDs to subset on, optional

  • query (Union[str, dict]) – The query to supply to _apply_query If a string, uses the default Pandas query function Else, a dict of lists where the key is column name in the dataframe and the corresponding value is a list of values to keep in the dataframe

  • figsize (tuple) – Size of graph

Return type:

plt.figure

PredictorPerformance(df, facet=None, order=None, to_plot='Performance', y='PredictorName', **kwargs)

Shows a box plot of predictor performance

Parameters:
  • top_n (int) – The number of top performing predictors to show If 0 (default), all predictors are shown

  • to_html (bool) – Whether to write image to html, with title file_title at path file_path

  • file_title (Optional[str]) – The title of the image when written to html

  • file_path (Optional[str]) – The location the file will be written when written to html

  • query (Union[str, dict]) – The query to supply to _apply_query If a string, uses the default Pandas query function Else, a dict of lists where the key is column name in the dataframe and the corresponding value is a list of values to keep in the dataframe

  • facets (Optional[Union[list, str]]) – Whether to create a chart for multiple facets or subsets.

Return type:

px.Figure

_divide_context()

Divides the context keys if they are combined

PredictorPerformanceHeatmap(df, facet=None, **kwargs)

Shows a heatmap plot of predictor performance across models

Parameters:
  • top_n (int) – Whether to subset to a top number of predictors If 0 (default), all predictors are shown

  • to_html (bool) – Whether to write image to html, with title file_title at path file_path

  • file_title (Optional[str]) – The title of the image when written to html

  • file_path (Optional[str]) – The location the file will be written when written to html

  • query (Union[str, dict]) – The query to supply to _apply_query If a string, uses the default Pandas query function Else, a dict of lists where the key is column name in the dataframe and the corresponding value is a list of values to keep in the dataframe

  • show_each (bool) – Whether to show each file when multiple facets are used

  • facets (Optional[Union[list, str]]) – Whether to create a chart for multiple facets or subsets. For example, if facets == ‘Channel’, a bubble plot is made for each channel Depending on show_each, every chart is either shown or not If more than one facet is visualised, they are returned in a list

Return type:

px.Figure

ResponseGain(df, by='Channel', facet=None, **kwargs)

Plots the cumulative response per model, subsetted by ‘by’

Parameters:
  • by (str) – The column to calculate response gain by

  • to_html (bool) – Whether to write image to html, with title file_title at path file_path

  • file_title (Optional[str]) – The title of the image when written to html

  • file_path (Optional[str]) – The location the file will be written when written to html

  • query (Union[str, dict]) – The query to supply to _apply_query If a string, uses the default Pandas query function Else, a dict of lists where the key is column name in the dataframe and the corresponding value is a list of values to keep in the dataframe

  • show_each (bool) – Whether to show each file when multiple facets are used

  • facets (Optional[Union[list, str]]) – Whether to create a chart for multiple facets or subsets. For example, if facets == ‘Channel’, a bubble plot is made for each channel Depending on show_each, every chart is either shown or not If more than one facet is visualised, they are returned in a list

Return type:

px.Figure

ModelsByPositives(df, by='Channel', **kwargs)

Plots the percentage of models vs the number of positive responses

Parameters:
  • by (str) – The column to calculate the model percentage by

  • to_html (bool) – Whether to write image to html, with title file_title at path file_path

  • file_title (Optional[str]) – The title of the image when written to html

  • file_path (Optional[str]) – The location the file will be written when written to html

  • query (Union[str, dict]) – The query to supply to _apply_query If a string, uses the default Pandas query function Else, a dict of lists where the key is column name in the dataframe and the corresponding value is a list of values to keep in the dataframe

  • show_each (bool) – Whether to show each file when multiple facets are used

  • facets (Optional[Union[list, str]]) – Whether to create a chart for multiple facets or subsets. For example, if facets == ‘Channel’, a bubble plot is made for each channel Depending on show_each, every chart is either shown or not If more than one facet is visualised, they are returned in a list

Return type:

px.Figure

TreeMap(df, color, values, title, reverse_scale, log, midpoint, format, context_keys, value_in_text=True, **kwargs)

Plots a treemap to view performance over multiple context keys

Parameters:
  • color (str) – The column to set as the color of the squares One out of: {responsecount, responsecount_log, positives, positives_log, percentage_without_responses, performance_weighted, successrate}

  • by (str) – The column to set as the size of the squares

  • value_in_text (str) – Whether to print the values of the squares in the squares

  • midpoint (Optional[float]) – A parameter to assert more control over the color distribution Set near 0 to give lower values a ‘higher’ color Set near 1 to give higher values a ‘lower’ color Necessary for, for example, Success Rate, where rates lie very far apart If not supplied in such cases, there is no difference in the color between low values such as 0.001 and 0.1, so midpoint should be set low

  • to_html (bool) – Whether to write image to html, with title file_title at path file_path

  • file_title (Optional[str]) – The title of the image when written to html

  • file_path (Optional[str]) – The location the file will be written when written to html

  • query (Union[str, dict]) – The query to supply to _apply_query If a string, uses the default Pandas query function Else, a dict of lists where the key is column name in the dataframe and the corresponding value is a list of values to keep in the dataframe

  • show_each (bool) – Whether to show each file when multiple facets are used

  • facets (Optional[Union[list, str]]) – Whether to create a chart for multiple facets or subsets. For example, if facets == ‘Channel’, a bubble plot is made for each channel Depending on show_each, every chart is either shown or not If more than one facet is visualised, they are returned in a list

Return type:

px.Figure

PredictorCount(df, facet, **kwargs)
PredictorContribution(df, by, **kwargs)