Upload folder using huggingface_hub
Browse files- README.md +92 -0
- fault_census.json +52 -0
- ingest_stream_2024.csv +0 -0
- make_bronze_stream.py +82 -0
- raw/daily_user.csv +0 -0
- raw/heavy_user.csv +0 -0
- raw/moderate_user.csv +0 -0
- raw/rare_user.csv +0 -0
README.md
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
---
|
| 2 |
+
license: cc-by-4.0
|
| 3 |
+
source_datasets:
|
| 4 |
+
- original
|
| 5 |
+
task_categories:
|
| 6 |
+
- tabular-classification
|
| 7 |
+
- time-series-forecasting
|
| 8 |
+
tags:
|
| 9 |
+
- ev
|
| 10 |
+
- data-engineering
|
| 11 |
+
- medallion
|
| 12 |
+
- teaching
|
| 13 |
+
- sensor-data
|
| 14 |
+
size_categories:
|
| 15 |
+
- 10K<n<100K
|
| 16 |
+
pretty_name: EV Fleet Telemetry Arrival Stream (Bronze) — Sample EV Data CSV
|
| 17 |
+
---
|
| 18 |
+
Attribution: original hourly telemetry derived from Kaggle dataset "EV Sensors:
|
| 19 |
+
Driving Pattern Diagnostics (2020-24)" by Kunal Mehra (https://www.kaggle.com/datasets/kunalm95/ev-sensors-driving-pattern-diagnostics-2020-24),
|
| 20 |
+
CC BY 4.0. Dimension enrichment and planted sensor faults are synthetic (deterministic, seed 7), also CC BY 4.0.
|
| 21 |
+
|
| 22 |
+
# Bronze Layer — EV Sensor Arrival Stream (download this and work from here)
|
| 23 |
+
|
| 24 |
+
You are holding what a fleet operator's data engineer receives: **raw sensor data,
|
| 25 |
+
exactly as it arrives** — and real arrival data is never clean. Everything you need
|
| 26 |
+
for a data-cleaning exercise is in this folder. You do not need anything else.
|
| 27 |
+
|
| 28 |
+
## Contents
|
| 29 |
+
|
| 30 |
+
| file | what it is |
|
| 31 |
+
|---|---|
|
| 32 |
+
| `ingest_stream_2024.csv` | **the demo/hands-on file**: 35,363 hourly sensor rows, one calendar year (2024), four EVs, delivered shuffled in arrival order — with realistic sensor faults planted |
|
| 33 |
+
| `raw/daily_user.csv` … `raw/rare_user.csv` | the original Kaggle telemetry files (Kunal Mehra, CC BY 4.0), untouched — the "published clean" counterpart |
|
| 34 |
+
| `fault_census.json` | **answer key**: exact counts and ranges of every fault planted |
|
| 35 |
+
| `make_bronze_stream.py` | deterministic generator (seed 7) producing `ingest_stream_2024.csv` from the clean files — fully reproducible |
|
| 36 |
+
| `README.md` | this file |
|
| 37 |
+
|
| 38 |
+
## Schema of `ingest_stream_2024.csv` (17 columns)
|
| 39 |
+
|
| 40 |
+
| column | meaning |
|
| 41 |
+
|---|---|
|
| 42 |
+
| `timestamp` | hourly, 2024 |
|
| 43 |
+
| `vehicle_id` | EV-101 rare · EV-102 moderate · EV-103 daily · EV-104 heavy user |
|
| 44 |
+
| `user_profile` | usage profile of that vehicle |
|
| 45 |
+
| `district` | location that hour (Downtown · Harbor · University · Industrial), 82 % home district |
|
| 46 |
+
| `SOC` | state of charge %, valid range 0–100 |
|
| 47 |
+
| `SOH` | state of health %, valid range 0–100 |
|
| 48 |
+
| `Charging_Cycles` | lifetime full-charge cycles |
|
| 49 |
+
| `charging_now` | 1 when SOC rises vs previous hour (derived) |
|
| 50 |
+
| `Battery_Temp`, `Motor_Temp` | °C |
|
| 51 |
+
| `Motor_RPM`, `Motor_Torque` | rpm · Nm |
|
| 52 |
+
| `Brake_Pad_Wear` | %, valid range 0–100 |
|
| 53 |
+
| `Charging_Voltage` | V |
|
| 54 |
+
| `Tire_Pressure` | **PSI** by contract (valid ≈ 25–45) |
|
| 55 |
+
| `DTC` | 0 = no fault, else diagnostic trouble code string |
|
| 56 |
+
| `grid_carbon_g_per_kwh` | district grid carbon intensity, gCO₂/kWh at that hour |
|
| 57 |
+
|
| 58 |
+
## The faults planted (what your cleaning demo will find)
|
| 59 |
+
|
| 60 |
+
| fault | how to detect | count planted |
|
| 61 |
+
|---|---|---|
|
| 62 |
+
| missing readings | empty cell in `SOC`, `Battery_Temp`, `Tire_Pressure` | 1,250 (434 + 398 + 418) |
|
| 63 |
+
| `SOC` out of bound | value > 100 | 276 |
|
| 64 |
+
| `SOH` out of bound | value > 100 | 174 |
|
| 65 |
+
| `Battery_Temp` out of bound | value < −25 °C | 172 |
|
| 66 |
+
| `Brake_Pad_Wear` out of bound | value > 100 | 209 |
|
| 67 |
+
| `Tire_Pressure` zero (dead sensor) | value = 0 | 24 |
|
| 68 |
+
| unit mix-up: pressure in kPa | value > 60 → divide by 6.895 | 517 |
|
| 69 |
+
| duplicate rows (sensor retry/double-write) | identical full rows | 419 |
|
| 70 |
+
|
| 71 |
+
After a correct cleaning pass you should have **34,944 rows** — that number is in
|
| 72 |
+
`fault_census.json` too, so participants can self-check.
|
| 73 |
+
|
| 74 |
+
No `SOC` outlier exceeds 145 and no `SOH` outlier exceeds 104.5 by design, so simple
|
| 75 |
+
range rules are unambiguous. Cleaning policy questions to raise in class:
|
| 76 |
+
*fix, flag, or drop?* for each fault type — a wrong indicator is worse than no indicator.
|
| 77 |
+
|
| 78 |
+
## What the cleaned data enables (gold layer, built live)
|
| 79 |
+
|
| 80 |
+
- battery `SOH` decline per vehicle/profile → fleet replacement decisions
|
| 81 |
+
- `DTC` precursor patterns by usage profile → predictive maintenance
|
| 82 |
+
- emissions per vehicle-day via `grid_carbon_g_per_kwh` × kWh charged → the
|
| 83 |
+
"same EV, very different footprint by district" insight (Industrial ≈ 577 vs
|
| 84 |
+
University ≈ 363 g/kWh on the full 2020–24 silver data)
|
| 85 |
+
|
| 86 |
+
## Licensing / provenance
|
| 87 |
+
|
| 88 |
+
Original hourly telemetry: Kaggle "EV Sensors: Driving Pattern Diagnostics (2020-24)"
|
| 89 |
+
by Kunal Mehra, CC BY 4.0. The arrival stream, dimension enrichment and the planted
|
| 90 |
+
faults are synthetic additions under the same license (CC BY 4.0, attribution required).
|
| 91 |
+
Absolute row-level values are simulated — treat as realistic-pattern teaching data,
|
| 92 |
+
not ground truth.
|
fault_census.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"rows": 34944,
|
| 3 |
+
"faults": {
|
| 4 |
+
"missing_values": 1250,
|
| 5 |
+
"missing_by_field": {
|
| 6 |
+
"SOC": 434,
|
| 7 |
+
"Battery_Temp": 398,
|
| 8 |
+
"Tire_Pressure": 418
|
| 9 |
+
},
|
| 10 |
+
"out_of_bound:SOC": {
|
| 11 |
+
"n": 276,
|
| 12 |
+
"planted_range": [
|
| 13 |
+
100.5,
|
| 14 |
+
145
|
| 15 |
+
]
|
| 16 |
+
},
|
| 17 |
+
"out_of_bound:SOH": {
|
| 18 |
+
"n": 174,
|
| 19 |
+
"planted_range": [
|
| 20 |
+
100.0,
|
| 21 |
+
104.2
|
| 22 |
+
]
|
| 23 |
+
},
|
| 24 |
+
"out_of_bound:Battery_Temp": {
|
| 25 |
+
"n": 172,
|
| 26 |
+
"planted_range": [
|
| 27 |
+
-42.0,
|
| 28 |
+
-25.0
|
| 29 |
+
]
|
| 30 |
+
},
|
| 31 |
+
"out_of_bound:Brake_Pad_Wear": {
|
| 32 |
+
"n": 209,
|
| 33 |
+
"planted_range": [
|
| 34 |
+
100.5,
|
| 35 |
+
112.0
|
| 36 |
+
]
|
| 37 |
+
},
|
| 38 |
+
"out_of_bound:Tire_Pressure_zero": {
|
| 39 |
+
"n": 24,
|
| 40 |
+
"planted_range": [
|
| 41 |
+
0,
|
| 42 |
+
0
|
| 43 |
+
]
|
| 44 |
+
},
|
| 45 |
+
"unit_mix:Tire_Pressure_kPa": {
|
| 46 |
+
"n": 517,
|
| 47 |
+
"rule": "value > 60 implies kPa; /6.895 to PSI"
|
| 48 |
+
},
|
| 49 |
+
"duplicate_rows": 419,
|
| 50 |
+
"rows_after_fault_injection": 35363
|
| 51 |
+
}
|
| 52 |
+
}
|
ingest_stream_2024.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
make_bronze_stream.py
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
"""Simulate a realistic 'arrival stream' for the cleaning demo.
|
| 3 |
+
|
| 4 |
+
Takes the (clean) 2024 silver facts for all four vehicles, then plants the
|
| 5 |
+
faults a real sensor feed produces: missing readings, out-of-bound values,
|
| 6 |
+
unit mix-ups, and duplicate retries. Deterministic (seed 7). Output plus an
|
| 7 |
+
exact fault census go to silver-checkable CSV + JSON so the instructor has
|
| 8 |
+
an answer key: after cleaning, row and fault counts must match.
|
| 9 |
+
"""
|
| 10 |
+
import csv, json, random, os
|
| 11 |
+
BASE = os.path.expanduser("~/presentations/data/ev_enriched")
|
| 12 |
+
random.seed(7)
|
| 13 |
+
|
| 14 |
+
# ---- load 2024 rows from all profiles (the "clean truth" we corrupt) ----
|
| 15 |
+
truth = []
|
| 16 |
+
for prof in ["rare_user", "moderate_user", "daily_user", "heavy_user"]:
|
| 17 |
+
with open(f"{BASE}/silver/fact_telemetry_{prof}.csv") as f:
|
| 18 |
+
for r in csv.DictReader(f):
|
| 19 |
+
if r["timestamp"].startswith("2024"):
|
| 20 |
+
truth.append(r)
|
| 21 |
+
print("clean truth rows (2024):", len(truth))
|
| 22 |
+
|
| 23 |
+
def census():
|
| 24 |
+
return {"rows": len(truth), "faults": {}}
|
| 25 |
+
|
| 26 |
+
c = census()
|
| 27 |
+
rows = []
|
| 28 |
+
# ---- 1. missing readings (~3.5% of rows, one field each) ----
|
| 29 |
+
miss = {"SOC": 0, "Battery_Temp": 0, "Tire_Pressure": 0}
|
| 30 |
+
for r in truth:
|
| 31 |
+
x = random.random()
|
| 32 |
+
if x < 0.012: r["SOC"] = ""; miss["SOC"] += 1
|
| 33 |
+
elif x < 0.024: r["Battery_Temp"] = ""; miss["Battery_Temp"] += 1
|
| 34 |
+
elif x < 0.035: r["Tire_Pressure"] = ""; miss["Tire_Pressure"] += 1
|
| 35 |
+
c["faults"]["missing_values"] = sum(miss.values()); c["faults"]["missing_by_field"] = miss
|
| 36 |
+
rows.extend(truth)
|
| 37 |
+
|
| 38 |
+
# ---- 2. out-of-bound values (plausible sensor glitches) ----
|
| 39 |
+
def ob(col, lo, hi, frac):
|
| 40 |
+
picks = [r for r in rows if r[col] != ""]
|
| 41 |
+
chosen = random.sample(picks, int(len(picks) * frac))
|
| 42 |
+
for r in chosen:
|
| 43 |
+
v = float(r[col])
|
| 44 |
+
r[col] = round(lo + (hi - lo) * random.random(), 2)
|
| 45 |
+
c["faults"][f"out_of_bound:{col}"] = {"n": len(chosen), "planted_range": [lo, hi]}
|
| 46 |
+
|
| 47 |
+
ob("SOC", 100.5, 145, 0.008) # SOC can never exceed 100 %
|
| 48 |
+
ob("SOH", 100.0, 104.2, 0.005) # health % cannot exceed 100
|
| 49 |
+
ob("Battery_Temp", -42.0, -25.0, 0.005) # below thermistor floor
|
| 50 |
+
ob("Brake_Pad_Wear", 100.5, 112.0, 0.006)
|
| 51 |
+
c["faults"]["out_of_bound:Tire_Pressure_zero"] = {"n": 0}
|
| 52 |
+
rowsz = [r for r in rows if r["Tire_Pressure"] != ""]
|
| 53 |
+
for r in random.sample(rowsz, 24):
|
| 54 |
+
r["Tire_Pressure"] = "0.0"
|
| 55 |
+
c["faults"]["out_of_bound:Tire_Pressure_zero"] = {"n": 24, "planted_range": [0, 0]}
|
| 56 |
+
|
| 57 |
+
# ---- 3. unit mix-up: tire pressure reported in kPa (PSI × 6.895) by one gateway ----
|
| 58 |
+
kpak = [r for r in rows if r["Tire_Pressure"] != "" and float(r["Tire_Pressure"]) > 0]
|
| 59 |
+
chosen = random.sample(kpak, int(len(kpak) * 0.015))
|
| 60 |
+
for r in chosen:
|
| 61 |
+
r["Tire_Pressure"] = round(float(r["Tire_Pressure"]) * 6.895, 1) # 34 PSI -> ~234 kPa
|
| 62 |
+
c["faults"]["unit_mix:Tire_Pressure_kPa"] = {"n": len(chosen), "rule": "value > 60 implies kPa; /6.895 to PSI"}
|
| 63 |
+
|
| 64 |
+
# ---- 4. duplicate retries (~1.2%) ----
|
| 65 |
+
dup_ct = int(len(rows) * 0.012)
|
| 66 |
+
rows.extend([dict(r) for r in random.sample(rows, dup_ct)])
|
| 67 |
+
c["faults"]["duplicate_rows"] = dup_ct
|
| 68 |
+
|
| 69 |
+
# ---- 5. shuffle: arrival order is never sorted ----
|
| 70 |
+
random.shuffle(rows)
|
| 71 |
+
|
| 72 |
+
cols = ["timestamp","vehicle_id","user_profile","district","SOC","SOH","Charging_Cycles",
|
| 73 |
+
"charging_now","Battery_Temp","Motor_RPM","Motor_Torque","Motor_Temp",
|
| 74 |
+
"Brake_Pad_Wear","Charging_Voltage","Tire_Pressure","DTC","grid_carbon_g_per_kwh"]
|
| 75 |
+
out = f"{BASE}/bronze/ingest_stream_2024.csv"
|
| 76 |
+
with open(out, "w", newline="") as f:
|
| 77 |
+
w = csv.DictWriter(f, cols); w.writeheader(); w.writerows(rows)
|
| 78 |
+
c["faults"]["rows_after_fault_injection"] = len(rows)
|
| 79 |
+
with open(f"{BASE}/bronze/fault_census.json", "w") as f:
|
| 80 |
+
json.dump(c, f, indent=2)
|
| 81 |
+
print(json.dumps(c, indent=2))
|
| 82 |
+
print("wrote", out)
|
raw/daily_user.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
raw/heavy_user.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
raw/moderate_user.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
raw/rare_user.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|