DS 227 · Graduate · Week 2

KDD Frameworks

CRISP-DM, SEMMA, and the KDD process: project structures that turn unplanned exploration into defensible work.

Knowledge Discovery in Data · University of the Philippines Cebu

Outline

Three frameworks for one process

Key terms · 1 of 2

Seven terms for describing process

Each is explained again where it is first used, and all appear in the glossary at the end. Last week’s terms (dataset, record, pattern, model, pipeline…) still apply.

process model

A named, step-by-step plan for running a data project. Also called a framework.

e.g. CRISP-DM, SEMMA, the KDD process

KDD process

The academic original (Fayyad, 1996): selection, preprocessing, transformation, data mining, interpretation.

e.g. the five-stage pipeline from Week 1

CRISP-DM

CRoss-Industry Standard Process for Data Mining: six phases in a loop, starting from the question.

e.g. the framework this course runs on

SEMMA

Sample, Explore, Modify, Model, Assess: five steps from the software company SAS.

e.g. starts with data already in hand

phase

One stage of a process model, with its own question and its own output.

e.g. Evaluation asks “could this be wrong?”

stakeholder

The person or group whose decision the analysis serves.

e.g. a town councillor deciding on water testing

iterate

Return to an earlier phase, applying what was recently learned.

e.g. Evaluation finds a problem → back to Business Understanding

Key terms · 2 of 2

CRISP-DM’s six phases and two terms from the example

One line each here; Part 2 gives each phase its own slide.

business understanding

Phase 1: identify whose decision the analysis serves and the exact question that would settle it.

e.g. “did the monthly fail rate rise after May?”

data understanding

Phase 2: examine the data: what each column means, and what looks unusual.

e.g. noticing the testing lab changed in May

data preparation

Phase 3: the decisions that turn raw rows into an analysable table.

e.g. what to do with a month that has no samples

modelling

Phase 4: choose and compute the summary or model that answers the question.

e.g. the average fail rate per lab

evaluation

Phase 5: check whether the result answers the question, and how it could be wrong.

e.g. “did the water change, or only the lab?”

deployment

Phase 6: put the result into real use, usually a sentence someone acts on.

e.g. a two-line note to the council, caveat included

rate

A count divided by what it is out of, often × 100 to make a percentage.

e.g. 9 failing out of 38 samples = 23.7%

confound

A third factor that changes together with the variable under study and can produce a false pattern.

e.g. a new testing lab, the same month the rate jumped

Previous session

Week 1: what KDD is

Knowledge discovery is the non-trivial extraction of valid, novel, useful patterns from data. This week covers the process that finds such patterns while avoiding self-deception.

Week 1 → Week 2

Definition → discipline. A definition specifies the destination; a framework specifies the order of steps and where errors commonly occur.

Why order matters

Steps performed out of order produce a confident answer to a question no one asked.

About the tool

CRISP-DM was written by five companies in the 1990s

1996

Conceived

Companies including Daimler, NCR and Teradata want a shared way to run data projects.

1997

EU funding

It becomes a European Union research project.

1999

Version 1.0

Presented at a workshop in Brussels and published as a guide.

2015

IBM extension

IBM releases ASUM-DM, which refines and extends CRISP-DM.

SourceWikipedia: CRISP-DM; Wirth & Hipp (2000)

About the tool

How widely CRISP-DM is used

SourceWikipedia: CRISP-DM (citing the KDnuggets polls)

Motivation

Analysis without a defined process

"Without a destination, any route is acceptable, and none can be justified."
The failure mode a framework exists to prevent
Part 1

The KDD process

Fayyad, Piatetsky-Shapiro & Smyth, 1996: the source of the field's vocabulary.

The five stages were introduced last week. This part revisits them as a process model and shows that data mining is only one of them.

Common error

Data mining as one stage of KDD

The term "data mining" is often used for the entire project. In the KDD paper it is a single stage, the algorithm run, surrounded by considerably more work.

KDD = the whole process

Selecting, cleaning, transforming, mining, and interpreting, from end to end.

Data mining = one stage inside it

The pattern-finding step. It is powerful, but its output is unreliable if the preceding stages were done poorly.

Pipeline

Five stages, four transformations

Raw Data Selection Target data Pre- processing Transform Features Data Mining Interpret / Evaluate → Knowledge Each arrow discards or reshapes data, and each is a decision by the analyst.
Stage by stage

Inputs and outputs of each stage

StageInputOutput
SelectionEverything recordedThe target subset worth studying
PreprocessingTarget data, including its flawsCleaned data: missing values, noise handled
TransformationClean rowsFeatures — reduced, encoded, scaled
Data miningFeatures + a goalPatterns: rules, clusters, a model
InterpretationRaw patternsKnowledge that supports action

Definitions

noise
random errors and oddities that hide the real signal
encoded / scaled
categories turned into numbers / numbers rescaled to a common range
rules / clusters
“if this, then that” statements / groups of similar records
Related terms

Data mining, statistics, and machine learning are distinct

Applications

Three everyday applications of KDD

Review question

Stages omitted by the phrase “data mining”

"We used data mining to find the pattern." Which KDD stages does that sentence quietly skip?

A · Selection & preprocessing
B · Transformation
C · Interpretation
D · All of the above

D — all of them.

"We ran the algorithm" omits the four stages that determined what data the algorithm received. Most errors occur in those stages.

Part 2

CRISP-DM

The Cross-Industry Standard Process for Data Mining, used in this week's lab.

Part 1 covered the academic five-stage pipeline. CRISP-DM adds two phases it omits: a first phase for the question and a last phase for using the answer.

Origin

Origin in industry practice

CRISP-DM was written in the late 1990s by companies managing many one-off analytics projects, which needed a shared, tool-agnostic method for running them. It remains the most widely used framework in industry.

Cross-industry

Designed to apply equally to a bank, a hospital, or a water utility.

Tool-agnostic

Does not prescribe Python, R (another programming language), or a spreadsheet; it structures the thinking.

Still dominant

Surveys repeatedly rank it the most-followed data-science process.

Definition

Definition: CRISP-DM

CRISP-DM (after Chapman et al., 2000)

A process model for data mining projects: six phases (business understanding, data understanding, data preparation, modelling, evaluation, deployment), each with defined tasks and outputs, run as a cycle rather than once.

PhaseIn this week’s water-testing example
1 · Business understandinga checkable question: did failures really rise after April?
3 · Data preparationcomputing fail_rate, and deciding what August’s 0 of 0 means
5 · Evaluationtesting the conclusion against the change of lab in May
back to 1the finding sends the analyst back to the question

Source: Chapman, Clinton, Kerber, Khabaza, Reinartz, Shearer & Wirth (2000), CRISP-DM 1.0: Step-by-step data mining guide (paraphrased).

Cycle

Six phases in a cycle

Business Understanding Data Understanding Data Preparation Modelling Evaluation Deploy- ment

CRISP-DM is a cooking cycle: identify the diners (business), check the pantry (data), wash and chop (preparation), cook (modelling), taste (evaluation), and serve (deployment); a poor result leads back to the menu.

Phase 1 of 6

Business Understanding

Before any number is computed: whose decision the analysis serves, and what would change the answer. This phase is the most often skipped and the most costly to skip. “Business” means whoever the work is for: a town, a clinic, a school.

The requirement is established before any analysis; a correct answer to a question no one asked is still a failure.

Converting a request into a question the data can settle

"Is our water getting worse?" expresses a concern; "Did the monthly fail rate rise after May?" can be checked.

Defining success in advance

The result that would count as an answer is decided before it is seen; otherwise any finding can be rationalised.

Phase 2 of 6

Data Understanding

The data is examined before it is trusted: every column, what each one means, and any anomalies that would invalidate naïve conclusions.

The contents and labels of the data are verified before the analysis is planned around them.

Reading the table carefully

A rise from 6% to 25% failures has a mundane explanation and an alarming one. Both are initially hypotheses.

Identifying unrecorded changes

If the measuring lab switched in the same month the numbers rose, the numbers may not be comparable.

Phase 3 of 6 · Most time-consuming phase

Data Preparation as a series of decisions

"Preparation is not cleaning for appearance. It is a series of decisions, each of which changes the answer and each of which must be defensible."
This week's lab, on the phase that takes 60–80% of a real project

Preparation is slow, but it affects the result more than the choice of model does.

Phase 4 of 6

Modelling

"Modelling" need not mean machine learning. It means choosing the summary that answers the question; sometimes a grouped average (one average per group, e.g. per lab) is the whole model.

The simplest method that answers the question is often preferable, because every step can be explained.

Matching the method to the question

Grouping fail rates by lab answers whether the labs differ, which is a different question from whether the water changed.

Simplicity as an advantage

An explainable summary is preferable to an unexplainable model. Complexity is justified only when the question requires it.

Phase 5 of 6

Evaluation

Evaluation checks whether the result answers the Phase-1 question and how it could be wrong. The analyst challenges the conclusion before anyone else does.

A cook tastes before serving and checks whether an odd flavour comes from the soup or from the tasting spoon (the measurement).

Evidence required for confidence

Specify one observation that would show the water genuinely worsened.

Evidence against the conclusion

If a stricter threshold (the cut-off level that counts as a fail) at the new lab explains the jump, the water may not have changed at all.

Phase 6 of 6

Deployment

Usually a sentence someone acts on, not a model in production (running automatically inside a real system). A discovery has effect only once it reaches the person making the decision.

The result must reach the decision-maker, together with a statement of its limitations.

Stating what the data shows

And, equally clearly, what is not yet supported.

Calibrated confidence

Hedging should not be so heavy that nothing is said, and certainty should not exceed the evidence.

Summary

The six phases, one line each

1

Business

Decision owner and question.

2

Data

Examine it; find anomalies.

3

Preparation

Decisions that shape the answer.

4

Modelling

The summary that answers it.

5

Evaluation

Checks for error.

6

Deployment

A sentence someone acts on.

CRISP-DM in numbers

Water-testing data through the six phases

MonthSamplesFailsFail rateLab
April4025.0%A
May38923.7%B
June411024.4%B
July39923.1%B
August00—B
Phase 1 · applied

A checkable question

Business Understanding converts the concern "Is the water worse?" into a test with a yes-or-no answer.

The precise question

"Did the mean monthly fail rate rise after April?": a quantity that can be computed and defended.

Success criterion, set in advance

A rise from ~5% to ~24% would count as real only if nothing else about the measurement changed.

Phase 3 · applied

Computing fail_rate requires a decision

Phase 4 · applied

A grouped average as a model

No machine learning is involved, only a grouped average, which answers a different question from the one posed.

LabMonthsMean fail rate
AApril5.0%
BMay–July23.7%

Observation

The rise coincides exactly with the switch from Lab A to Lab B, so "the water got worse" now has a competing explanation.

Phase 5 · applied

Testing the conclusion

"The failure rate quadrupled in the month a new lab took over the testing. The measuring instrument must be ruled out before the water is blamed."
Evaluation examines the obvious explanation critically
Phase 6 · applied

Reporting with a caveat

Here deployment is not a server but the sentence given to the town: claim, number, and the caveat that keeps it accurate.

The defensible finding

"Measured fail rates rose from ~5% to ~24% after April — but a lab change in May confounds it, so this is a flag to investigate, not proof the water worsened."

Role of the caveat

Without it, the report may raise a false alarm or miss a real one. The honest statement is the deliverable.

Iteration in the example

Evaluation leads back to the start

5

Evaluation found a confound

The lab switch could explain the entire rise.

1

Back to Business Understanding

New question: "Does the water differ, holding the lab fixed?"

2

Back to Data

Obtain comparable months: same lab, before and after.

Break

  Five minutes

After the break: a comparison of CRISP-DM with a competing framework.

Part 3

SEMMA

SAS's five-step process, deliberately narrower in scope.

Part 2 covered CRISP-DM’s six phases. This part adds a third framework and compares all three side by side to show what each omits.

Acronym

Sample · Explore · Modify · Model · Assess

S

Sample

Take a workable slice of the data.

E

Explore

Visualise; identify patterns and anomalies.

M

Modify

Clean, transform, engineer features.

M

Model

Fit the pattern-finding method.

A

Assess

Judge how well it holds up.

SEMMA is a cooking-competition round that starts with the ingredients provided and ends at the judges’ tasting, without asking who the meal is for or serving it.

Omitted phases

Phases omitted by SEMMA

It is deliberately limited to the technical core. This makes it concise, but risky if its omissions are overlooked.

No business understanding

SEMMA assumes someone already framed the problem. CRISP-DM makes that Phase 1.

No deployment

It ends at "Assess." Turning the result into action is outside the scope of the acronym.

Comparison

Three frameworks aligned by stage

KDD processCRISP-DMSEMMA
—Business Understanding— (missing)
SelectionData UnderstandingSample + Explore
Preprocessing + TransformationData PreparationModify
Data MiningModellingModel
Interpretation / EvaluationEvaluationAssess
Use of knowledgeDeployment— (missing)
SEMMA limitations

Risks of SEMMA’s omissions

It opens at Sample, which assumes data is already available, and closes at Assess. It includes no purpose and no follow-up action, which is a hidden risk.

No Business Understanding

Starting at Sample allows a flawless model of the wrong question.

No Deployment

Ending at Assess can leave a strong result unused in a notebook.

Continued value

For the technical middle, SEMMA's five steps are concise and repeatable, provided the middle is not mistaken for the whole.

Choosing a framework

Framework selection in practice

SituationFrameworkReason
A stakeholder with a vague requestCRISP-DMIt requires the purpose first
Data already in hand, iterating fastSEMMATight modelling loop
Explaining the field to a newcomerKDD processNames every transformation
Review question

Identifying the CRISP-DM phase

An analyst drops the August row because it has zero samples. Which CRISP-DM phase is this?

A · Business Understanding
B · Data Preparation
C · Modelling
D · Deployment

B — Data Preparation.

Deciding what to do with a broken row (drop, fill, or flag) is preparation. It is a judgment call that must be defensible, not a tidy-up.

Recommendation

Complementary frameworks

The frameworks are not alternatives to choose between. CRISP-DM structures the project; SEMMA's concise verbs suit the technical middle; KDD's vocabulary names the stages precisely.

CRISP-DM as the default

It is the most complete and the most widely understood, and this course uses it.

A checklist, not a constraint

Its value lies in catching a step that would otherwise be skipped, usually Phase 1 or Phase 5.

Effort distribution

Most of the work is not modelling

Understanding + Preparation Modelling Eval + Deploy ~60–80% of the effort modelling the payoff Effort across a typical KDD project
Common error

Proceeding directly to modelling

The tempting sequence is to open the notebook (a document of text and runnable code), load the CSV (a plain-text table file), and fit something (let a model learn from the data). It appears to be progress but produces a confident answer to a question no one asked.

Symptom

A polished result that cannot be linked to any required decision.

Remedy

The first hour should be spent in Phases 1 and 2 without code, as the framework requires.

Review question

The phase to revisit before publication

A team reports "fail rate rose from 6% to 25% after May." What CRISP-DM phase most needs revisiting before they publish?

A · Modelling — try a fancier method
B · Data Understanding — the lab changed in May
C · Deployment — write it up faster
D · Nothing — the numbers speak

B — Data Understanding.

If the measuring lab switched the same month, the before and after numbers may not be comparable. The analysis should return to this phase before any claim is made.

This week's lab

Walking a dataset through CRISP-DM

The lab takes one small water-quality dataset through all six phases. It requires almost no code: the reasoning is the work. ~45 minutes.

Main difficulties

A month with zero samples, a lab that switched mid-year, and three different "averages" that each tell a different story.

The deliverable

Two honest sentences for a councillor: what the data shows, and what cannot yet be claimed.

The lab’s code, explained

Two decisions, in pandas

The Week 1 lab opened a table and counted its gaps. This week’s lab adds a new column (the fail rate) and makes Data Preparation choices about a month with no data. The next two slides read that code line by line. Each block runs in the browser: select ▶ Run / Edit under it (the first run downloads Python, 10 to 20 seconds).

Lab · Parts 0–1

A fail-rate column and a month without data

  • pd.read_csv(io.StringIO(raw))read the ten-month table (typed as text in the variable raw) into a DataFrame, pandas’ table, called water
  • water["samples_failing"] / water["samples_taken"] * 100divide one column by another, row by row, then × 100: the fail rate as a percentage
  • water["fail_rate"] = (…).round(1)store the answer as a new column named fail_rate, rounded to 1 decimal
  • water.iloc[3:8]show rows by position: 3 up to, not including, 8 (April to August; positions count from 0)
  • the outputthe rate jumps from 6.7 to 25.4 exactly when the lab becomes Regional. August: 0 ÷ 0 has no answer, so pandas writes NaN (missing), not 0
import io, pandas as pd # raw holds the ten-month table as text (see the lab) water = pd.read_csv(io.StringIO(raw)) water["fail_rate"] = (water["samples_failing"] / water["samples_taken"] * 100).round(1) print(water.iloc[3:8]) month samples_taken samples_failing lab fail_rate 3 April 119 8 Municipal 6.7 4 May 122 31 Regional 25.4 5 June 120 29 Regional 24.2 6 July 117 33 Regional 28.2 7 August 0 0 Regional NaN

One line of pandas works on a whole column at once, like filling a formula down a spreadsheet column.

Lab · Part 2

Defaults as choices

Two ways to average the same fail_rate column.

  • water["fail_rate"].mean().mean() is a method (a function that belongs to a value, after a dot). pandas skips NaN by default, so it averages the 9 months that have data
  • .fillna(0)first fill every missing cell with 0, treating August as a perfect month
  • round(…, 1)a function (a named piece of work) that rounds the number in its brackets to 1 decimal
  • the output16.8 vs 15.1: the invented perfect month makes the water look 1.7 points better than any real month showed
print(round(water["fail_rate"].mean(), 1)) print(round(water["fail_rate"].fillna(0).mean(), 1)) 16.8 15.1

Leaving an unmarked exam out of the class average is honest; writing 0 on it changes the average and records something that never happened.

In the lab

The lab asks for the guard to be written explicitly (keep only months where samples were taken), so the choice is visible in the code instead of hidden in a default. Fill each ____, press ▶ Run, then press Check.

Exercise · 3 min

Writing the guard

The honest choice keeps only the months that have data, instead of counting August as 0%.

Tasks

  1. Predict how many months the guard keeps, and their mean fail rate.
  2. Select ▶ Run / Edit and run the code.
  3. Change the condition to water["lab"] == "Regional". How many months now, and what mean?

Result on the lecture laptop (select to reveal)

9 of 10 months kept, mean 16.8: the same as .mean(), which skips August’s NaN. Regional only: 6 months (August among them, still NaN), mean 25.2, against 6.2 for the Municipal lab’s four months.

kept = water[water["samples_taken"] > 0] # the guard: months with data print(len(water), "months,", len(kept), "kept") print(round(kept["fail_rate"].mean(), 1))
Summary

Four main points

Glossary

Week 2 terms

Readings

Readings for next week

Next week

Data scraping I

Web fundamentals and HTML parsing: how raw data is obtained before this process can begin.

DS 227 · Knowledge Discovery in Data