superstats.utils.plotting#
Shared data preparation helpers for plotting functions.
Functions
|
Resolve dict-or-array estimates/targets into stacked arrays plus display names. |
- superstats.utils.plotting.prepare_plot_data(estimates, targets, variable_keys=None, variable_names=None)[source]#
Resolve dict-or-array estimates/targets into stacked arrays plus display names.
For dict input, per-key arrays are stacked along a new last axis in the order given by variable_keys (or all keys, by default). For array input, estimates/targets are used as-is and variable_keys is ignored.
- Parameters:
- estimates
Mapping[str,np.ndarray]ornp.ndarray If a dict, per-key arrays sharing the same leading shape, to be stacked into a new last axis. If an array, used directly (already includes the params axis). Must be the same kind (dict or array) as targets.
- targets
Mapping[str,np.ndarray]ornp.ndarray Same convention as estimates, one fewer axis than estimates in the array case (no sample axis). Must be the same kind (dict or array) as estimates.
- variable_keyssequence
ofstrorNone,optional, default:None Which keys to select from estimates/targets when they are dicts, and in what order. By default, all keys, in dict insertion order. Ignored if estimates/targets are arrays.
- variable_namessequence
ofstrorNone,optional, default:None Display names for the columns, in the same order as the selected variables. Defaults to variable_keys (if dicts) or param_0, param_1, … (if arrays).
- estimates
- Returns:
- estimates_arr, targets_arr, names
tuple Stacked arrays of shape (…, num_params) and a list of display names, one per column.
- estimates_arr, targets_arr, names
- Raises:
ValueErrorIf estimates and targets are not both dicts or both arrays, if variable_keys references a key missing from either dict, or if variable_names doesn’t match the number of selected/resolved variables.
- Parameters:
- Return type: