Skip to content

Gage study model

daspi.anova.model.GageStudyModel(source, target, reference, tolerance, resolution, u_cal, u_bi=None, u_lin=None, u_rest=None, k=2, tolerance_ratio=0.2, q_ms_limit=0.15, cg_limit=1.33, cgk_limit=1.33, resolution_ratio_limit=0.05, alpha=0.05, bias_corrected=False)

Bases: LinearModel

Calculates uncertainties for a measurement system (MSA Type 1 study), supporting one or multiple GageEstimator instances. If multiple are provided, the uncertainty for linearity is also calculated.

PARAMETER DESCRIPTION
source

Pandas DataFrame as tabular data in a long format used for the model.

TYPE: pandas DataFrame

target

Column name for source data holding the measurement values.

TYPE: str

reference

Column name holding the reference values for the measured parts. This column is also used to identify which measured values belong to which reference part. If the column has missing values, the pandas method ffill() is used to ensure that the column is filled. The uncertainty u_lin is determined if the column contains several reference values, unless a known measurement uncertainty is given with the argument u_lin.

TYPE: str

tolerance

The specification limits for the measurement system. This can be a float, a SpecLimits instance or a Specification instance. If a float is given, it is interpreted as the tolerance (e.g., 0.1 for ±0.05).

TYPE: float | SpecLimits | Specification

resolution

The resolution of the measurement system. If None, the resolution is estimated from the data. If a float is given, it is interpreted as the resolution (e.g., 0.01 for a resolution of 0.01).

TYPE: float | None

u_cal

The measurement uncertainty of the gage used to measure the reference value. This parameter quantifies the uncertainty associated with the measurement device itself, reflecting how much the measured value could vary due to the inherent limitations of the gage. If a float is specified, it is assumed to be the expanded uncertainty with a coverage factor of k = 2, which typically corresponds to a 95% confidence level. Please note that the coverage factor of the calibration is independent of the coverage factor selected here.

TYPE: MeasurementUncertainty | float

u_bi

The uncertainty for bias u_BI can be specified here if it is known; otherwise, it will be determined from the data. This parameter represents the systematic error that may affect the measurement results, indicating how much the measured values deviate from the true value due to consistent inaccuracies. The default is None.

TYPE: MeasurementUncertainty | None DEFAULT: None

u_lin

The measurement uncertainty for linearity u_LIN is determined if multiple reference values are provided. This parameter assesses how well the measured values conform to a linear relationship with the reference values. However, it will not be determined if a known measurement uncertainty is provided here. The default is None.

TYPE: MeasurementUncertainty | None DEFAULT: None

u_rest

The uncertainty for further uncertainties not covered by the parameters above. This parameter accounts for all additional sources of uncertainty that may affect the overall measurement but are not specifically addressed by the default uncertainties provided here. It provides a more comprehensive assessment of measurement uncertainty by considering factors that may arise from environmental conditions, operator influences, or other unknown variables. If known, it can be specified here; otherwise, the default value is None.

TYPE: MeasurementUncertainty | None DEFAULT: None

k

The coverage factor for expanded uncertainty. It is used as a multiplier to determine the expanded uncertainty based on the standard uncertainty. The value of k is typically set to reflect the desired confidence level in the measurement results. Default is 2, typical values are: - k=2 corresponds to a confidence interval of 95.45% - k=3 corresponds to a confidence interval of 99.73%

TYPE: int | float DEFAULT: 2

tolerance_ratio

The ratio of the tolerance to the standard deviation of the measurement system. If the ratio is below this limit, the measurement system is considered unacceptable. Default is 0.2.

TYPE: float DEFAULT: 0.2

q_ms_limit

The limit for the Q_MS value. If the Q_MS is below this limit, the measurement system is considered acceptable. Default is 0.15.

TYPE: float DEFAULT: 0.15

cg_limit

The limit for the Gage R&R study's Cg value. If the Cg value below this limit, the measurement system is considered unacceptable. Default is 1.33.

TYPE: float DEFAULT: 1.33

cgk_limit

The limit for the Gage R&R study's Cgk value. If the Cgk value is below this limit, the measurement system is considered unacceptable. Default is 1.33.

TYPE: float DEFAULT: 1.33

resolution_ratio_limit

The ratio of the resolution to the standard deviation of the measurement system. If the ratio is below this limit, the measurement system is considered unacceptable. Default is 0.05.

TYPE: float DEFAULT: 0.05

bias_corrected

Indicates whether the bias is corrected for the Gage R&R study. If True, the bias is not included in the measurement uncertainty; otherwise, it is included. Default is False.

TYPE: bool DEFAULT: False

Examples:

Run the following command in a jupyter notebook to get the html output of gage or you can also use print(repr(gage)) instead:

import daspi as dsp
df = dsp.load_dataset('grnr_layer_thickness')
gage = dsp.GageStudyModel(
    source=df,
    target='result_gage',
    reference='reference',
    u_cal=df['U_cal'][0],
    tolerance=df['tolerance'][0],
    resolution=df['resolution'][0],)
chart = dsp.GageStudyCharts(
        gage, stretch_figsize=1.5
    ).plot(
    ).stripes(
    ).label(
    ) # .save('path/to/file.png')
gage # or print(repr(gage))
Notes

If only one reference is provided, the uncertainty for linearity (LIN) will be 0.0. If multiple references are provided, the uncertainty for linearity will be calculated based on the standard deviation of the biases of the GageEstimator instances.

gage property

Returns the GageEstimator instances (read-only).

ref_gages property

Returns a list of GageEstimator instances used in the model (read_only).

If only one reference is used, it returns a list containing one GageEstimator of that reference. If multiple references are used, it returns a list of GageEstimator instances for each reference part measured.

bias_corrected property

Whether the bias is corrected for the Gage R&R study. If True, the bias itself is not included in the measurement uncertainty; otherwise, it is.

bias property

Returns the bias of the Gage study (read-only).

n_samples property

The number of samples used in the Gage study (read-only).

n_references property

Get the amount of references used in the study (read-only).

n_replications property

Get the number of replications for each reference (read-only).

tolerance property

Returns the tolerance of the first GageEstimator instance (read-only).

resolution property

Returns the resolution of the first GageEstimator instance (read-only).

k property writable

Get the coverage factor k used in uncertainty calculations.

This property returns the coverage factor, which is a multiplier used to determine the expanded uncertainty based on the standard uncertainty. The value of k is typically set to reflect the desired confidence level in the measurement results.

Set the coverage factor with a positive number, typical values are: - k=2 corresponds to a confidence interval of 95.45% - k=3 corresponds to a confidence interval of 99.73%

u_cal property

The expanded uncertainty of the calibration.

u_re property

The uncertainty of the resolution of the testing system (read-only).

u_bi property

The uncertainty of the bias of the testing system (read-only).

u_lin property

The uncertainty of linearity of the measurement system (read-only).

u_evr property

The uncertainty of the expanded variance ratio of the testing system (read-only).

u_rest property

The uncertainty of the repeatability of the testing system (read-only).

u_ms property

The uncertainty of the measurement system (read-only).

q_ms_limit property

Get the provided limit for the Q_MS as float between 0 and 1 (read-only).

T_min_UMS property

The minimum allowed tolerance for this testing system based on the uncertainty (read-only).

from_gage_estimators(gages, k=2, bias_corrected=False) staticmethod

Create a GageStudyModel from a list of GageEstimator instances. This method is useful when you already have GageEstimator instances and want to create a GageStudyModel without needing to provide the source DataFrame and other parameters again.

PARAMETER DESCRIPTION
gages

A list of GageEstimator instances to create the model from.

TYPE: GageEstimator | List[GageEstimator]

k

The coverage factor for expanded uncertainty. It is used as a multiplier to determine the expanded uncertainty based on the standard uncertainty. The value of k is typically set to reflect the desired confidence level in the measurement results. Default is 2, typical values are: - k=2 corresponds to a confidence interval of 95.45% - k=3 corresponds to a confidence interval of 99.73%

TYPE: int | float DEFAULT: 2

RETURNS DESCRIPTION
GageStudyModel

A new GageStudyModel instance created from the provided GageEstimator instances.

references_analysis()

Returns a DataFrame with the analysis of the reference parts.

The analysis includes the GageEstimator statistics for each reference part, such as Cg, Cgk, resolution ratio, and bias.

RETURNS DESCRIPTION
DataFrame

Analysis of the reference parts with GageEstimator statistics.

Examples:

import daspi as dsp
df = dsp.load_dataset('grnr_layer_thickness')
gage = dsp.GageStudyModel(
    source=df,
    target='result_gage',
    reference='reference',
    u_cal=df['U_cal'][0],
    tolerance=df['tolerance'][0],
    resolution=df['resolution'][0],)
print(gage.references_analysis())
     Ref     mean     Bias         s      R
1  0.101  0.10066 -0.00034  0.000688  0.003

capabilities()

Returns a DataFrame with the capabilities of the measurement system.

The capabilities include Cg, Cgk, and the ratio of resolution the .

RETURNS DESCRIPTION
DataFrame

Capabilities for Cp, Cpk, Cg, Cgk and the ratio of resolution to standard deviation.

Examples:

import daspi as dsp
df = dsp.load_dataset('grnr_layer_thickness')
gage = dsp.GageStudyModel(
    source=df,
    target='result_gage',
    reference='reference',
    u_cal=df['U_cal'][0],
    tolerance=df['tolerance'][0],
    resolution=df['resolution'][0],)
print(gage.capabilities())
            Value  Limit  Capable     T_min
Cg        2.179005   1.33     True  0.018311
Cgk       1.932051   1.33     True  0.021711
RE_ratio  0.033333   0.05     True  0.020000
U_MS      0.096371   0.15     True  0.019274
p_BI      0.001024   0.05    False       NaN

uncertainties()

Returns a DataFrame with the uncertainties for the measurement system.

The table contains the following rows:

  • CAL: Calibration uncertainty
  • RE: Resolution uncertainty
  • BI: Bias uncertainty
  • LIN: Linearity uncertainty
  • EVR: Equipment Variation on the Reference
  • REST: Other known and provided uncertainty
  • MS: Measurement System uncertainty

The table contains the following columns:

  • u: The measurement uncertainty for the respective components
  • U: The expanded uncertainty as k * u
  • Q: The Quality Indicator serves as a quality indicator for the measurement process, reflecting how well the measurement system performs in relation to the specified requirements and tolerances.
  • rank: The rank of the uncertainty component, where a lower rank indicates a more significant contribution to the overall uncertainty.
RETURNS DESCRIPTION
DataFrame

Uncertainties for CAL, RE, BI, LIN, EVR, REST, MS.

Examples:

import daspi as dsp
df = dsp.load_dataset('grnr_layer_thickness')
gage = dsp.GageStudyModel(
    source=df,
    target='result_gage',
    reference='reference',
    u_cal=df['U_cal'][0],
    tolerance=df['tolerance'][0],
    resolution=df['resolution'][0],)
print(gage.uncertainties())
             u         U         Q  rank
CAL   0.000100  0.000200  0.013333   4.0
RE    0.000289  0.000577  0.038490   2.0
BI    0.000196  0.000393  0.026173   3.0
LIN   0.000000  0.000000  0.000000   NaN
EVR   0.000688  0.001377  0.091785   1.0
REST  0.000000  0.000000  0.000000   NaN
MS    0.000723  0.001446  0.096371   NaN