verona.visualization package

verona.visualization.metrics module

verona.visualization.metrics.bar_plot_metric(data: DataFrame, x_label: str = 'Dataset', y_label: str = 'Accuracy', reduction: Literal['mean', 'max', 'min', 'median'] = None, y_min: float = 0.0, y_max: float = 100.0, font_size: int = 15, print_values: bool = False, num_decimals: int = 2) Figure[source]

Generates a bar chart from input data.

Parameters:
  • data (pd.DataFrame) – Pandas DataFrame where the columns name correspond to the categories to be represented on the X-axis and the values are either single numerical values or NumPy Arrays. If arrays are used, the reduction parameter will be applied.

  • x_label (str, optional) – Label for the X axis. Default is 'Dataset'.

  • y_label (str, optional) – Label for the Y axis. Defaults to 'Accuracy'.

  • reduction (Literal['mean', 'max', 'min', 'median'], optional) – The reduction function to be applied if the values in the data dictionary are NumPy Arrays.

  • y_min (float, optional) – The minimum value for the Y-axis. Default is 0.0.

  • y_max (float, optional) – The maximum value for the Y-axis. Defaults is 100.0.

  • font_size (int, optional) – Font size of the text in the plot. Default is 15.

  • print_values (bool, optional) – If True, metric values are printed over each bar. Default is False.

  • num_decimals (int, optional) – Number of decimals to display if print_values is True. Default is 2.

Returns:

Plotly Figure object representing the bar chart.

Return type:

Plotly Figure

verona.visualization.metrics.box_plot_metric(data: DataFrame, x_label: str = 'Dataset', y_label: str = 'Accuracy', y_min: float = 0.0, y_max: float = 100.0, font_size: int = 15) Figure[source]

Generates a box plot showing the corresponding box for each category.

Parameters:
  • data (pd.DataFrame) – Pandas DataFrame containing the values to be represented in the graph. The columns name correspond to the categories to be represented on the X-axis, while the values associated are used to build the corresponding box.

  • x_label (str, optional) – Label for the X axis. Default is 'Dataset'.

  • y_label (str, optional) – Label for the Y axis. Default is 'Accuracy'.

  • y_min (float, optional) – The minimum value for the Y-axis. Defaults is 0.0.

  • y_max (float, optional) – The maximum value for the Y-axis. Default is 100.0.

  • font_size (int, optional) – Font size of the text in the plot. Default is 15.

Returns:

Plotly Figure object representing the error plot.

Return type:

Plotly Figure

verona.visualization.metrics.error_plot_metric(data: DataFrame, x_label: str = 'Dataset', y_label: str = 'Accuracy', y_min: float = 0.0, y_max: float = 100.0, font_size: int = 15, print_values: bool = False, num_decimals: int = 2) Figure[source]

Generates an error plot from input data.

This function is particularly useful for visualizing results from cross-validation experiments, as it shows the mean and standard deviation for each NumPy Array of values.

Parameters:
  • data (pd.DataFrame) – Pandas DataFrame where the columns name correspond to the categories to be represented on the X-axis and the values are used to construct the corresponding error bars.

  • x_label (str, optional) – Label for the X axis. Default is 'Dataset'.

  • y_label (str, optional) – Label for the Y axis. Default is 'Accuracy'.

  • y_min (float, optional) – The minimum value for the Y-axis. Default is 0.0.

  • y_max (float, optional) – The maximum value for the Y-axis. Default is 100.0.

  • font_size (int, optional) – Font size of the text in the plot. Default is 15.

  • print_values (bool, optional) – Whether to print metric values over each point. Default is False.

  • num_decimals (int, optional) – Number of decimal places to show if print_values is True. Default is 2.

Returns:

Plotly Figure object representing the error plot.

Return type:

Plotly Figure

verona.visualization.metrics.line_plot_metric(data: DataFrame, x_label: str = 'Dataset', y_label: str = 'Accuracy', reduction: Literal['mean', 'max', 'min', 'median'] = None, y_min: float = 0.0, y_max: float = 100.0, font_size: int = 15, print_values: bool = False, num_decimals: int = 2) Figure[source]

Generates a line chart from input data.

Parameters:
  • data (pd.DataFrame) – Pandas DataFrame where the columns name correspond to the categories to be represented on the X-axis and the values are either single numerical values or NumPy Arrays. If arrays are used, the reduction parameter will be applied.

  • x_label (str, optional) – Label for the X axis. Default is 'Dataset'.

  • y_label (str, optional) – Label for the Y axis. Default is 'Accuracy'.

  • reduction (Literal['mean', 'max', 'min', 'median'], optional) – The reduction function to be applied if the values in the data dictionary are NumPy Arrays.

  • y_min (float, optional) – The minimum value for the Y-axis. Default is 0.0.

  • y_max (float, optional) – The maximum value for the Y-axis. Default is 100.0.

  • font_size (int, optional) – Font size of the text in the plot. Default is ``15` .

  • print_values (bool, optional) – If True, metric values are printed over each point. Default is False.

  • num_decimals (int, optional) – Number of decimals to display if print_values is True. Default is 2.

Returns:

Plotly Figure object representing the line chart.

Return type:

Plotly Figure

verona.visualization.metrics.plot_metric_by_prefixes_len(data: DataFrame, metric_label: str = 'Accuracy', font_size: int = 15, print_values: bool = False, num_decimals: int = 2) Figure[source]

Generates a mixed plot, where the bar chart indicates the number of prefixes of each length and the line chart indicates the value of the chosen metric for each prefix length.

Parameters:
  • data (pd.DataFrame) – Pandas DataFrame where the column names indicate the length of the prefixes and the associated values indicate 1- the value of the metric and 2- the number of prefixes of that length.

  • metric_label (str, optional) – Label for the right Y-axis. Default is 'Accuracy'.

  • font_size (int, optional) – Font size of the text in the plot. Default is 15.

  • print_values (bool, optional) – Whether to print metric values over each point. Defaults is False.

  • num_decimals (int, optional) – Number of decimal places to show if ‘print_values’ is True. Default is 2.

Returns:

Plotly Figure object representing the bar chart and the line chart.

Return type:

PLotly Figure

verona.visualization.stattests module

verona.visualization.stattests.plot_posteriors_plackett(plackett_results: PlackettLuceResults, save_path=None)[source]

Plot the posteriors of the Plackett-Luce model (quantiles 95%, 05% and 50%). If two approaches do not overlap, they have a significative different ranking.

Parameters

save_path: String that indicates the path where the plot will be saved. If None, the plot will not be saved.

Returns

Matplotlib Figure : ``Matplotlib Figure of the aforementioned plot

Examples

>>> result_matrix = pd.DataFrame([[0.75, 0.6, 0.8], [0.8, 0.7, 0.9], [0.9, 0.8, 0.7]])
>>> plackett_ranking = PlackettLuceRanking(result_matrix, ["a1", "a2", "a3"])
>>> results = plackett_ranking.run(n_chains=10, num_samples=300000, mode="max")
>>> plot = plot_posteriors_plackett(results, save_path=None)
>>> print(plot)