TExcelTAD
Home › Data for ML: Types, Formats, Sources & Quality › Mini Project: Dataset Quality Analyzer

Mini Project: Dataset Quality Analyzer

In this project you build a Dataset Quality Analyzer: a small, reusable tool that takes a table and a configuration, runs every check from this course, and writes a reproducible quality report with a clear decision. It is the beginner project "data quality analyzer" of the Machine Learning track's project list, and the same tool will be useful in every later course: run it on any dataset before you train on it.

You will:

  1. generate a messy health-screening dataset with known, planted problems (so you can check that the analyzer finds them);
  2. build the analyzer: a set of checks driven by a configuration, each returning a severity, a count and examples;
  3. produce the Markdown report and a JSON summary;
  4. draw the figures that go with the report;
  5. reuse the analyzer, unchanged, on a different dataset;
  6. write up your findings using the template at the end.

Each step is a complete program; later steps repeat the pieces they need, so any of them runs on its own.

Step 1: A messy dataset with known problems

A test dataset whose problems you planted yourself is the best way to test a checker: you know exactly what it should find. The dataset describes 300 visits to three screening clinics, with a label diabetic. The planted problems are listed in the code:

python · try it yourself
import numpy as np
import pandas as pd

def make_screening(seed=7):
    rng = np.random.default_rng(seed)
    n = 300
    height = np.round(rng.normal(166, 9, n))
    df = pd.DataFrame({
        "patient_id": [f"P{i:04}" for i in range(n)],
        "clinic": rng.choice(["North", "South", "East"], n, p=[0.4, 0.35, 0.25]),
        "visit_date": pd.date_range("2026-01-05", periods=n, freq="6h").strftime("%Y-%m-%d"),
        "age": rng.integers(18, 86, n),
        "height_cm": height,
        "weight_kg": np.round(24 * (height / 100) ** 2 + rng.normal(0, 7, n), 1),
        "temp_c": np.round(rng.normal(36.8, 0.35, n), 1),
        "glucose": np.round(rng.lognormal(1.7, 0.18, n), 1),
        "smoker": rng.choice(["yes", "no"], n, p=[0.25, 0.75]),
    })
    df["diabetic"] = (df["glucose"] >= 7.0).astype(int)
    variants = {"north": ["north", "North "], "south": ["Sth", "south"], "east": ["east", "East "]}
    for i, idx in enumerate([5, 6, 7, 8]):                                # spelling variants
        df.loc[idx, "clinic"] = variants[df.loc[idx, "clinic"].lower()][i % 2]
    clinic = df["clinic"].str.strip().str.lower().replace({"sth": "south"})
    # --- planted problems ---
    df.loc[[3, 40, 77, 150], "age"] = -1                                  # placeholder for unknown
    df.loc[[12, 201], "age"] = [230, 310]                                 # typos
    df.loc[[20, 21, 22, 23, 24, 25], "glucose"] = 999.0                   # placeholder
    lb = df.index[clinic == "east"][:12]
    df.loc[lb, "weight_kg"] = np.round(df.loc[lb, "weight_kg"] * 2.20462, 1)   # pounds
    df.loc[[60, 61, 62, 63, 64], "temp_c"] = [98.2, 98.9, 99.5, 97.9, 100.4]   # Fahrenheit
    df.loc[rng.choice(n, 10, replace=False), "weight_kg"] = np.nan        # missing
    df.loc[clinic == "south", "smoker"] = ""                        # question not on South's form
    sl = df.index[clinic == "south"][:8]
    df.loc[sl, "visit_date"] = pd.to_datetime(df.loc[sl, "visit_date"]).dt.strftime("%d/%m/%Y")
    df.loc[[100, 101, 102, 103], "diabetic"] = 1 - df.loc[[100, 101, 102, 103], "diabetic"]  # label errors
    dup = df.loc[[30, 31, 32, 33, 34]]                                    # exact duplicates
    near = df.loc[[50, 51, 52]].assign(patient_id=lambda d: d["patient_id"].str.lower() + " ")
    return pd.concat([df, dup, near], ignore_index=True)

df = make_screening()
print("shape:", df.shape)
print(df.iloc[[3, 12, 20, 60, 5]].to_string())
print()
print("label counts:", df["diabetic"].value_counts().to_dict())
shape: (308, 10)
   patient_id clinic  visit_date  age  height_cm  weight_kg  temp_c  glucose smoker  diabetic
3       P0003  South  05/01/2026   -1      158.0       48.1    37.4      4.8                0
12      P0012   East  2026-01-08  230      167.0      146.6    37.7      4.1     no         0
20      P0020   East  2026-01-10   42      149.0      116.4    37.1    999.0     no         0
60      P0060  South  2026-01-20   68      168.0       53.9    98.2      5.5                0
5       P0005   east  2026-01-06   38      157.0      159.0    36.7      5.5    yes         0

label counts: {0: 266, 1: 42}

Step 2: The analyzer

The analyzer is a configuration plus a list of check functions. Every check has the same signature, check(df, cfg), and returns (severity, count, examples). Placeholders are turned into missing values once, at the start, so that later checks see the honest data; the placeholder check reports how many there were.

python · try it yourself
import numpy as np
import pandas as pd

def make_screening(seed=7):
    rng = np.random.default_rng(seed)
    n = 300
    height = np.round(rng.normal(166, 9, n))
    df = pd.DataFrame({
        "patient_id": [f"P{i:04}" for i in range(n)],
        "clinic": rng.choice(["North", "South", "East"], n, p=[0.4, 0.35, 0.25]),
        "visit_date": pd.date_range("2026-01-05", periods=n, freq="6h").strftime("%Y-%m-%d"),
        "age": rng.integers(18, 86, n),
        "height_cm": height,
        "weight_kg": np.round(24 * (height / 100) ** 2 + rng.normal(0, 7, n), 1),
        "temp_c": np.round(rng.normal(36.8, 0.35, n), 1),
        "glucose": np.round(rng.lognormal(1.7, 0.18, n), 1),
        "smoker": rng.choice(["yes", "no"], n, p=[0.25, 0.75]),
    })
    df["diabetic"] = (df["glucose"] >= 7.0).astype(int)
    variants = {"north": ["north", "North "], "south": ["Sth", "south"], "east": ["east", "East "]}
    for i, idx in enumerate([5, 6, 7, 8]):                                # spelling variants
        df.loc[idx, "clinic"] = variants[df.loc[idx, "clinic"].lower()][i % 2]
    clinic = df["clinic"].str.strip().str.lower().replace({"sth": "south"})
    df.loc[[3, 40, 77, 150], "age"] = -1
    df.loc[[12, 201], "age"] = [230, 310]
    df.loc[[20, 21, 22, 23, 24, 25], "glucose"] = 999.0
    lb = df.index[clinic == "east"][:12]
    df.loc[lb, "weight_kg"] = np.round(df.loc[lb, "weight_kg"] * 2.20462, 1)
    df.loc[[60, 61, 62, 63, 64], "temp_c"] = [98.2, 98.9, 99.5, 97.9, 100.4]
    df.loc[rng.choice(n, 10, replace=False), "weight_kg"] = np.nan
    df.loc[clinic == "south", "smoker"] = ""
    sl = df.index[clinic == "south"][:8]
    df.loc[sl, "visit_date"] = pd.to_datetime(df.loc[sl, "visit_date"]).dt.strftime("%d/%m/%Y")
    df.loc[[100, 101, 102, 103], "diabetic"] = 1 - df.loc[[100, 101, 102, 103], "diabetic"]
    dup = df.loc[[30, 31, 32, 33, 34]]
    near = df.loc[[50, 51, 52]].assign(patient_id=lambda d: d["patient_id"].str.lower() + " ")
    return pd.concat([df, dup, near], ignore_index=True)

CONFIG = {
    "key": "patient_id",
    "label": "diabetic",
    "placeholders": {"age": [-1], "glucose": [999.0], "smoker": [""]},
    "ranges": {"age": (0, 110), "height_cm": (120, 220), "weight_kg": (30, 200), "temp_c": (34, 42), "glucose": (2, 30)},
    "allowed": {"clinic": {"North", "South", "East"}, "smoker": {"yes", "no"}, "diabetic": {0, 1}},
    "date_columns": {"visit_date": "%Y-%m-%d"},
    "max_missing_share": 0.05,
    "label_rule": ("glucose", 7.0),          # diabetic should be 1 exactly when glucose >= 7.0
    "group": "clinic",
}

def norm_key(s):
    return s.astype(str).str.strip().str.lower()

def check_placeholders(df, cfg, raw):
    hits = {c: int(raw[c].isin(v).sum()) for c, v in cfg["placeholders"].items()}
    return "warning", sum(hits.values()), [f"{c}: {k}" for c, k in hits.items() if k]

def check_missing(df, cfg, raw):
    share = df.isna().mean()
    over = share[share > cfg["max_missing_share"]].round(3)
    worst = df.isna().groupby(df[cfg["group"]].pipe(norm_key)).mean().max(axis=1).round(2)
    return "warning", int(df.isna().any(axis=1).sum()), [f"{c}: {s:.1%}" for c, s in over.items()] + \
        [f"worst group: {worst.idxmax()} ({worst.max():.0%} in one column)"]

def check_exact_duplicates(df, cfg, raw):
    d = df.duplicated()
    return "error", int(d.sum()), df.loc[d, cfg["key"]].head(3).tolist()

def check_key_duplicates(df, cfg, raw):
    k = norm_key(df[cfg["key"]])
    d = k.duplicated(keep=False) & ~df.duplicated(keep=False)
    return "error", int(d.sum()), sorted(df.loc[d, cfg["key"]].unique().tolist())[:4]

def check_ranges(df, cfg, raw):
    out = {c: df.loc[(df[c] < lo) | (df[c] > hi), c] for c, (lo, hi) in cfg["ranges"].items()}
    return "warning", sum(len(v) for v in out.values()), [f"{c}: {len(v)} e.g. {v.head(2).tolist()}" for c, v in out.items() if len(v)]

def check_allowed(df, cfg, raw):
    bad = {c: sorted(map(str, set(df[c].dropna()) - ok)) for c, ok in cfg["allowed"].items()}
    rows = sum(int((df[c].notna() & ~df[c].isin(ok)).sum()) for c, ok in cfg["allowed"].items())
    return "error" if bad.get(cfg["label"]) else "warning", rows, [f"{c}: {v}" for c, v in bad.items() if v]

def check_dates(df, cfg, raw):
    fails = {c: df.loc[pd.to_datetime(df[c], format=f, errors="coerce").isna() & df[c].notna(), c]
             for c, f in cfg["date_columns"].items()}
    return "warning", sum(len(v) for v in fails.values()), [f"{c}: {v.head(2).tolist()}" for c, v in fails.items() if len(v)]

def check_units(df, cfg, raw):
    bmi = df["weight_kg"] / (df["height_cm"] / 100) ** 2
    lb = bmi > 45
    f = df["temp_c"].between(90, 110)
    groups = df.loc[lb, cfg["group"]].value_counts().to_dict()
    return "warning", int(lb.sum() + f.sum()), [f"weight in lb? {int(lb.sum())} rows, by clinic {groups}",
                                                 f"temp in F? {int(f.sum())} rows"]

def check_label_rule(df, cfg, raw):
    col, thr = cfg["label_rule"]
    ok = df[col].notna()
    bad = ok & (df[cfg["label"]] != (df[col] >= thr).astype(int))
    return "warning", int(bad.sum()), df.loc[bad, cfg["key"]].head(4).tolist()

def check_classes(df, cfg, raw):
    counts = df[cfg["label"]].value_counts()
    ir = counts.max() / counts.min()
    return ("warning" if ir > 10 else "info"), int(counts.min()), [f"counts {counts.sort_index().to_dict()}", f"imbalance ratio {ir:.1f}"]

CHECKS = [check_placeholders, check_missing, check_exact_duplicates, check_key_duplicates, check_ranges,
          check_allowed, check_dates, check_units, check_label_rule, check_classes]

def analyze(raw, cfg):
    df = raw.copy()
    for c, values in cfg["placeholders"].items():
        df[c] = df[c].replace(values, np.nan)
    results = []
    for check in CHECKS:
        severity, count, examples = check(df, cfg, raw)
        results.append({"check": check.__name__.removeprefix("check_"),
                        "status": severity if count else "ok", "count": count, "examples": examples})
    return results

raw = make_screening()
for r in analyze(raw, CONFIG):
    print(f"{r['check']:17} {r['status']:8} {r['count']:4}  {'; '.join(map(str, r['examples']))}")

import hashlib
fp = hashlib.sha256(pd.util.hash_pandas_object(raw, index=False).values.tobytes()).hexdigest()[:12]
print("rows:", len(raw), "| fingerprint:", fp)
placeholders      warning   124  age: 4; glucose: 6; smoker: 114
missing           warning   127  smoker: 37.0%; worst group: south (100% in one column)
exact_duplicates  error       5  P0030; P0031; P0032
key_duplicates    error       6  P0050; P0051; P0052; p0050
ranges            warning     7  age: 2 e.g. [230.0, 310.0]; temp_c: 5 e.g. [98.2, 98.9]
allowed           warning     4  clinic: ['east', 'north', 'south']
dates             warning     8  visit_date: ['05/01/2026', '05/01/2026']
units             warning    19  weight in lb? 14 rows, by clinic {'East': 13, 'east': 1}; temp in F? 5 rows
label_rule        warning     4  P0100; P0101; P0102; P0103
classes           info       42  counts {0: 266, 1: 42}; imbalance ratio 6.3
rows: 308 | fingerprint: 5f027006eb7c

Compare the findings with the planted problems from Step 1:

Planted Found by
4 ages of −1, 6 glucose values of 999 placeholders (4 and 6)
smoker question missing on South's form placeholders (114 empty answers) and missing (37.0% of rows, worst group: south with 100%)
5 exact duplicate rows exact_duplicates (5)
3 copies with a lower-cased, padded id key_duplicates (6 rows: 3 pairs)
2 age typos, 5 temperatures in °F ranges (7)
4 spelling variants of clinic names allowed (4)
8 South dates written day-first dates (8)
12 East weights in pounds, 5 temperatures in °F units (14 + 5: the 12 pound weights plus 2 copies of them among the duplicated rows)
4 flipped labels label_rule (exactly P0100 to P0103)
a minority class classes (42 of 308, imbalance ratio 6.3, reported as info)

Every planted problem is found, and the counts can be explained to the row. That is the standard to hold a quality tool to before you trust it on data whose problems you do not know. Notice also that one problem can trigger several checks (the Fahrenheit temperatures appear in ranges and units), and one check can catch problems of different origins: read the findings together.

Step 3: The report

The report generator from the quality report lesson turns the results into Markdown with an identity block, a findings table sorted by severity, and a decision, plus a JSON summary for automatic comparisons. To keep this step short, it starts from the results of Step 2 saved as JSON, exactly what the analyzer would write to results.json next to the dataset:

python · try it yourself
import json

results = json.loads("""[
 {"check": "placeholders", "status": "warning", "count": 124},
 {"check": "missing", "status": "warning", "count": 127},
 {"check": "exact_duplicates", "status": "error", "count": 5},
 {"check": "key_duplicates", "status": "error", "count": 6},
 {"check": "ranges", "status": "warning", "count": 7},
 {"check": "allowed", "status": "warning", "count": 4},
 {"check": "dates", "status": "warning", "count": 8},
 {"check": "units", "status": "warning", "count": 19},
 {"check": "label_rule", "status": "warning", "count": 4},
 {"check": "classes", "status": "info", "count": 42}
]""")
ORDER = {"error": 0, "warning": 1, "info": 2, "ok": 3}

def report(results, meta):
    worst = min((r["status"] for r in results), key=ORDER.get)
    decision = {"error": "NOT USABLE until the errors are fixed",
                "warning": "usable after the warnings are reviewed", "info": "usable", "ok": "usable"}[worst]
    lines = [f"# Data quality report: {meta['name']}",
             f"data as of {meta['as_of']} | fingerprint `{meta['fingerprint']}` | analyzer v{meta['version']}",
             f"rows {meta['rows']} | one row = {meta['grain']}", "",
             f"**Decision: {decision}**", "",
             "| check | status | count |", "|---|---|---|"]
    for r in sorted(results, key=lambda r: (ORDER[r["status"]], r["check"])):
        lines.append(f"| {r['check']} | {r['status']} | {r['count']} |")
    summary = {"fingerprint": meta["fingerprint"], "status": worst,
               "counts": {r["check"]: r["count"] for r in results}}
    return "\n".join(lines), summary

meta = {"name": "clinic screening", "as_of": "2026-04-30", "fingerprint": "5f027006eb7c", "version": "1.0",
        "rows": 308, "grain": "one clinic visit"}
text, summary = report(results, meta)
print(text)
print()
print(json.dumps(summary))
# Data quality report: clinic screening
data as of 2026-04-30 | fingerprint `5f027006eb7c` | analyzer v1.0
rows 308 | one row = one clinic visit

**Decision: NOT USABLE until the errors are fixed**

| check | status | count |
|---|---|---|
| exact_duplicates | error | 5 |
| key_duplicates | error | 6 |
| allowed | warning | 4 |
| dates | warning | 8 |
| label_rule | warning | 4 |
| missing | warning | 127 |
| placeholders | warning | 124 |
| ranges | warning | 7 |
| units | warning | 19 |
| classes | info | 42 |

{"fingerprint": "5f027006eb7c", "status": "error", "counts": {"placeholders": 124, "missing": 127, "exact_duplicates": 5, "key_duplicates": 6, "ranges": 7, "allowed": 4, "dates": 8, "units": 19, "label_rule": 4, "classes": 42}}

Step 4: Figures for the report

Numbers say how many; figures show where. Four panels cover the main findings: the weight histogram (the pound values), temperature (the Fahrenheit values), glucose without placeholders against the label (label errors sit on the wrong side of the 7.0 line), and missingness by clinic.

python · try it yourself
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

def make_screening(seed=7):
    rng = np.random.default_rng(seed)
    n = 300
    height = np.round(rng.normal(166, 9, n))
    df = pd.DataFrame({
        "patient_id": [f"P{i:04}" for i in range(n)],
        "clinic": rng.choice(["North", "South", "East"], n, p=[0.4, 0.35, 0.25]),
        "visit_date": pd.date_range("2026-01-05", periods=n, freq="6h").strftime("%Y-%m-%d"),
        "age": rng.integers(18, 86, n),
        "height_cm": height,
        "weight_kg": np.round(24 * (height / 100) ** 2 + rng.normal(0, 7, n), 1),
        "temp_c": np.round(rng.normal(36.8, 0.35, n), 1),
        "glucose": np.round(rng.lognormal(1.7, 0.18, n), 1),
        "smoker": rng.choice(["yes", "no"], n, p=[0.25, 0.75]),
    })
    df["diabetic"] = (df["glucose"] >= 7.0).astype(int)
    variants = {"north": ["north", "North "], "south": ["Sth", "south"], "east": ["east", "East "]}
    for i, idx in enumerate([5, 6, 7, 8]):                                # spelling variants
        df.loc[idx, "clinic"] = variants[df.loc[idx, "clinic"].lower()][i % 2]
    clinic = df["clinic"].str.strip().str.lower().replace({"sth": "south"})
    df.loc[[3, 40, 77, 150], "age"] = -1
    df.loc[[12, 201], "age"] = [230, 310]
    df.loc[[20, 21, 22, 23, 24, 25], "glucose"] = 999.0
    lb = df.index[clinic == "east"][:12]
    df.loc[lb, "weight_kg"] = np.round(df.loc[lb, "weight_kg"] * 2.20462, 1)
    df.loc[[60, 61, 62, 63, 64], "temp_c"] = [98.2, 98.9, 99.5, 97.9, 100.4]
    df.loc[rng.choice(n, 10, replace=False), "weight_kg"] = np.nan
    df.loc[clinic == "south", "smoker"] = ""
    sl = df.index[clinic == "south"][:8]
    df.loc[sl, "visit_date"] = pd.to_datetime(df.loc[sl, "visit_date"]).dt.strftime("%d/%m/%Y")
    df.loc[[100, 101, 102, 103], "diabetic"] = 1 - df.loc[[100, 101, 102, 103], "diabetic"]
    dup = df.loc[[30, 31, 32, 33, 34]]
    near = df.loc[[50, 51, 52]].assign(patient_id=lambda d: d["patient_id"].str.lower() + " ")
    return pd.concat([df, dup, near], ignore_index=True)

df = make_screening()
df["glucose"] = df["glucose"].replace(999.0, np.nan)
df["age"] = df["age"].replace(-1, np.nan)
df["smoker"] = df["smoker"].replace("", np.nan)
clinic = df["clinic"].str.strip().str.lower().replace({"sth": "south"})

fig, axes = plt.subplots(2, 2, figsize=(9, 6))
axes[0, 0].hist(df["weight_kg"].dropna(), bins=40)
axes[0, 0].set_title("weight_kg: a second group above 110 (pounds)")
axes[0, 1].hist(df["temp_c"], bins=40)
axes[0, 1].set_title("temp_c: a few values near 99")
rng = np.random.default_rng(0)
jitter = df["diabetic"] + rng.uniform(-0.15, 0.15, len(df))
axes[1, 0].scatter(df["glucose"], jitter, s=10, alpha=0.6)
axes[1, 0].axvline(7.0, linestyle="--")
axes[1, 0].set_yticks([0, 1], ["not diabetic", "diabetic"])
axes[1, 0].set_title("glucose vs label (rule: 7.0)")
miss = df[["age", "weight_kg", "glucose", "smoker"]].isna().groupby(clinic).mean()
miss.T.plot.bar(ax=axes[1, 1], rot=0)
axes[1, 1].set_title("share missing by clinic")
fig.tight_layout()
plt.show()

wrong_side = ((df["glucose"] >= 7.0).astype(int) != df["diabetic"]) & df["glucose"].notna()
print("points on the wrong side of the glucose rule:", int(wrong_side.sum()))
print("missing smoker answers by clinic:", df["smoker"].isna().groupby(clinic).sum().to_dict())
points on the wrong side of the glucose rule: 4
missing smoker answers by clinic: {'east': 0, 'north': 0, 'south': 114}

Step 5: Reuse on another dataset

A tool is only reusable if nothing about the first dataset is hard-coded. Here the same analyzer code runs on scikit-learn's wine data; only the configuration changes. To keep the step self-contained, it repeats just the checks that apply (the others need columns this dataset does not have, and the configuration simply leaves them out):

python · try it yourself
import numpy as np
import pandas as pd
from sklearn.datasets import load_wine

def check_missing(df, cfg):
    return "warning", int(df.isna().any(axis=1).sum()), []

def check_exact_duplicates(df, cfg):
    return "error", int(df.duplicated().sum()), []

def check_ranges(df, cfg):
    out = {c: int(((df[c] < lo) | (df[c] > hi)).sum()) for c, (lo, hi) in cfg["ranges"].items()}
    return "warning", sum(out.values()), [f"{c}: {k}" for c, k in out.items() if k]

def check_outliers(df, cfg):
    hits = {}
    for c in df.select_dtypes("number").columns.drop(cfg["label"]):
        med = df[c].median()
        mad = (df[c] - med).abs().median()
        z = 0.6745 * (df[c] - med) / mad
        if (z.abs() > 3.5).any():
            hits[c] = int((z.abs() > 3.5).sum())
    return "info", sum(hits.values()), [f"{c}: {k}" for c, k in sorted(hits.items(), key=lambda kv: -kv[1])[:3]]

def check_classes(df, cfg):
    counts = df[cfg["label"]].value_counts()
    ir = counts.max() / counts.min()
    return ("warning" if ir > 10 else "info"), int(counts.min()), [f"counts {counts.sort_index().to_dict()}", f"IR {ir:.2f}"]

wine = load_wine(as_frame=True).frame
cfg = {"label": "target", "ranges": {"alcohol": (8, 16), "ash": (0, 5), "magnesium": (50, 200)}}
for check in [check_missing, check_exact_duplicates, check_ranges, check_outliers, check_classes]:
    severity, count, examples = check(wine, cfg)
    status = severity if count else "ok"
    print(f"{check.__name__.removeprefix('check_'):17} {status:8} {count:4}  {'; '.join(examples)}")
missing           ok          0
exact_duplicates  ok          0
ranges            ok          0
outliers          info       16  malic_acid: 9; ash: 3; magnesium: 2
classes           info       48  counts {0: 59, 1: 71, 2: 48}; IR 1.48

On the wine data, nothing is missing or duplicated, every value is inside the configured ranges, and the classes are only mildly imbalanced (IR 1.48): the decision would be "usable". The outlier check, at the info level, flags 16 values, 9 of them in malic_acid, a right-skewed column whose long tail is real, not an error. That is why outliers are reported as information for a person to look at, not as errors.

Extensions

Pick one or more:

  • Severity from the configuration: let CONFIG set each check's severity and thresholds, so a team can tighten the rules without touching code.
  • Fix suggestions: for each finding, add a suggested fix (map "Sth" to "South", convert the 12 East weights from pounds, parse the South dates as day-first) and generate the cleaning code as text, for a human to review.
  • Label suspicion with a model: add the cross-validated check from Label Quality and compare its suspects with the rule-based ones.
  • Batch comparison: run the analyzer on two batches (two months) and report changes in every count, as in the quality report lesson.
  • Save everything: write report.md, summary.json and the figure as files with the fingerprint in their names.

Write-up template

Use this structure for your report on a dataset. Keep the top half short; a reader should know the decision after ten seconds.

text
# Data quality report: <dataset name>

Dataset: <name, source, owner>          Version / fingerprint: <id>
Data as of: <date>                       Analyzer version: <x.y>
Grain: one row = <...>                   Key: <column>     Label: <column>

## Decision
<usable / usable after review / not usable> because <one sentence>.

## Errors (block use)
- <check>: <count> rows. Example: <...>. Likely cause: <...>. Fix: <...>. Owner: <...>.

## Warnings (need a decision)
- <check>: <count> rows. Example: <...>. Proposed handling: <...>.

## Distributions
- Label counts: <...>, imbalance ratio <...>.
- Figures: <file names>, with one sentence each on what they show.

## Sources, consent and licence
- <where the data came from, under which terms, retention date, who may access it>

## Open questions for the data owner
- <...>

Checklist

  • Every planted problem in Step 1 is reported by at least one check.
  • No check reports a problem that was not planted (or you can explain why it is real).
  • Running the analyzer twice gives byte-identical output.
  • The analyzer runs on a second dataset with only a new configuration.
  • The write-up states a decision and names an owner for every error.