Skip to content

FittedDensity

FittedDensity

Bases: DensityCurve

Class for plotting a fitted probability density function (PDF) as a curve along the feature axis.

Unlike GaussianKDE, which always estimates the density non-parametrically from the raw data and controls the curve width via margin, this class fits (or assumes) a distribution to the data according to strategy and evaluates its PDF. The width of the curve is controlled by agreements instead of margin: the curve spans the range between the quantiles corresponding to the largest agreement value.

If strategy is (or evaluates to) 'data', no distribution is fitted at all; the PDF/CDF is instead estimated directly from the raw data using the same Gaussian kernel density estimation as GaussianKDE, only the curve width is still controlled by agreements rather than margin.

PARAMETER DESCRIPTION
source

Pandas long format DataFrame containing the data source for the plot.

TYPE: pandas DataFrame

target

Column name of the target variable for the plot.

TYPE: str

feature

Column name of the feature variable for the plot, by default ''.

TYPE: str DEFAULT: ''

strategy

Which strategy should be used to fit/assume the distribution whose PDF is evaluated, see SpreadOpacity. If 'data', no distribution is fitted and the PDF/CDF is estimated directly from the raw data via Gaussian kernel density estimation instead (same as GaussianKDE). Default is 'data'.

TYPE: (eval, fit, norm, data) DEFAULT: 'eval'

agreements

Specifies the tolerated process variation for calculating quantiles. The largest agreement value also determines the width of the plotted curve. See SpreadOpacity for details. Default is DEFAULT.AGREEMENTS = (2, 4, 6), corresponding to (±1σ, ±2σ, ±3σ).

TYPE: tuple[float, ...] or tuple[int, ...] DEFAULT: AGREEMENTS

possible_dists

Distributions to which the data may be subject, see SpreadOpacity. Default is DIST.COMMON.

TYPE: tuple of strings or rv_continous DEFAULT: COMMON

height

Height of the density curve at its maximum. If None, the curve is drawn using the real estimated probability (not normalized to a fixed height), by default None.

TYPE: float | None DEFAULT: None

fill

Flag whether to fill in the curves, by default True

TYPE: bool DEFAULT: True

cumulative

If True, the cumulative distribution (CDF) is plotted instead of the density (PDF), by default False.

TYPE: bool DEFAULT: False

target_on_y

Flag indicating whether the target variable is plotted on the y-axis, by default True.

TYPE: bool DEFAULT: True

color

Color to be used to draw the artists. If None, the first color is taken from the color cycle, by default None.

TYPE: str | None DEFAULT: None

ax

The axes object for the plot. If None, the current axes is fetched using plt.gca(). If no axes are available, a new one is created. Defaults to None.

TYPE: Axes | None DEFAULT: None

visible_spines

Specifies which spines are visible, the others are hidden. If 'none', no spines are visible. If None, the spines are drawn according to the stylesheet. Defaults to None.

TYPE: Literal['target', 'feature', 'none'] | None DEFAULT: None

hide_axis

Specifies which axes should be hidden. If None, both axes are displayed. Defaults to None.

TYPE: Literal['target', 'feature', 'both'] | None DEFAULT: None

**kwds

Additional keyword arguments that have no effect and are only used to catch further arguments that have no use here (occurs when this class is used within chart objects).

DEFAULT: {}

kw_default property

Default keyword arguments for plotting (read-only)

estimate

Evaluate the fitted/assumed distribution's PDF over the range spanned by the largest agreements value.

estimate_cumulative

Evaluate the fitted/assumed distribution's CDF directly (analytically) over the range spanned by the largest agreements value.