Skip to content

Process capability analysis charts

daspi.plotlib.precast.ProcessCapabilityAnalysisCharts(source, target, *, spec_limits, hue='', dist='norm', error_values=(), strategy='norm', agreement=6, possible_dists=DIST.COMMON, stretch_figsize=False)

Bases: JointChart

A class for creating process capability analysis charts.

This class extends the JointChart class and provides methods for creating process capability analysis charts. It allows you to visualize process capability analysis data and perform various analysis tasks.

PARAMETER DESCRIPTION
source

The source data.

TYPE: DataFrame

target

The target (dependant) variable.

TYPE: str

spec_limits

The specification limits for the process capability analysis.

TYPE: SpecLimits

hue

The hue variable for the chart, by default ''.

TYPE: str DEFAULT: ''

dist

The probability distribution use for creating feature data (the theoretical values). Default is 'norm'.

TYPE: scipy stats rv_continuous DEFAULT: 'norm'

error_values

If the process data may contain coded values for measurement errors or similar, they can be specified here, by default [].

TYPE: tuple of float DEFAULT: ()

strategy

Which strategy should be used to determine the control limits (process spread): - eval: The strategy is determined according to the given evaluate function. If none is given, the internal evaluate method is used. - fit: First, the distribution that best represents the process data is searched for and then the agreed process spread is calculated - norm: it is assumed that the data is subject to normal distribution. The variation tolerance is then calculated as agreement * standard deviation - data: The quantiles for the process variation tolerance are read directly from the data. by default 'norm'

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

agreement

Specify the tolerated process variation for which the control limits are to be calculated. - If int, the spread is determined using the normal distribution agreementσ, e.g. agreement = 6 -> 6σ ~ covers 99.75 % of the data. The upper and lower permissible quantiles are then calculated from this. - If float, the value must be between 0 and 1.This value is then interpreted as the acceptable proportion for the spread, e.g. 0.9973 (which corresponds to ~ 6 σ) by default 6

TYPE: float or int DEFAULT: 6

possible_dists

Distributions to which the data may be subject. Only continuous distributions of scipy.stats are allowed, by default DIST.COMMON

TYPE: tuple of strings or rv_continous DEFAULT: COMMON

stretch_figsize

If True, the height and width of the figure are stretched based on the number rows and columns in the axes grid. If a float is provided, the figure size is stretched by the given factor. If a tuple of two floats is provided, the figure size is stretched by the given factors for the x and y axis, respectively. by default False.

TYPE: bool | float | Tuple[float, float] DEFAULT: False

Examples:

import daspi as dsp

df = dsp.load_dataset('drop_card')
target = 'distance'

chart = dsp.ProcessCapabilityAnalysisCharts(
        source=df,
        target=target,
        spec_limits=dsp.SpecLimits(0, float(df.loc[0, 'usl'])),
        hue='method'
    ).plot(
    ).stripes(
    ).label(
        fig_title='Process Capability Analysis',
        sub_title='Drop Card Experiment',
        target_label='Distance (cm)',
        info=True)

ProcessCapabilityAnalysisChartsDocstringExample

spec_limits = spec_limits instance-attribute

The specification limits for the process capability analysis.

dist = dist instance-attribute

The probability distribution use for creating feature data (the theoretical values).

kw_estim = dict(error_values=error_values, strategy=strategy, agreement=agreement, possible_dists=possible_dists) instance-attribute

Keyword arguments for the ProcessEstimator instances used for calculating the capability indices.

n_groups = source.groupby(hue).ngroups if hue else 1 instance-attribute

The number of hue groups in the source data.

processes()

Get a dictionary of ProcessEstimator instances that are used for calculating the capability indices.

RETURNS DESCRIPTION
Dict[str, ProcessEstimator]

A dictionary where: - Keys: The hue categories or the target name if no hue is used. - Values: The corresponding ProcessEstimator instances.

process_descriptions(exclude=())

Get a DataFrame containing the descriptions of each process.

This method generates a DataFrame that contains the descriptions of each process, excluding any specified columns.

PARAMETER DESCRIPTION
exclude

Attributes to exclude from the summary statistics, by default ().

TYPE: Tuple[str, ...] DEFAULT: ()

RETURNS DESCRIPTION
DataFrame

A DataFrame containing the descriptions of each process.

plot(**kwds_cpi)

Plot the process capability analysis charts.

This method plots the process capability analysis charts, including scatter plots, probability density functions, Gaussian kernel density estimation, and capability confidence intervals.

PARAMETER DESCRIPTION
kwds_cpi

Additional keyword arguments for the capability confidence interval plot.

TYPE: dict DEFAULT: {}

RETURNS DESCRIPTION
Self

The ProcessCapabilityAnalysisCharts instance, for method chaining.

stripes(*, mean=True, median=True, control_limits=True)

This method adds stripes to the process capability analysis charts, including mean, median, control limits and specification limits.

PARAMETER DESCRIPTION
mean

Whether to add a line for the mean, by default True.

TYPE: bool DEFAULT: True

median

Whether to add a line for the median (if applicable), by default True.

TYPE: bool DEFAULT: True

control_limits

Whether to add lines for the control limits (if applicable), by default True.

TYPE: bool DEFAULT: True

RETURNS DESCRIPTION
Self

The ProcessCapabilityAnalysisCharts instance, for method chaining.

label(*, fig_title='', sub_title='', feature_label=(), target_label='', info=False)

Label the process capability analysis charts.

This method labels the process capability analysis charts with custom labels and titles.

PARAMETER DESCRIPTION
fig_title

The title of the figure, by default ''.

TYPE: str DEFAULT: ''

sub_title

The subtitle of the figure, by default ''.

TYPE: str DEFAULT: ''

feature_label

The labels for the features. If not provided, default labels will be used. The tuple should contain five elements. By default, the labels are: ('Observation order', '', 'Quantiles of standard normal distribution', '', '')

TYPE: Tuple[str, ...] DEFAULT: ()

target_label

The label for the target variable, by default ''.

TYPE: str DEFAULT: ''

info

Whether to display information about the chart. If True, the information will be displayed. If a string is provided, it will be used as the title of the information box. By default, the information is not displayed.

TYPE: bool | str DEFAULT: False

RETURNS DESCRIPTION
Self

The ProcessCapabilityAnalysisCharts instance, for method chaining.