spacr.response_distribution¶
Compare a response distribution before and after transformation.
The module applies the same transformation and distribution classifier used by the regression pipeline. Its combined histogram therefore provides a diagnostic of how the selected transformation changes the response and the candidate model family.
Functions¶
|
Format a statistical caption for a |
|
Compare response distributions before and after transformation. |
|
Summarize and classify a response distribution. |
|
Draw the before/after comparison on a pyqtgraph plot. |
|
Plot response distributions before and after transformation. |
|
Apply the regression pipeline's response transformation. |
Module Contents¶
- spacr.response_distribution.caption(result: Dict[str, Any]) str[source]¶
Format a statistical caption for a
compare()result.- Parameters:
result – response-distribution comparison result to render.
- spacr.response_distribution.compare(values: Sequence[float], transform: str) Dict[str, Any][source]¶
Compare response distributions before and after transformation.
- Parameters:
- Returns:
dict – The original and transformed arrays, their summaries, the normalized transformation name, and flags indicating whether values changed and whether the transformed values require a separate axis.
- spacr.response_distribution.describe(values: Sequence[float]) Dict[str, Any][source]¶
Summarize and classify a response distribution.
- Parameters:
values (sequence of float) – Response values before or after transformation. Non-finite values are excluded.
- Returns:
dict – Sample size, range, skewness, D’Agostino normality-test p-value, regression-family identifier, and display label. The family is empty when fewer than eight finite observations are available or classification fails.
- spacr.response_distribution.fast_panel(values: Sequence[float], transform: str, plot=None, dependent_variable: str = '')[source]¶
Draw the before/after comparison on a pyqtgraph plot.
The same picture
panel()draws, on the screen’s own renderer, so the figure a run writes and the figure a tab shows are one scene. Both distributions go on ONE pair of axes as outlines rather than on two stacked panels: the question is whether the transform moved the shape, and two shapes on separate axes with separate scales is the one layout that cannot answer it.- Parameters:
values (sequence of float) – Response values. Non-finite values are excluded.
transform (str) – Transformation name, as
transformed()accepts.plot (FastPlot or None, default=None) – Where to draw. One is created when omitted.
dependent_variable (str, default="") – The response’s name, for the axis label.
- Returns:
FastPlot or None – The plot drawn on, or None when there is nothing finite to draw.
- spacr.response_distribution.panel(values: Sequence[float], transform: str, ax=None, dependent_variable: str = '')[source]¶
Plot response distributions before and after transformation.
- Parameters:
values (sequence of float) – Response values to compare.
transform (str) – Transformation to apply.
ax (matplotlib.axes.Axes, optional) – Axes on which to draw. A standalone figure and axes are created when omitted.
dependent_variable (str, optional) – Response name shown on the horizontal axis.
- Returns:
dict – Result from
compare(), augmented with the primary axes under"axes".
- spacr.response_distribution.transformed(values: Sequence[float], transform: str) numpy.ndarray[source]¶
Apply the regression pipeline’s response transformation.
- Parameters:
values (sequence of float) – Response values to transform.
transform (str) – Transformation accepted by
spacr.ml.apply_transformation().
- Returns:
numpy.ndarray – Transformed values. Values are returned unchanged for
"none", an unsupported transformation, or a transformation that cannot be applied.
Nested helpers¶
- caption.one(part: Dict[str, Any]) str¶
Format one side of the captured before/after comparison.
- Parameters:
part – distribution summary returned by
describe().- Returns:
the display name alone when no family or finite statistics are available; otherwise the name followed by finite normality and skewness statistics.
spacr/response_distribution.py:160