Ch.01 Mini Project — Attribute Auditor¶
Concept: Stevens' attribute taxonomy (Nominal → Ordinal → Interval → Ratio), discrete vs. continuous, appropriate summary statistics per scale.
What it does¶
Given any CSV file, attribute_audit.py will:
- Infer each column's attribute type using name-hinting heuristics and value analysis
- Classify discrete vs. continuous
- Flag missing values per column
- Print a column-type summary (bar chart of type distribution)
Usage¶
# Run the built-in demo (mirrors Ch.1 textbook dataset)
python attribute_audit.py
# Audit your own CSV
python attribute_audit.py my_dataset.csv
No external dependencies — pure Python 3 standard library only.
Sample Output¶
════════════════════════════════════════════════════════════════════════════════
ATTRIBUTE AUDIT REPORT
Source : Demo (Ch.1 textbook dataset + extras)
Rows : 10 | Columns: 7
════════════════════════════════════════════════════════════════════════════════
Column : Name
Type : Nominal | Discrete
Notes : 10 unique values.
············...
Column : Age
Type : Ratio | Discrete
Notes : Range [23.00, 82.00]
············...
Column : Temperature_C
Type : Interval | Continuous
Notes : Date/time/calendar-based column.
············...
COLUMN TYPE SUMMARY
Ratio ███ 3
Nominal ██ 2
Ordinal █ 1
Interval █ 1
Key Concepts from Ch.1 Applied¶
| Concept | Where it appears in code |
|---|---|
| Stevens' 4 attribute types | infer_attribute_type() return value |
| True-zero test for Ratio | has_true_zero() heuristic |
| Discrete vs. continuous | is_integer_valued() check |
| Missing value handling | counted and reported per column |
Implementation Status¶
The script contains one complete infer_attribute_type() implementation and runs as a standalone demo or against a supplied CSV file.
Limitations & Future Ideas¶
- Type inference is heuristic — column name + value analysis. Always verify manually for real datasets.
- Extension:
--force-type colname=OrdinalCLI flag to override inference per column. - Extension:
compute_stats()— scale-appropriate statistics (mode for Nominal, median for Ordinal, mean/std for Interval/Ratio). - Extension: JSON output mode for use in downstream pipelines.