Class Comparison Methods in Data Mining

Yo Yogesh.M Updated 24 Oct 2026
7 min read ·Lesson 47 of 50
In this post

Describing a single group of data in isolation only goes so far. Saying "graduate students tend to have a GPA above 3.5" is a fact, but it becomes far more useful once it can be answered alongside the

Describing a single group of data in isolation only goes so far. Saying "graduate students tend to have a GPA above 3.5" is a fact, but it becomes far more useful once it can be answered alongside the question "...compared to what?" Class comparison (also called class discrimination) is the data mining technique that answers exactly that: it compares a target class against one or more contrasting classes to find the patterns and attributes that actually distinguish them, rather than describing either group on its own.

This is a close relative of class characterization, which describes a single class by itself (for example, summarizing the typical attributes of graduate students with no reference to any other group). Class comparison uses many of the same underlying techniques, but the goal shifts from "what does this class look like?" to "what makes this class different from that one?" — comparing sales figures from one year against another, or comparing the profile of graduate students against undergraduates, are both class comparisons in this sense.

Classes Must Be Structurally Comparable

A comparison is only meaningful when the classes involved share the same kind of attributes. Comparing "Computer Science students" against "Physics students" works because both groups are described by the same fields — GPA, program, residence, and so on. Comparing "a person" against "an address" against "an item" does not work, because these are not different groups of the same kind of entity; they don't share a common attribute structure to compare across in the first place. This constraint sounds obvious once stated, but it is the reason class comparison is defined specifically as comparing classes of comparable objects, not an unrestricted comparison between any two arbitrary things.

Synchronous Generalization: Comparing at the Same Level of Detail

A comparison is misleading unless both classes are described at the same level of detail. Comparing "sales in Vancouver" (a city) against "sales in the USA" (an entire country) does not isolate any real difference between the two groups — it mixes a difference in geographic scope in with whatever difference in sales actually exists, making the result impossible to interpret cleanly. Synchronous generalization avoids this by generalizing both the target class and the contrasting class to the same level of a shared concept hierarchy before comparing them — both summarized at the city level, or both at the state level, or both at the country level, so that the only thing varying between the two descriptions is the class itself, not the granularity of the description.

The Class Comparison Process

1. Data Collection. Relevant data is gathered and split into the target class (the group of primary interest) and one or more contrasting classes (the group or groups it will be compared against).

2. Dimension Relevance Analysis. When many attributes are available, only the ones actually useful for distinguishing the classes are kept. This step exists because comparing on irrelevant attributes adds noise and computational cost without adding insight — an attribute like a student's phone number does nothing to explain why one class differs from another, even though it might be present in the raw data.

3. Synchronous Generalization. The target class is generalized to a chosen level of abstraction, and the same level is then applied to the contrasting class or classes, exactly as described above.

4. Presentation of Results. The comparison is displayed using tables, charts (bar charts, pie charts, curves), cross-tabulations, or rules. A measure called count% — the percentage of records within each class that fall into a given category — is the standard way to make the comparison readable at a glance.

A Worked Comparison: Graduate vs. Undergraduate Students

To see what this looks like with real numbers, take a target class of 200 graduate students and a contrasting class of 300 undergraduate students, each with a GPA and a residence status, generalized into GPA bands for a fair comparison:

import pandas as pd

table = pd.crosstab(df["gpa_band"], df["status"], normalize="columns") * 100
print(table.round(1))

Output:

status        graduate  undergraduate
gpa_band
GPA 2.0-2.99       1.5           40.3
GPA 3.0-3.49      35.5           46.0
GPA 3.5-4.0       63.0           13.7

This is class comparison doing its actual job: 63.0% of graduate students fall in the top GPA band, compared to only 13.7% of undergraduates, while 40.3% of undergraduates fall in the lowest band compared to just 1.5% of graduates. Neither percentage alone — "63% of graduates have a high GPA" — would be nearly as informative without the undergraduate figure sitting next to it for contrast. The same generalized comparison applied to residence status tells a different, equally clear story:

residence    graduate  undergraduate
off-campus      74.5           40.3
on-campus       25.5           59.7

Graduate students in this data are far more likely to live off-campus than undergraduates are — a pattern that a description of graduate students alone, without the undergraduate contrast, would never surface.

Discriminant Rules and d-weight

Class comparison results are often written up as discriminant rules — statements that highlight how strongly a particular condition points toward one class over another. The strength of that association is measured by d-weight, computed for a specific condition as:

d-weight = count(condition AND target class) / [count(condition AND target class) + count(condition AND contrasting class)]

A d-weight close to 1 means the condition is heavily associated with the target class; a value close to 0 means it is heavily associated with the contrasting class; a value near 0.5 means the condition does not discriminate between the two at all. Computing it directly on the same student data confirms what the GPA table above already suggested:

count_target = ((df["gpa_band"] == "GPA 3.5-4.0") & (df["status"] == "graduate")).sum()
count_contrast = ((df["gpa_band"] == "GPA 3.5-4.0") & (df["status"] == "undergraduate")).sum()
d_weight = count_target / (count_target + count_contrast)
print(count_target, count_contrast, round(d_weight, 3))

Output:

126 41 0.754

Out of every student with a GPA in the 3.5–4.0 band, roughly 75.4% are graduate students — turning the earlier table into a single, direct measure of how strongly "high GPA" points toward the graduate class. Running the same calculation on residence status shows the opposite pattern:

count(on-campus AND graduate) = 51
count(on-campus AND undergraduate) = 179
d-weight (graduate | on-campus) = 0.222

A d-weight of 0.222 means living on-campus actually points away from the graduate class — only 22.2% of on-campus students in this data are graduate students, consistent with the off-campus/on-campus percentages shown earlier. This is what makes discriminant rules useful for summarizing a comparison concisely: instead of reading two full cross-tabulations, a single d-weight per condition ranks which attributes discriminate strongly between the classes and which barely discriminate at all.

Expressing a Comparison as a Query

Because class comparison is a well-defined operation, it can be expressed directly as a query rather than only performed ad hoc. The classic form (in the same DMQL style used to specify data mining tasks generally) for the graduate-vs-undergraduate comparison looks like this:

use University_Database
mine comparison as "graduate_students vs_undergraduate_students"
in relevance to name, gender, program, birth_place, birth_date, residence, phone_no, GPA
for "graduate_students"
where status in "graduate"
versus "undergraduate_students"
where status in "undergraduate"
analyze count%
from student

Each clause maps directly onto the process above: for ... versus ... defines the target and contrasting classes, in relevance to names the attributes dimension-relevance analysis should consider, and analyze count% specifies exactly the measure used in the worked example — the query is a precise, executable specification of the comparison, rather than a vague request to "compare these two groups."

Key Terms

  • Attributes — the data fields being compared across classes (name, gender, program, GPA, and so on).
  • Concept hierarchy — the levels of abstraction (city → state → country; specific GPA → GPA band) that synchronous generalization moves between.
  • Thresholds — configurable limits that control how far generalization proceeds or how many attributes are retained during dimension relevance analysis.
  • Relevance threshold — the cutoff used to decide which attributes are important enough to keep for the comparison.

0 Comments

Reviewed before they appear

No comments yet.

Data Mining
Introduction to Data Mining Data Mining Implementation Process Data Mining Architecture Data Mining Techniques KDD: Knowledge Discovery in Databases History of Data Mining Data Mining Tools Data Mining vs Machine Learning Facebook Data Mining Social Media Data Mining Methods Clustering in Data Mining Text Data Mining Bagging vs Boosting Data Mining vs Data Warehousing Social Media Data Mining Data Mining: Bayesian Classifiers Data Mining: World Wide Web Different Types of Clustering Bitcoin Mining and Blockchain Data Mining Orange Data Mining Data Mining vs Big Data Decision Tree Induction Educational Data Mining Data Mining in Healthcare Apriori Algorithm Data Integration in Data Mining Difference Between Data Mining and Text Mining Discretization in Data Mining Redundancy and Correlation in Data Mining Classification of Data Mining Systems Classification Algorithms in Data Mining Data Generalization in Data Mining Classification and Prediction in Data Mining Regression in Data Mining What Is an Outlier in Data Mining Data Cleaning in Data Mining Data Processing in Data Mining Data Mining Task Primitives Web Content Mining, Web Structure Mining, and Web Usage Mining Binning in Data Mining KDD vs. Data Mining Noise in Data Mining BIRCH in Data Mining Stemming in Data Mining Feature Transformation in Data Mining Visual and Audio Data Mining Class Comparison Methods in Data Mining Data Selection in Data Mining Tasks and Functionalities of Data Mining Ubiquitous and Invisible Data Mining
Ask about this post
AI Ask about this post

Ask questions about Class Comparison Methods in Data Mining and get answers drawn from it.

Signed-in readers only.