pydvl.reporting.plots
¶
shaded_mean_std
¶
shaded_mean_std(
data: ndarray,
abscissa: Optional[Sequence[Any]] = None,
num_std: float = 1.0,
mean_color: Optional[str] = "dodgerblue",
shade_color: Optional[str] = "lightblue",
title: Optional[str] = None,
xlabel: Optional[str] = None,
ylabel: Optional[str] = None,
ax: Optional[Axes] = None,
**kwargs
) -> Axes
The usual mean \(\pm\) std deviation plot to aggregate runs of experiments.
Deprecation notice
This function is bogus and will be removed in the future in favour of properly computed confidence intervals.
PARAMETER | DESCRIPTION |
---|---|
data |
axis 0 is to be aggregated on (e.g. runs) and axis 1 is the data for each run.
TYPE:
|
abscissa |
values for the x-axis. Leave empty to use increasing integers. |
num_std |
number of standard deviations to shade around the mean.
TYPE:
|
mean_color |
color for the mean |
shade_color |
color for the shaded region |
title |
Title text. To use mathematics, use LaTeX notation. |
xlabel |
Text for the horizontal axis. |
ylabel |
Text for the vertical axis |
ax |
If passed, axes object into which to insert the figure. Otherwise, a new figure is created and returned
TYPE:
|
kwargs |
these are forwarded to the ax.plot() call for the mean.
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
Axes
|
The axes used (or created) |
Source code in src/pydvl/reporting/plots.py
plot_ci_array
¶
plot_ci_array(
data: NDArray,
level: float,
type: Literal["normal", "t", "auto"] = "normal",
abscissa: Optional[Sequence[str]] = None,
mean_color: Optional[str] = "dodgerblue",
shade_color: Optional[str] = "lightblue",
ax: Optional[Axes] = None,
**kwargs
) -> Axes
Plot values and a confidence interval from a 2D array.
Supported intervals are based on the normal and the t distributions.
PARAMETER | DESCRIPTION |
---|---|
data |
A 2D array with M different values for each of the N indices.
TYPE:
|
level |
The confidence level.
TYPE:
|
type |
The type of confidence interval to use.
TYPE:
|
abscissa |
The values for the x-axis. Leave empty to use increasing integers. |
mean_color |
The color of the mean line. |
shade_color |
The color of the confidence interval. |
ax |
If passed, axes object into which to insert the figure. Otherwise, a new figure is created and the axes returned.
TYPE:
|
**kwargs |
Additional arguments to pass to the plot function.
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
Axes
|
The matplotlib axes. |
Source code in src/pydvl/reporting/plots.py
plot_ci_values
¶
plot_ci_values(
values: ValuationResult,
level: float,
type: Literal["normal", "t", "auto"] = "auto",
abscissa: Optional[Sequence[str]] = None,
mean_color: Optional[str] = "dodgerblue",
shade_color: Optional[str] = "lightblue",
ax: Optional[Axes] = None,
**kwargs
)
Plot values and a confidence interval.
Uses values.data_names
for the x-axis.
Supported intervals are based on the normal and the t distributions.
PARAMETER | DESCRIPTION |
---|---|
values |
The valuation result.
TYPE:
|
level |
The confidence level.
TYPE:
|
type |
The type of confidence interval to use. If "auto", uses "norm" if the minimum number of updates for all indices is greater than 30, otherwise uses "t".
TYPE:
|
abscissa |
The values for the x-axis. Leave empty to use increasing integers. |
mean_color |
The color of the mean line. |
shade_color |
The color of the confidence interval. |
ax |
If passed, axes object into which to insert the figure. Otherwise, a new figure is created and the axes returned.
TYPE:
|
**kwargs |
Additional arguments to pass to the plot function.
DEFAULT:
|
RETURNS | DESCRIPTION |
---|---|
The matplotlib axes. |
Source code in src/pydvl/reporting/plots.py
spearman_correlation
¶
spearman_correlation(vv: List[OrderedDict], num_values: int, pvalue: float)
Simple matrix plots with spearman correlation for each pair in vv.
PARAMETER | DESCRIPTION |
---|---|
vv |
list of OrderedDicts with index: value. Spearman correlation is computed for the keys.
TYPE:
|
num_values |
Use only these many values from the data (from the start of the OrderedDicts)
TYPE:
|
pvalue |
correlation coefficients for which the p-value is below the
threshold
TYPE:
|
Source code in src/pydvl/reporting/plots.py
plot_shapley
¶
plot_shapley(
df: DataFrame,
*,
level: float = 0.05,
ax: Optional[Axes] = None,
title: Optional[str] = None,
xlabel: Optional[str] = None,
ylabel: Optional[str] = None,
prefix: Optional[str] = "data_value"
) -> Axes
Plots the shapley values, as returned from compute_shapley_values, with error bars corresponding to an \(\alpha\)-level Normal confidence interval.
PARAMETER | DESCRIPTION |
---|---|
df |
dataframe with the shapley values
TYPE:
|
level |
confidence level for the error bars
TYPE:
|
ax |
axes to plot on or None if a new subplots should be created
TYPE:
|
title |
string, title of the plot |
xlabel |
string, x label of the plot |
ylabel |
string, y label of the plot |
RETURNS | DESCRIPTION |
---|---|
Axes
|
The axes created or used |
Source code in src/pydvl/reporting/plots.py
plot_influence_distribution
¶
plot_influence_distribution(
influences: NDArray[float_], index: int, title_extra: str = ""
) -> Axes
Plots the histogram of the influence that all samples in the training set have over a single sample index.
PARAMETER | DESCRIPTION |
---|---|
influences |
array of influences (training samples x test samples) |
index |
Index of the test sample for which the influences will be plotted.
TYPE:
|
title_extra |
Additional text that will be appended to the title.
TYPE:
|
Source code in src/pydvl/reporting/plots.py
plot_influence_distribution_by_label
¶
plot_influence_distribution_by_label(
influences: NDArray[float_], labels: NDArray[float_], title_extra: str = ""
)
Plots the histogram of the influence that all samples in the training set have over a single sample index, separated by labels.
PARAMETER | DESCRIPTION |
---|---|
influences |
array of influences (training samples x test samples) |
labels |
labels for the training set. |
title_extra |
Additional text that will be appended to the title.
TYPE:
|