DS 227 · Graduate · Week 1

Knowledge Discovery in Data

The frameworks, methods, and ethics of deriving valid, novel, and useful knowledge from raw, messy data.

3 units · Blended learning (full online)

Outline

Session structure

Outline

Week 1 topics

Key terms · 1 of 2

Six terms for describing data

These terms recur throughout the semester. Each is explained again on the slide where it is first used, and all appear in the glossary at the end.

data

Recorded facts — numbers, text, dates, clicks — before anyone has interpreted them.

e.g. “7/1: 3 sachets kape” in a store’s notebook

dataset

A collection of data about one topic, usually arranged as a table.

e.g. two years of clinic appointments, saved as one file

record (row)

One entry in a dataset: everything recorded about one thing or event. One row of the table.

e.g. one appointment: patient, date, attended or not

attribute (column)

One property that every record has — one column of the table.

e.g. age, barangay, number of visits

feature

The data-mining term for an attribute, especially one constructed to help find a pattern.

e.g. “distance to the clinic”, worked out from the address

missing value

A cell where nothing was recorded. In code it shows up as NaN (“not a number”).

e.g. a patient with no contact number on file

Key terms · 2 of 2

Seven terms for turning data into knowledge

Memorisation is not required; each term is used later in this session.

pattern

A regularity that shows up across many records.

e.g. “no-shows rise on clinic days after heavy rain”

knowledge

A pattern that has passed four tests — valid, novel, useful, understandable — so someone can act on it.

e.g. “remind far-away patients when rain is forecast”

KDD

Knowledge Discovery in Data: the whole multi-step process from raw data to knowledge.

e.g. choose the data, clean it, reshape it, search it, judge the result

data mining

The one step inside KDD where a method searches the data for patterns.

e.g. sorting shoppers into groups that buy alike

algorithm

A fixed recipe of steps a computer follows, the same way every time.

e.g. “sort the list, then take the middle value”

model

A simplified summary of the data that describes a pattern or predicts an outcome.

e.g. the rule “lives over 4 km away + rain → likely to miss”

pipeline

A chain of stages where each stage’s output is the next stage’s input.

e.g. raw file → cleaned table → summary → chart

Motivation

Abundant data, scarce knowledge

Jeepney GPS pings, GCash payments, weather station readings, and census forms accumulate far faster than anyone can read them.

The gap

Storage grows exponentially (doubling again and again); human attention does not. Whatever is not processed into knowledge is effectively lost.

A store notebook that fills a new page every second cannot be read in full, so most of it goes unused without a method for finding what matters.

Data collected Data we can study by hand Time → the gap
Data sources

Four sources of data

Transactions

Sales, payments, enrollments, bookings: deliberately recorded, usually fairly clean, and the classic raw material for data mining.

Sensors & logs

GPS traces, weather stations, server logs, CCTV: recorded as a side effect, in very large volume, and rarely designed for analysis.

Human text & media

Posts, reviews, news articles, photos: rich in meaning but irregular in structure. Weeks 3–4 cover how to collect it.

Official statistics

Census, surveys, administrative registers. PSA OpenSTAT (the Philippine Statistics Authority’s free online tables) is our recurring example. Curated, documented, but aggregated: already added up into totals, so the individual records are gone.

Key terms

Structured, semi-structured, unstructured

Shape What it looks like Example
Structured Rows × labeled columns; a schema fixed in advance Enrollment table, POS sales, OpenSTAT extracts
Semi-structured Tagged and nested, but flexible; the structure is stored with the data JSON from an API, HTML pages, XML feeds
Unstructured No inherent fields; meaning must be extracted News articles, complaint emails, photos, audio

Definitions

schema
the fixed list of columns (and what kind of value each holds) a table must follow
HTML
the text format web pages are written in, full of tags like <p> (Week 3)
JSON / XML
text formats for nested data, e.g. {"name": "Ana", "visits": [3, 5]}
API
a service a website provides so programs can request its data directly (Week 4)
About the tool

“Knowledge discovery” was named at a 1989 workshop

1989

The term

Gregory Piatetsky-Shapiro coins “knowledge discovery in databases” for the first workshop on it.

1995

A conference

The KDD conference begins; it has run every year since.

1996

The definition

Fayyad, Piatetsky-Shapiro and Smyth publish the definition this course uses.

1998

ACM SIGKDD

The field becomes an official special-interest group of the ACM.

SourceWikipedia: Data mining; Wikipedia: SIGKDD

About the tool

How the field has grown

SourceWikipedia: SIGKDD; Wikipedia: Data mining

Part 1

Definition of knowledge discovery

A standard definition, examined one word at a time.

The raw material is now defined: records and attributes in a table. This part examines when a pattern in that table qualifies as knowledge.

Classic definition

Definition of KDD (Fayyad et al., 1996)

"The non-trivial process of identifying valid, novel, potentially useful, and ultimately understandable patterns in data."
— Fayyad, Piatetsky-Shapiro & Smyth, "From Data Mining to Knowledge Discovery in Databases," AI Magazine, 1996

Panning for gold, where patterns are the abundant sand and the four highlighted words are the sieve that keeps only the gold (knowledge).

The definition in detail

The four adjectives as filters

Valid

The pattern holds on new data, not only the sample (the part of the data that was studied). Guards against overfitting (learning quirks of this sample that will not repeat) and coincidence.

Novel

It reveals something not already known. "Sales rise in December" is valid but not a discovery.

Potentially useful

Someone can act on it: a decision, a policy, a product. Usefulness is judged by the domain, not the algorithm.

Understandable

A person can understand why it holds, immediately or after further explanation. A black-box score (a number from a method whose reasoning cannot be inspected) does not qualify on its own.

Validity

Spurious correlation

A standard textbook example: ice cream sales and drowning deaths rise and fall together month after month. The pattern is strong and the data are real, but the causal claim is false.

The lurking variable

Hot weather drives both. A pattern can be statistically real yet invalid as knowledge if it disappears once context is taken into account.

Definitions

correlation
two things that rise and fall together
causal claim
saying one thing makes the other happen
lurking variable
a hidden third thing driving both; also called a confounder
hold-out testing
checking a pattern on data kept aside and never searched

Validity checks covered in this course

  • Hold-out testing: whether it holds on unseen data (Week 7+)
  • Confounder analysis: which other variables move with it (Week 8)
  • Stability: whether it holds across years, regions, subgroups

Guideline

A striking pattern is the start of an examination, not its conclusion. The four filters constitute that examination.

Data → Wisdom

The DIKW hierarchy

DIKW stands for Data → Information → Knowledge → Wisdom. Each layer adds context and meaning. KDD is the process for moving up the pyramid.

The four layers

Data
raw recorded facts, one entry at a time
Information
data summarised and given context (who, when, how many)
Knowledge
a checked pattern someone can act on
Wisdom
judgment about when to trust and use that knowledge

Position of KDD

Between data and knowledge: turning recorded facts into actionable patterns.

Wisdom Knowledge Information Data
Worked example

From a sari-sari store's notebook to a decision

Review question · Hour 1

Identify the filter this finding fails

A mall's analytics team reports: "Customers who buy umbrellas are 340% more likely to also buy pancit canton during the same typhoon week. Recommendation: bundle them year-round."

A · Valid — the pattern may not hold outside typhoon weeks
B · Novel — everyone already knew this
C · Useful — no one can act on it
D · Understandable — the mechanism is opaque

Select an answer, then click and hold (or tap) to show the answer

A — a validity failure.

The pattern is real within typhoon weeks (people stock up on storm supplies together), but the recommendation extrapolates it year-round. Tested on ordinary weeks, it would likely vanish. It is arguably not novel either, but the decisive flaw is the validity of the generalization.

Break

  10 minutes

After the break: the five-stage process that turns raw data into defensible knowledge.

Part 2

The KDD process

Five stages, with repeated iteration.

Part 1 defined what counts as knowledge. This part presents the process that produces it: the pipeline from a raw file to a defensible finding.

Pipeline

Five stages from raw data to knowledge

1 · Selection choose target data 2 · Preprocessing clean & repair 3 · Transformation reshape & reduce 4 · Data Mining extract patterns 5 · Interpretation / Evaluation judge & explain feedback: any stage can return to an earlier one Raw data in Knowledge out

KDD resembles cooking a meal: select the ingredients (selection), wash them (preprocessing), chop them (transformation), cook (mining), and taste before serving (interpretation), returning to an earlier step if the result is wrong.

Stages 1–2

Selection & preprocessing

Before any analysis: which data to use, and whether it can be trusted.

Guiding question

Whether the conclusion would change if this field were wrong. If so, the field requires careful cleaning.

Definitions

domain expert
someone who knows the field the data describes, e.g. a nurse
field
another word for an attribute (column)
scraping
copying data out of web pages with code (Week 3)
duplicate
the same record entered twice
encoding
how text is stored in a file; a mismatch turns “Ñ” into unreadable characters

1 · Selection

  • Define the goal with the domain expert first
  • Choose tables, fields, time windows, populations
  • Scraping and acquisition belong to this stage (Weeks 3–4)

2 · Preprocessing

  • Handle missing values, duplicates, impossible entries
  • Reconcile units, encodings, spellings ("Q.C." vs "Quezon City")
  • Document every repair; cleaning is part of the analysis (Weeks 5–6)
Stages 3–4

Transformation & mining

The cleaned data is reshaped so that patterns can be found, and the patterns are then extracted.

Mining tasks

Classification · regression · clustering · association rules · anomaly detection · summarization

The next slide defines each new term on this slide in plain language.

3 · Transformation

  • Feature engineering: derive age from birthdate, rates from counts
  • Normalize, encode categoricals, reduce dimensionality
  • The same data, reshaped, can reveal or hide a pattern

4 · Data mining

  • Apply the algorithm matched to the goal, not the most fashionable one
  • Fit, tune, and check stability across samples
  • Output: candidate patterns, not yet knowledge
Definition

Definition: data mining

Data mining (Fayyad, Piatetsky-Shapiro & Smyth, 1996)

“A step in the KDD process that consists of applying data analysis and discovery algorithms that, under acceptable computational efficiency limitations, produce a particular enumeration of patterns (or models) over the data.”

Stage, for the five clinics in this week’s labData mining?
1–2 · choose the clinics; decide what to do with Talamban’s missing visitsno: selection and preprocessing
3 · compute visits per staff member for each clinicno: transformation
4 · search for clinics whose visits per staff member stand outyes: an algorithm enumerating patterns
5 · decide whether that pattern is valid, novel and usefulno: interpretation, by people

KDD is the whole process; data mining is one step inside it.

Stages 3–4 · Definitions

Definitions of the terms in stages 3–4

Analogy (continued): transformation prepares the ingredients and mining applies the recipe suited to the requested dish; a sophisticated recipe cannot compensate for poor preparation.

Stage 5

Interpretation: evaluating candidate patterns

Worked example

One problem, five stages

A barangay health center notices many patients miss their follow-up appointments. The captain asks: "Can the data tell us who is likely to miss, so we can send reminders where they matter?"

Rationale for this example

The example is small and local, and it involves every stage, pitfall, and ethical question in this course. It recurs throughout the semester.

Available data

  • Paper logbooks of appointments, partially digitized
  • A patient registry with age, address, contact number
  • SMS records of past reminder attempts

The underlying KDD question

The task is not only "predict no-shows" but "find valid, novel, useful, understandable patterns in who misses and why, so a human can design a better reminder policy."

Worked example · Stages 1–2

Selection and preprocessing decisions in the example

Worked example · Stages 3–5

Transformation, mining, interpretation, and iteration

Common errors

Common errors at each stage

Stage Classic pitfall Defense
Selection Sampling bias: the available data does not represent the claimed population (everyone the study aims to describe) Identify who is missing from the table, and why
Preprocessing Silent deletion of inconvenient rows Cleaning journal; report row counts before/after
Transformation Leakage: a feature that implicitly contains the answer Confirm the value is known before the outcome
Mining Overfitting: memorizing noise as pattern Hold-out data; prefer simpler models first
Interpretation Claims that exceed the evidence The four filters, applied in writing
Disambiguation

KDD and related fields

Term What it names Relation to KDD
KDD The whole discovery process, end to end The umbrella term; this course
Data mining Pattern-extraction algorithms Stage 4 of the KDD process
Machine learning Algorithms that improve from data Supplies many mining tools
Data science The broad discipline & profession KDD is its methodological core
Analytics / BI (business intelligence) Reporting & decision support in orgs Consumes KDD outputs
Review question · Hour 2

Identify the stage

An analyst computes "days until next typhoon" as a feature for predicting appointment no-shows, using PAGASA's after-the-fact storm records. Identify the stage and the pitfall.

A · Preprocessing — silent deletion
B · Transformation — leakage
C · Mining — overfitting
D · Selection — sampling bias

Select an answer, then click and hold (or tap) to show the answer

B — transformation-stage leakage.

Feature engineering happens in Stage 3, and "days until next typhoon" uses information that was not available at prediction time. The model would score very well in testing and fail in deployment, which is the characteristic symptom of leakage.

Break

  10 minutes

After the break: real applications, a 170-year-old case study, ethics, and course requirements.

Part 3

KDD in practice

Applications and their risks.

Parts 1 and 2 covered the definition and the five stages. This part examines them in practice, where an incorrect finding affects real people.

Applications

One pipeline, different stakes by domain

Case study · 1854

Knowledge discovery before computers

During London's 1854 cholera outbreak, physician John Snow mapped death locations by hand and found that they clustered around the Broad Street water pump, evidence against the prevailing "bad air" theory. The pump handle was removed; the outbreak subsided.

Relevance to KDD

Data collection, cleaning (deaths misattributed to other addresses), a visualization, an inference, an action: the complete KDD loop, 170 years before the term existed.

Evaluation against the four filters

  • Valid — clustering held up; later traced to a contaminated well
  • Novel — contradicted expert consensus (miasma theory)
  • Useful — one removed pump handle; lives saved
  • Understandable — a map anyone could read

Modern equivalents

A dashboard tracking dengue clusters or traffic fatalities applies the method of Snow's map with modern tools. Weeks 9–10 cover building the map and the argument.

Ethics

Ethical risks of discovery

The same techniques that map poverty can profile individuals. The Philippines' Data Privacy Act of 2012 (RA 10173) sets legal duties for anyone processing personal data (any information that can identify a person), including researchers.

Recurring ethical questions

  • Whether the data was collected with meaningful consent
  • Whether individuals can be re-identified (matched back to their names) from the outputs
  • Who benefits, and who bears the risk, if the finding is wrong

Week 11: ethics in depth

Privacy law, anonymization (removing names and identifiers) and its limits, algorithmic bias (a method that treats some groups unfairly), and responsible scraping. Ethics is also part of every week, beginning with scraping practice in Week 3.

Activity · 15 minutes

Breakout activity: evaluating a "finding"

Part 4

Course structure

Twelve weeks along the KDD pipeline.

Part 2 introduced the five stages. This part shows how the twelve weeks cover them one stage at a time, and what the course requires.

Roadmap

Overview of the 12 weeks

Weeks Theme Topics
1–2 KDD foundations This intro · CRISP-DM, SEMMA & process frameworks
3–6 Scraping & preprocessing HTML parsing · APIs & scraping ethics · cleaning · transformation
7–8 Data exploration Descriptive statistics · univariate & multivariate EDA · visualization
9–10 Journalism & storytelling Finding stories in data · narrative, dashboards & communication
11–12 Ethics & synthesis Privacy & responsible analytics · final presentations

Definitions

HTML parsing
using code to read a web page’s text and extract the required parts
descriptive statistics
summary numbers such as the average and how spread out values are
EDA
exploratory data analysis: looking at data from many angles before concluding
univariate / multivariate
one column at a time / several columns together
Logistics

Course logistics

Assessment

Grade components

Component Weight What it rewards
Weekly exercises (best 8 of 10) 40% Consistent hands-on practice; the two lowest scores are dropped
Midterm synthesis (Week 7) 20% Integrating scraping → cleaning → exploration on a fresh dataset
Final discovery project 30% Full KDD cycle on data from the student’s field, defended in Week 12
Participation 10% Quizzes, forum activity, discussion contributions
Preparation for next week

Week 1 assignment

The assignment is deliberately small; its aim is to begin viewing familiar settings as data.

1 · Find a dataset

Browse PSA OpenSTAT or any open portal in a relevant field. Choose one dataset of genuine interest.

2 · Write half a page

State a question it might answer, and explain which of the four filters (valid, novel, useful, understandable) would be hardest to satisfy.

3 · Set up Python + Jupyter

Installation instructions are on the course page. Code writing begins in Week 3; the weekly labs require no installation because they run in the browser.

This week’s lab

A first table in code

The terms dataset, record, attribute, and missing value are now defined. The lab shows how they appear when Python opens a small clinic table, the first step of Stage 2 (preprocessing). The next two slides explain 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 · Part 0

Loading a five-clinic table from text

  • import io, pandas as pdload two libraries (ready-made code): pandas, for tables, and io; as pd gives pandas a short nickname
  • raw = """…"""a variable (a name that holds a value) called raw, holding the table as plain text: commas between columns, one record per line
  • pd.read_csv(io.StringIO(raw))read that text as if it were a CSV file; the result is a DataFrame, pandas’ table, stored in df
  • print(df)show the table underneath the code
  • the output0–4 on the left are row labels, counted from 0. NaN is the missing value: Talamban has no visits recorded. Visits show .0 because a column with a gap is stored as decimals.
import io, pandas as pd raw = """clinic,barangay,visits,staff C-01,Lahug,412,6 C-02,Mabolo,388,5 C-03,Guadalupe,1240,6 C-04,Talamban,,4 C-05,Banilad,455,5""" df = pd.read_csv(io.StringIO(raw)) print(df) clinic barangay visits staff 0 C-01 Lahug 412.0 6 1 C-02 Mabolo 388.0 5 2 C-03 Guadalupe 1240.0 6 3 C-04 Talamban NaN 4 4 C-05 Banilad 455.0 5

A DataFrame is a spreadsheet controlled with code: each record is a row, each attribute is a named column.

Lab · Parts 1–2

Three initial checks for a new table

The checks cover size, missing values, and a typical value, using the same df as the previous slide.

  • df.shapethe size, as (rows, columns): (5, 4) means 5 clinics, 4 attributes
  • df["visits"]select one column by its name, in square brackets and quotes
  • .isna().sum().isna() marks each missing cell True; .sum() counts the Trues. 1 = one clinic has no visits number
  • .mean() / .median()the average / the middle value. pandas skips the missing cell, so both use 4 clinics
  • the doteach .name() is a method: a function (a named piece of work) that belongs to a value, called with a dot and brackets
print(df.shape) print(df["visits"].isna().sum()) print(df["visits"].mean(), df["visits"].median()) (5, 4) 1 623.75 433.5

One busy clinic (1,240 visits) raises the mean to 623.75; the median, 433.5, stays close to a typical clinic. Analogy: when a millionaire enters a sari-sari store, the average customer’s wealth rises but the middle customer’s does not.

In the lab

Replace each ____ with an answer, press ▶ Run to see the output, then press Check. Two multiple-choice questions ask what the numbers mean.

Exercise · 3 min

One busy clinic

Guadalupe’s 1,240 visits already pull the mean (623.75) far above the median (433.5). What if it were busier still?

Tasks

  1. Select ▶ Run / Edit and run the code: it prints the mean and the median.
  2. Predict both after changing Guadalupe’s 1240 to 3000.
  3. Make the change and run it again.

Result on the lecture laptop (select to reveal)

The mean jumps to 1,063.75; the median stays at 433.5. One extreme value moves the mean, not the middle.

import io, pandas as pd raw = """clinic,barangay,visits,staff C-01,Lahug,412,6 C-02,Mabolo,388,5 C-03,Guadalupe,1240,6 C-04,Talamban,,4 C-05,Banilad,455,5""" df = pd.read_csv(io.StringIO(raw)) print("mean:", df["visits"].mean(), " median:", df["visits"].median())
Synthesis

Three main points

Glossary · 1 of 2

Week 1 terms: data and the process

Glossary · 2 of 2

Week 1 terms: pitfalls and first code

Readings

Sources for this week

Required

Fayyad, U., Piatetsky-Shapiro, G., & Smyth, P. (1996). From Data Mining to Knowledge Discovery in Databases. AI Magazine, 17(3). Short, readable, and the source of this week's definition.

Reference (consult as needed)

Han, Kamber & Pei, Data Mining: Concepts and Techniques — Ch. 1. · Republic Act No. 10173 (Data Privacy Act of 2012), full text at the National Privacy Commission site.

Next week

KDD frameworks

CRISP-DM, SEMMA, and how project teams structure the discovery loop: the project-management framework for the rest of the course.

DS 227 · Knowledge Discovery in Data