Sub topic 5
Classifying Y and X as continuous or discrete
This chapter assumes you know the DMAIC cycle, can read histograms and box plots, and understand sample versus population. You also need to be able to state a null and alternative hypothesis. The first step in choosing a test is to classify your data. This chapter shows how to do that for the output (Y) and the inputs (X).
Why the classification comes first
In the Analyze phase you test whether a suspected input (X) affects the output (Y). Y is the process result you care about, such as cycle time or defect status. X is a factor that might explain Y, such as shift, supplier, or oven temperature.
Test families are built for particular combinations of data types. A t-test compares means, and a mean is only meaningful for continuous or count-like measurements. A chi-square test compares counts across categories, so it needs categorical data. If you classify a variable wrongly, you shortlist the wrong tests and may get answers that look precise but mean nothing.
Classify Y first, because it defines the question. Then classify each X.
The two types
Continuous data can take any value within a range, limited only by how finely you measure. Time, length, weight, temperature, and pressure are continuous. Differences between values are meaningful, and averages make sense.
Discrete data can take only separate values. It comes in three common forms:
| Form | Description | Example |
|---|---|---|
| Binary | Two outcomes | Pass or fail, defective or not |
| Categorical (nominal) | Named groups with no natural order | Shift A, B, C; supplier; machine ID |
| Count | Whole-number tallies of events | Defects per unit, complaints per day |
Ordinal data, such as a 1 to 5 satisfaction rating, is a fourth case. The values are ordered, but the gaps between them are not necessarily equal. The edge cases below cover how to handle it.
A practical decision flow
Edge cases that cause mistakes
Measurement resolution
A continuous quantity measured with a coarse instrument can look discrete. If a caliper reads only to the nearest millimetre and your parts vary by 3 mm in total, you may see only four distinct values. The underlying characteristic is still continuous. Prefer a finer instrument, since a coarse one throws away information. As a rule of thumb, you want at least about 10 distinct values across the observed range.
Counts versus continuous measurements
Defects per unit is a count. With large counts, such as 200 or more events per sample, it behaves much like continuous data. With small counts, such as 0, 1, or 2, it does not. The distribution is skewed and bounded at zero, so a test that assumes a normal shape can mislead. Decide with the data's actual distribution in view.
Derived rates and percentages
A percentage looks continuous but may come from discrete data. If 12 of 200 units fail, the "6% defect rate" is a summary of a binary variable (defective or not) across 200 units. Test it as a proportion. Do not treat a column of percentages as ordinary continuous values unless each percentage comes from a large denominator and the denominators are similar.
Ordinal ratings
A satisfaction score from 1 to 5 is ordered, but "4" is not necessarily twice "2". Many teams treat ordinal data as categorical, or use rank-based tests. Averaging a 5-point scale can be defensible with enough responses, but state that choice in your report.
Numeric codes that are really categories
Machine ID 1, 2, 3 is categorical even though the values are numbers. Software will happily compute a mean machine ID, and it is meaningless. Check the meaning of each column, not its storage type.
Continuous X used at a few settings
Suppose oven temperature is set at 180, 190, and 200 °C in an experiment. The variable is continuous in nature. You have a choice of treatment:
- Treat X as discrete with three groups and compare means with ANOVA. This makes no assumption about the shape of the relationship.
- Treat X as continuous and fit a regression. This is more powerful if the relationship is roughly linear, and it lets you predict at untested temperatures.
The choice depends on your question, and both can be legitimate.
Y that you can choose to measure either way
You can sometimes measure the same characteristic as continuous or as binary. For example, you can record the actual fill weight, or only whether it fell inside specification. Continuous measurement carries more information, so it needs smaller samples to detect the same shift. Binary pass/fail records throw that information away. When measurement cost allows it, collect the continuous value.
What the classification suggests
Once Y and X are classified, you can shortlist test families. The next chapter builds the full selection map. This table is a preview.
| Y | X | Typical family |
|---|---|---|
| Continuous | Discrete, 2 groups | Two-sample or paired t-test |
| Continuous | Discrete, 3 or more groups | One-way ANOVA |
| Continuous | Continuous | Correlation, simple regression |
| Discrete | Discrete | Proportion test, chi-square |
| Discrete | Continuous | Logistic regression (outside this tutorial's scope) |
Classifying columns in code
A quick script can propose a classification for every column in a dataset. It cannot know what a column means, so treat its output as a prompt for review.
import pandas as pd
df = pd.DataFrame({
"cycle_time_s": [41.2, 39.8, 44.1, 40.5, 42.7, 43.3, 41.9, 40.1],
"defective": ["yes", "no", "no", "yes", "no", "no", "no", "yes"],
"shift": ["A", "B", "A", "C", "B", "C", "A", "B"],
"defects_per_unit": [0, 2, 1, 0, 3, 1, 0, 2],
"temp_setting_c": [180, 190, 200, 180, 190, 200, 180, 190],
})
def propose_type(series, few_levels=6):
"""Return a proposed data type. A human must confirm it."""
if pd.api.types.is_bool_dtype(series) or not pd.api.types.is_numeric_dtype(series):
n = series.nunique()
return "discrete: binary" if n == 2 else "discrete: categorical"
integer_valued = bool((series % 1 == 0).all())
if integer_valued and series.nunique() <= few_levels:
return "REVIEW: integer with few levels (count, category code, or coarse measurement)"
return "continuous"
for name in df.columns:
print(f"{name:18s} -> {propose_type(df[name])}")Running this labels cycle_time_s as continuous, defective as binary, and shift as categorical. It flags defects_per_unit and temp_setting_c for review. That is the correct outcome. The first is a count, and the second is a continuous factor set at three levels. The script cannot tell them apart, but you can.
Recording the classification in your project
Write the classification into the project's data collection plan, next to the operational definition of each variable. A minimal record has four fields:
- The variable name and its role (Y or X).
- The data type: continuous, binary, categorical, or count.
- The measurement unit and resolution.
- The planned test family.
This record also helps your team catch problems early, such as a coarse gauge or a pass/fail Y where a measurement was possible.
Exercise
A team studies whether three suppliers (X) affect the number of scratches per panel (Y). Scratches per panel range from 0 to 3 for most panels. Classify Y and X, and explain why the classification of Y needs care.
Show answer
X is discrete categorical, because supplier is a named group with no order. Y is a discrete count of events. It needs care because the counts are small and bounded at zero, so the distribution is skewed and a test that assumes normal data may mislead. The team should check the distribution before choosing between ANOVA and an alternative. They could also consider whether recording panel-level measurements, such as total scratch length, would give a continuous Y.
Exercise
A technician records whether each bottle's fill weight is "in spec" or "out of spec". The scale actually displays the weight to 0.1 g. Is it better to analyze the pass/fail label or the weight? Give one reason.
Show answer
Analyze the weight when it is available. It is continuous and carries more information than the binary label, so a given shift in the process can be detected with a smaller sample. The pass/fail label can always be derived from the weight later.