Plot and calculate kernels

Examples use import kernelmix as km. See the tutorial for a complete analysis.

Plotting

Matplotlib is an optional dependency and is imported only when a plot is requested.

km.plot_trace(fit, parameter="lambda", indices=None, ax=None)
km.plot_pips(fit, ax=None)
km.plot_response(curve, ax=None)
km.plot_overall(effect, ax=None)
km.plot_surface(surface, ax=None)
km.plot_survival(prediction, row=0, ax=None)

Each function returns axes, creating them when ax=None. The caller controls display, export and styles. Trace indices selects a vector component, such as indices=0 for the first beta. Traces exclude warmup. PIP plots require selection.

plot_response accepts a univariate curve; plot_overall accepts an overall effect. Both show pointwise posterior intervals. plot_surface needs at least two values per grid and shows the posterior mean, with zero-centered colors when centered; its result retains interval limits. Use separate curves for different exposure units.

Kernel helper

km.gaussian_kernel(Z1, Z2=None, r=None)

Returns the Gaussian kernel between supplied rows. Z2=None reuses Z1 and r=None uses unit relevance. Relevance must be nonnegative. Inputs are used directly, without a fitted training transform.

Method sources