Concepts / Understanding Univariate Statistics for Feature Selection

Understanding Univariate Statistics for Feature Selection

When a dataset has many features, a natural first question is which of them deserve to be kept.

  • Programming

Choosing Which Features to Keep

When a dataset has many features, a natural first question is which of them deserve to be kept. One family of answers works by looking at each feature by itself. Instead of asking how a group of features behaves together, you ask a narrower question: for this one feature, is there a statistically significant relationship with the target? You repeat that question for every feature, then keep the ones whose relationship is strongest.

Methods built this way are called univariate statistics. The word univariate signals the key constraint of the method: each test considers only one feature at a time. Almost everything about the approach follows from that constraint, including its practical strengths and its blind spots. This article traces both, step by step.

Tracing the Test One Feature at a Time

Picture the procedure as a pipeline. Every feature enters the test separately. For each one, the test produces a single answer about that feature's link to the target. The answers are then sorted by how confident they are, and the top of the list is kept. No feature is compared with another feature during the test, and no model is trained along the way.

All featuresevery candidate inputTest one featureagainst the target, aloneRank by confidencestrongest relationshipfirstKeep the top of thelistthe strongest featuresKept featurespassed onwardeach feature in turnone answer per featuresorted listtop k kept
Each feature is tested alone, the answers are ranked by confidence, and only the top of the list is kept.

Notice what the test is and is not doing. It does not build a predictive model, and it does not try out different combinations of features. It produces, for each feature, an answer to one question about that feature's link to the target. The selection step then sorts the features by how confident each answer is and keeps the strongest ones.

Where a Single Feature Looks Useless

The defining weakness of univariate tests is that a feature will be discarded if it is only informative when combined with another feature. A single feature can look like noise while a pair of features predicts the target perfectly. To see how this happens, consider a small invented dataset with two binary features, a and b, and a binary target y. Each row lists a, b, and then y. The target is 1 exactly when the two features differ. This pattern is known as exclusive or.

What do you think happens?

Using only the rows where a is 0, and then only the rows where a is 1, what average of y would you expect? Think about how y behaves in each group before reading on.

Reveal answer
Answer:

The average of y is 0.5 for both values of a.

When a is 0, y is 0 in one row and 1 in another, so the average is 0.5. When a is 1, y is again 1 in one row and 0 in another, so the average is again 0.5. Knowing a alone tells you nothing about whether y is 0 or 1.

aby
000
011
101
110

An invented dataset in which y is 1 exactly when a and b differ

Worked example

Testing each feature in isolation

Average the target y over the matching rows for each value of a and each value of b, then decide whether either feature stands out.

  1. 1
    Feature a equals 0

    The matching rows are (0, 0, 0) and (0, 1, 1). Their y values are 0 and 1, so the average is 0.5.

  2. 2
    Feature a equals 1

    The matching rows are (1, 0, 1) and (1, 1, 0). Their y values are 1 and 0, so the average is 0.5.

  3. 3
    Feature b equals 0

    The matching rows are (0, 0, 0) and (1, 0, 1). Their y values are 0 and 1, so the average is 0.5.

  4. 4
    Feature b equals 1

    The matching rows are (0, 1, 1) and (1, 1, 0). Their y values are 1 and 0, so the average is 0.5.

  5. 5
    Compare with the target

    Every average is 0.5, so neither feature separates the rows with y equal to 1 from those with y equal to 0 when examined alone.

Result

A univariate procedure would score both a and b as uninformative and could discard them, even though together they determine y completely.

a = 0average y is 0.5b = 0average y is 0.5a = 0, b = 0y = 0a = 1average y is 0.5b = 1average y is 0.5a = 0, b = 1y = 1a = 1, b = 0y = 1a = 1, b = 1y = 0
Examined one at a time, a and b show no pattern in y. Examined together, each combination of values fixes y completely.

The left column of the comparison is what a univariate test sees. Each feature alone gives the same average, so both look uninformative. The right column is what the combination reveals. Once a and b are considered together, every pair of values determines y. The univariate procedure never looks at that right-hand column, which is why the feature pair can be discarded.

Why the Tests Are Fast and Model-Free

Univariate tests are often very fast to compute, and they do not require building a model. Because no model has to be trained, the cost of the selection step stays low even when there are many features to examine. Each feature is tested once against the target. This makes the approach a practical first pass over a large set of candidate inputs.

The same tests are also independent of whatever model you apply after feature selection. The scores they produce do not depend on which learning method you choose later. You can therefore run the selection once and then experiment with different downstream models without repeating the feature analysis for each one. The diagram below shows where this filter sits in the overall workflow.

Full set offeaturesall candidate inputsUnivariate filterscores each feature aloneSelected featuresstrongest relationshipsModel trainingany learning methodTrained modeluses the selected featurespassed inkeeps the toponly these featuresfitted
The univariate filter runs before any model is trained, and it passes only the selected features forward.

What gets passed from the filter to the model is only the list of selected features. The filter does not hand over a trained model or a set of combined features. Because the scores were computed without reference to the model, the same selected set can feed several different models in turn.

Naming the Method: ANOVA

The univariate approach has a specific name in classification problems, where the target is a category rather than a number. There, univariate statistics is also known as analysis of variance, usually abbreviated ANOVA. When you meet the term in a feature selection setting, read it as the same idea described above: an individual test of each feature's relationship with the target, followed by keeping the features with the strongest relationships.

Mistakes Beginners Make

  • Common mistake

    Treating a low univariate score as proof that a feature is useless

    What it looks like

    In the a and b dataset, both features average 0.5 for y, so a single-feature test suggests they carry no information.

    Why it fails

    A feature can be informative only in combination with another feature. The univariate test examines one feature at a time and cannot detect that interaction.

    Do this instead

    Treat univariate scores as one first-pass signal. Before discarding a feature, consider whether it could matter in combination with others.

  • Common mistake

    Assuming the selection depends on the model you will train later

    What it looks like

    Running the univariate test again for each downstream model you want to try.

    Why it fails

    The scores come from tests that are independent of the later model, so the feature analysis does not change with the learning method.

    Do this instead

    Run the selection once, then reuse the selected features across different downstream models.

  • Common mistake

    Believing ANOVA is a different technique from univariate statistics in feature selection

    What it looks like

    Looking for a separate method when a categorical target appears in the same feature selection task.

    Why it fails

    In classification problems, univariate statistics is also known as analysis of variance, so the two names refer to the same approach.

    Do this instead

    Read ANOVA as univariate statistics applied to a categorical target.

  • Common mistake

    Ranking features and keeping the strongest ones without checking how many features are kept at the end

Practice: Judging Univariate Results

MEDIUM

A univariate test scores feature c and feature d and finds that each one, examined alone, shows no clear relationship with the target. Using the exclusive-or dataset as a model, explain whether it would be safe to discard both features, and state what you would check before deciding.

Hints
  • Ask whether each feature's average of the target changes across its values.
  • Consider whether a pair of features could together determine the target even when each one alone does not.
  • Think about whether the selection step can see combinations of features at all.

Key Takeaways

  • Univariate statistics tests each feature individually against the target for a statistically significant relationship, then keeps the features with the strongest relationships.
  • Because each test considers one feature at a time, a feature that is informative only in combination with another can be wrongly discarded.
  • The tests are often very fast, need no model to be built, and are independent of whichever model is applied after selection.
  • In classification problems, where the target is a category, univariate statistics is also known as analysis of variance (ANOVA).

Related concepts

More concepts starting with U