Data Mining vs Machine Learning: How Are They Related?

Data mining is not a branch of machine learning. The two overlap, share many methods and differ in aim. We compare them, work through an example of each and see the role of statistics.
Statistics
Programming
Explainer
Author

Abdullah Al Mahmud

Published

November 30, 2026

Two overlapping circles. Data mining alone holds association rules, database queries and reports. Machine learning alone holds deployed models, representation learning and generative models. The overlap holds classification, regression and clustering.

The two fields share many methods, but each also has its own ground.

Data mining is not a branch of machine learning (ML). They are better seen as overlapping sister fields, with different origins, goals and toolkits. Both rely heavily on supervised and unsupervised learning, though often for different ends.

How they relate and differ

  • Data mining draws on statistics, databases and machine learning. Its main goal is knowledge discovery: sifting through large, often messy data (data warehouses, transaction logs) to uncover patterns, associations and anomalies that people can understand and act on.
  • Machine learning is a branch of artificial intelligence that draws on computer science and statistics. Its main goal is prediction and automation: building models that learn from data and make accurate decisions on new, unseen data.
Aspect Data mining Machine learning
Main aim Find understandable patterns in existing data Build models that work well on new data
Roots Databases, statistics, business intelligence Artificial intelligence, computer science, statistics
Typical output Reports, rules, customer segments Predictive models, automated systems
Human role Central: an analyst interprets the findings Often small once the model is running
TipRule of thumb

Data mining uses machine learning algorithms as tools, along with database queries and statistical tests, to gain insight. Machine learning uses data to train models.

Supervised and unsupervised learning in both

The same method can serve either field. What differs is the question we ask.

Supervised learning (labelled data)

Each record comes with the answer, such as “spam” or “not spam”.

  • In machine learning: mainly accurate prediction, such as image classification, spam detection and forecasting, using neural networks, gradient boosting or support vector machines (SVMs).
  • In data mining: often to understand why something happens, or to score records. A decision tree can help explain why customers leave, and logistic regression can show which factors go with fraud.

Unsupervised learning (unlabelled data)

The records have no answers, so the method looks for structure on its own.

  • In machine learning: representation learning, dimensionality reduction (principal component analysis, autoencoders) and generative modelling.
  • In data mining: central to exploration, such as clustering (customer segments), anomaly detection (network intrusions) and association rule mining (“customers who buy X also buy Y”). The last one is a classic of data mining.

Examples of both

The same business can ask both kinds of question:

Field of work A data mining question A machine learning question
Shop Which products are bought together? What will this customer buy next?
Bank What do fraudulent payments have in common? Is this payment fraudulent?
Phone company What kinds of customers do we have? Will this customer leave next month?
Email Which topics appear in complaints? Is this message spam?

Data mining: what sells together?

A shop records five baskets:

Basket Items
1 bread, butter
2 bread, butter, milk
3 bread, butter
4 bread, jam
5 milk, jam

We check the rule “bread → butter” with three measures:

  • Support: the share of all baskets that hold both items.
  • Confidence: among baskets with bread, the share that also hold butter.
  • Lift: the confidence divided by the share of all baskets with butter.

\[ \begin{aligned} \text{support} &= 3/5 = 0.60 \\ \text{confidence} &= 3/4 = 0.75 \\ \text{lift} &= 0.75 / 0.60 = 1.25 \end{aligned} \]

A lift above 1 means that bread buyers pick up butter more often than shoppers in general. The shop might place the two items close together. Five baskets are far too few for a real decision, of course.

baskets <- list(
  c("bread", "butter"),
  c("bread", "butter", "milk"),
  c("bread", "butter"),
  c("bread", "jam"),
  c("milk", "jam")
)

support <- function(items) {
  mean(sapply(baskets, function(basket) all(items %in% basket)))
}

both <- support(c("bread", "butter"))
confidence <- both / support("bread")
lift <- confidence / support("butter")

cat(sprintf("support %.2f, confidence %.2f, lift %.2f\n",
            both, confidence, lift))
support 0.60, confidence 0.75, lift 1.25
baskets = [
    {"bread", "butter"},
    {"bread", "butter", "milk"},
    {"bread", "butter"},
    {"bread", "jam"},
    {"milk", "jam"},
]

def support(items):
    return sum(items <= basket for basket in baskets) / len(baskets)

both = support({"bread", "butter"})
confidence = both / support({"bread"})
lift = confidence / support({"butter"})

print(f"support {both:.2f}, confidence {confidence:.2f}, lift {lift:.2f}")
support 0.60, confidence 0.75, lift 1.25

Machine learning: will a student pass?

Now we have labelled data on study hours and results:

Study hours 1 2 3 5 6 8
Result fail fail fail pass pass pass

We want a prediction for new students. A very simple method, nearest neighbour, copies the result of the student whose study hours are closest:

# study hours and results
hours  <- c(1, 2, 3, 5, 6, 8)
result <- c("fail", "fail", "fail", "pass", "pass", "pass")

predict_result <- function(new_hours) {
  result[which.min(abs(hours - new_hours))]
}

for (h in c(2.2, 4.8)) {
  cat(sprintf("%.1f hours -> %s\n", h, predict_result(h)))
}
2.2 hours -> fail
4.8 hours -> pass
train = [(1, "fail"), (2, "fail"), (3, "fail"),
         (5, "pass"), (6, "pass"), (8, "pass")]   # (study hours, result)

def predict(hours):
    nearest = min(train, key=lambda row: abs(row[0] - hours))
    return nearest[1]

for hours in [2.2, 4.8]:
    print(hours, "hours ->", predict(hours))
2.2 hours -> fail
4.8 hours -> pass

Here we do not look for a rule to report. We care about whether the predictions are right, so a real project would test the model on data it has not seen.

The role of statistics in both

Statistics supplies the tools to describe data, to judge whether a pattern is real, and to measure how far we can trust a prediction.

Statistical idea In data mining In machine learning
Descriptive statistics and charts Explore the data, spot errors and outliers Check and prepare the input variables
Sampling Study a manageable part of a huge database Split data into training and test sets
Probability Measure how strong a rule is Build classifiers such as naive Bayes
Regression Explain which factors go with an outcome Predict a number or a class
Hypothesis testing Check that a pattern is not due to chance Check that one model really beats another
Variability Judge how stable the customer segments are Cross-validation, bias and variance, overfitting

Statistics in the shop example

Our lift value is a comparison with statistical independence. If buying bread and buying butter were unrelated, we would expect:

\[ \begin{aligned} P(\text{both}) &= P(\text{bread}) \times P(\text{butter}) \\ &= 0.8 \times 0.6 = 0.48 \end{aligned} \]

The observed share is 0.60, and the ratio of the two is the lift:

\[ \text{lift} = 0.60 / 0.48 = 1.25 \]

Could a gap of this size arise by chance? With five baskets, it easily could. A test of independence on much more data would help us decide.

WarningSearch long enough and patterns appear

If we test 1,000 rules that reflect no real relationship, each at the 5% level of significance, we expect about 50 of them to look significant by chance. So we correct for the number of tests, or confirm a rule on fresh data.

Statistics in the student example

The model gives an answer for any number of study hours, but it does not tell us how often it is right. To find out, we keep some students aside as a test set and measure the accuracy, the share of correct predictions. A model that does well on the training data but poorly on the test set is overfitting: it has learnt the noise along with the pattern.

Summing up

Data mining and machine learning share many algorithms. We lean towards data mining when we want to discover and explain patterns, and towards machine learning when we want to predict or automate. Many projects do both, and both rest on statistics. We say more about this in How Statistics Powers Machine Learning, AI and Robotics.

R-bloggers

R posts from Stat Mania are also shared on R-bloggers, a hub of R blogs.