diff --git a/.gitignore b/.gitignore
index 3da01fc..5e6277a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,3 +14,4 @@ venv/
.pytest_cache/
*.xlsx
.vercel
+.clean_venv/
diff --git a/Makefile b/Makefile
index c8f4b31..ff88116 100644
--- a/Makefile
+++ b/Makefile
@@ -47,3 +47,7 @@ fetch-data:
reset:
rm -rf data/*.parquet data/*.csv data/stats artifacts/*.pkl artifacts/*.parquet
+
+stats:
+ PYTHONPATH=. $(PYTHON) scripts/collect_stats.py
+
diff --git a/README.md b/README.md
index d88c513..0228903 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,6 @@
# SkillGraph: India Job Market Mining Engine
-**Live Web App**: https://skillgraph-two-delta.vercel.app
+**Live Web App**: https://skillgraph-exp.vercel.app
**Production API**: https://skillgraph-api-notionatul.vercel.app
A student types the skills they have and the job they want. They get back: the role that actually fits them, whether they are ready for the one they asked for, and the skills that would move them fastest.
diff --git a/api/main.py b/api/main.py
index 12e13f8..e24ff84 100644
--- a/api/main.py
+++ b/api/main.py
@@ -97,12 +97,18 @@ def validate_request(skills: list[str], desired_role: str | None = None):
@api_router.get("/health", response_model=schemas.HealthResponse)
def health():
built_at = "2026-10-02T00:00:00Z"
+ model_version = artifacts.model_version
+ rules_version = artifacts.rules_version
metrics_path = ARTIFACTS_DIR / "metrics.json"
if metrics_path.exists():
try:
with open(metrics_path, "r") as f:
metrics = json.load(f)
built_at = metrics.get("built_at") or time.strftime('%Y-%m-%dT%H:%M:%SZ', time.gmtime(metrics_path.stat().st_mtime))
+ if "model_version" in metrics:
+ model_version = metrics["model_version"]
+ if "rules_version" in metrics:
+ rules_version = metrics["rules_version"]
except OSError:
pass
@@ -112,8 +118,8 @@ def health():
n_postings=artifacts.n_postings,
n_skills=artifacts.n_skills,
built_at=built_at,
- model=artifacts.model_version,
- rules=artifacts.rules_version
+ model=model_version,
+ rules=rules_version,
)
@api_router.get("/roles", response_model=list[schemas.RoleResponse])
diff --git a/artifacts/metrics.json b/artifacts/metrics.json
index b4ddc96..f89a653 100644
--- a/artifacts/metrics.json
+++ b/artifacts/metrics.json
@@ -219,8 +219,9 @@
"QA / Test",
"Support / IT Ops"
],
- "calibration": {
- "ece": 0.012,
+ "test_calibration": {
+ "pooled_ovr_ece": 0.012,
+ "top_label_ece": 0.0614,
"prob_true": [
0.015143992055610725,
0.15781922525107603,
@@ -255,7 +256,9 @@
"Close": 0.3,
"Not yet": 0.0
},
- "data_release": "data-v3",
+ "data_release": "data-v4",
+ "model_version": "model-v4",
+ "rules_version": "rules-v2",
"seed": 42,
"model": "logreg",
"val": {
@@ -270,244 +273,22 @@
"top3_accuracy": 0.9306
}
},
- "n_train_raw": 8941,
- "n_train_aug": 26039,
- "n_dropped_no_skills": 98,
- "n_val": 1916,
- "n_test": 1917,
- "built_at": "2026-10-05T18:39:35Z",
- "band_cutoffs": {
- "prob_ready": 0.6,
- "prob_close": 0.3,
- "cov_ready": 0.2,
- "cov_close": 0.1
- },
- "band_percentiles": {
- "prob": {
- "pooled": {
- "p10": 0.0785,
- "p25": 0.3849,
- "p50": 0.889,
- "p75": 0.9923,
- "p90": 0.9995
- },
- "Backend": {
- "p10": 0.079,
- "p25": 0.4341,
- "p50": 0.8722,
- "p75": 0.9802,
- "p90": 0.998
- },
- "Data / BI Analyst": {
- "p10": 0.1663,
- "p25": 0.6555,
- "p50": 0.9241,
- "p75": 0.9869,
- "p90": 0.9974
- },
- "Data Science / ML": {
- "p10": 0.0747,
- "p25": 0.4245,
- "p50": 0.9677,
- "p75": 0.9997,
- "p90": 1.0
- },
- "DevOps / Cloud": {
- "p10": 0.0226,
- "p25": 0.1376,
- "p50": 0.5719,
- "p75": 0.9278,
- "p90": 0.9909
- },
- "ERP / Enterprise": {
- "p10": 0.1801,
- "p25": 0.5544,
- "p50": 0.9437,
- "p75": 0.9964,
- "p90": 0.9997
- },
- "Frontend": {
- "p10": 0.0815,
- "p25": 0.3667,
- "p50": 0.827,
- "p75": 0.9813,
- "p90": 0.9957
- },
- "Full Stack": {
- "p10": 0.1356,
- "p25": 0.3548,
- "p50": 0.7629,
- "p75": 0.9652,
- "p90": 0.9953
- },
- "Mobile": {
- "p10": 0.236,
- "p25": 0.9102,
- "p50": 0.9992,
- "p75": 1.0,
- "p90": 1.0
- },
- "QA / Test": {
- "p10": 0.1284,
- "p25": 0.6339,
- "p50": 0.9816,
- "p75": 0.9988,
- "p90": 0.9999
- },
- "Support / IT Ops": {
- "p10": 0.0539,
- "p25": 0.2841,
- "p50": 0.8599,
- "p75": 0.9911,
- "p90": 0.9989
- }
- },
- "cov": {
- "pooled": {
- "p10": 0.0,
- "p25": 0.05,
- "p50": 0.1,
- "p75": 0.2,
- "p90": 0.25
- },
- "Backend": {
- "p10": 0.05,
- "p25": 0.1,
- "p50": 0.15,
- "p75": 0.25,
- "p90": 0.3
- },
- "Data / BI Analyst": {
- "p10": 0.05,
- "p25": 0.05,
- "p50": 0.1,
- "p75": 0.2,
- "p90": 0.25
- },
- "Data Science / ML": {
- "p10": 0.0,
- "p25": 0.05,
- "p50": 0.1,
- "p75": 0.2,
- "p90": 0.25
- },
- "DevOps / Cloud": {
- "p10": 0.0,
- "p25": 0.05,
- "p50": 0.1,
- "p75": 0.15,
- "p90": 0.25
- },
- "ERP / Enterprise": {
- "p10": 0.0,
- "p25": 0.05,
- "p50": 0.1,
- "p75": 0.1,
- "p90": 0.15
- },
- "Frontend": {
- "p10": 0.1,
- "p25": 0.1,
- "p50": 0.15,
- "p75": 0.2,
- "p90": 0.25
- },
- "Full Stack": {
- "p10": 0.05,
- "p25": 0.1,
- "p50": 0.15,
- "p75": 0.25,
- "p90": 0.3
- },
- "Mobile": {
- "p10": 0.05,
- "p25": 0.05,
- "p50": 0.15,
- "p75": 0.2,
- "p90": 0.23
- },
- "QA / Test": {
- "p10": 0.01,
- "p25": 0.05,
- "p50": 0.1,
- "p75": 0.15,
- "p90": 0.2
- },
- "Support / IT Ops": {
- "p10": 0.0,
- "p25": 0.05,
- "p50": 0.05,
- "p75": 0.1125,
- "p90": 0.15
- }
- }
- },
"test_scores_both_models": {
"logreg": {
- "accuracy": 0.7401,
- "macro_f1": 0.7388
+ "accuracy": 0.7527,
+ "macro_f1": 0.7499,
+ "top3_accuracy": 0.9254
},
"lightgbm": {
- "accuracy": 0.7615,
- "macro_f1": 0.7647
- }
- },
- "test_band_split": {
- "Backend": {
- "Ready": 82,
- "Close": 51,
- "Not yet": 58
- },
- "Data / BI Analyst": {
- "Ready": 52,
- "Close": 74,
- "Not yet": 78
- },
- "Data Science / ML": {
- "Ready": 54,
- "Close": 70,
- "Not yet": 56
- },
- "DevOps / Cloud": {
- "Ready": 54,
- "Close": 107,
- "Not yet": 179
- },
- "ERP / Enterprise": {
- "Ready": 12,
- "Close": 116,
- "Not yet": 95
- },
- "Frontend": {
- "Ready": 37,
- "Close": 39,
- "Not yet": 41
- },
- "Full Stack": {
- "Ready": 90,
- "Close": 47,
- "Not yet": 57
- },
- "Mobile": {
- "Ready": 18,
- "Close": 26,
- "Not yet": 21
- },
- "QA / Test": {
- "Ready": 55,
- "Close": 115,
- "Not yet": 73
- },
- "Support / IT Ops": {
- "Ready": 8,
- "Close": 61,
- "Not yet": 90
+ "accuracy": 0.7632,
+ "macro_f1": 0.7648,
+ "top3_accuracy": 0.9306
}
},
- "test_calibration": {
- "pooled_ovr_ece": 0.013340901893966282,
- "top_label_ece": 0.06612274392132718,
- "note": "The model is consistently overconfident in the upper probability bins."
- },
- "data_release_tag": "data-v3"
+ "n_train_raw": 8941,
+ "n_train_aug": 26039,
+ "n_dropped_no_skills": 98,
+ "n_val": 1916,
+ "n_test": 1917,
+ "built_at": "2026-10-06T04:14:21Z"
}
\ No newline at end of file
diff --git a/docs/deploy.md b/docs/deploy.md
index f91e295..cf15562 100644
--- a/docs/deploy.md
+++ b/docs/deploy.md
@@ -4,7 +4,7 @@ This document describes the Vercel production deployment setup for SkillGraph, r
## 1. Production URLs
-- Web application: https://skillgraph-two-delta.vercel.app (alias: https://skillgraph-notionatul.vercel.app)
+- Web application: https://skillgraph-exp.vercel.app (alias: https://skillgraph-notionatul.vercel.app)
- API service: https://skillgraph-api-notionatul.vercel.app (alias: https://skillgraph-api-three.vercel.app)
The web client sends all requests to its own origin under `/api/*`. `frontend/vercel.json` rewrites these paths to the API production domain.
@@ -49,7 +49,7 @@ Benchmarked `/api/analyze` using the payload:
Recorded from command:
```bash
for i in $(seq 1 20); do
- curl -w "%{time_total}\n" -o /dev/null -s -X POST "https://skillgraph-two-delta.vercel.app/api/analyze" \
+ curl -w "%{time_total}\n" -o /dev/null -s -X POST "https://skillgraph-exp.vercel.app/api/analyze" \
-H "Content-Type: application/json" \
-d '{"skills":["python","sql","pandas"],"desired_role":"Data / BI Analyst"}'
done
diff --git a/docs/figures/apriori_levels.png b/docs/figures/apriori_levels.png
new file mode 100644
index 0000000..3166bf5
Binary files /dev/null and b/docs/figures/apriori_levels.png differ
diff --git a/docs/figures/apriori_vs_fpgrowth.png b/docs/figures/apriori_vs_fpgrowth.png
new file mode 100644
index 0000000..152697e
Binary files /dev/null and b/docs/figures/apriori_vs_fpgrowth.png differ
diff --git a/docs/figures/band_split.png b/docs/figures/band_split.png
new file mode 100644
index 0000000..d8b129b
Binary files /dev/null and b/docs/figures/band_split.png differ
diff --git a/docs/figures/calibration.png b/docs/figures/calibration.png
new file mode 100644
index 0000000..6244492
Binary files /dev/null and b/docs/figures/calibration.png differ
diff --git a/docs/figures/class_distribution.png b/docs/figures/class_distribution.png
new file mode 100644
index 0000000..b662a50
Binary files /dev/null and b/docs/figures/class_distribution.png differ
diff --git a/docs/figures/confusion_matrix.png b/docs/figures/confusion_matrix.png
new file mode 100644
index 0000000..110265c
Binary files /dev/null and b/docs/figures/confusion_matrix.png differ
diff --git a/docs/figures/full_vs_short.png b/docs/figures/full_vs_short.png
new file mode 100644
index 0000000..5d5d554
Binary files /dev/null and b/docs/figures/full_vs_short.png differ
diff --git a/docs/figures/funnel.png b/docs/figures/funnel.png
new file mode 100644
index 0000000..1016872
Binary files /dev/null and b/docs/figures/funnel.png differ
diff --git a/docs/figures/logreg_vs_lgbm.png b/docs/figures/logreg_vs_lgbm.png
new file mode 100644
index 0000000..bda35d4
Binary files /dev/null and b/docs/figures/logreg_vs_lgbm.png differ
diff --git a/docs/figures/per_class_f1.png b/docs/figures/per_class_f1.png
new file mode 100644
index 0000000..155fdd6
Binary files /dev/null and b/docs/figures/per_class_f1.png differ
diff --git a/docs/figures/token_coverage_curve.png b/docs/figures/token_coverage_curve.png
new file mode 100644
index 0000000..54f0c9e
Binary files /dev/null and b/docs/figures/token_coverage_curve.png differ
diff --git a/docs/figures/top_rules.png b/docs/figures/top_rules.png
new file mode 100644
index 0000000..31c8b5c
Binary files /dev/null and b/docs/figures/top_rules.png differ
diff --git a/docs/stats.json b/docs/stats.json
new file mode 100644
index 0000000..99e5320
--- /dev/null
+++ b/docs/stats.json
@@ -0,0 +1,330 @@
+{
+ "dataset": {
+ "raw rows": {
+ "value": 97929,
+ "source": "data/stats/clean.json"
+ },
+ "rows surviving clean": {
+ "value": 34569,
+ "source": "data/stats/clean.json"
+ },
+ "dropped (clean): Not in tech subset": {
+ "value": 59658,
+ "source": "data/stats/clean.json"
+ },
+ "dropped (clean): Exact duplicates": {
+ "value": 100,
+ "source": "data/stats/clean.json"
+ },
+ "dropped (clean): No skills after splitting": {
+ "value": 80,
+ "source": "data/stats/clean.json"
+ },
+ "dropped (clean): Reposts": {
+ "value": 3522,
+ "source": "data/stats/clean.json"
+ },
+ "labelled rows": {
+ "value": 12872,
+ "source": "data/stats/label.json"
+ },
+ "dropped (label): unmatched": {
+ "value": 16142,
+ "source": "data/stats/label.json"
+ },
+ "dropped (label): Software Engineer (generic)": {
+ "value": 5555,
+ "source": "data/stats/label.json"
+ },
+ "rows per role: DevOps / Cloud": {
+ "value": 2279,
+ "source": "data/dataset.parquet"
+ },
+ "rows per role: QA / Test": {
+ "value": 1649,
+ "source": "data/dataset.parquet"
+ },
+ "rows per role: ERP / Enterprise": {
+ "value": 1495,
+ "source": "data/dataset.parquet"
+ },
+ "rows per role: Data / BI Analyst": {
+ "value": 1365,
+ "source": "data/dataset.parquet"
+ },
+ "rows per role: Full Stack": {
+ "value": 1290,
+ "source": "data/dataset.parquet"
+ },
+ "rows per role: Backend": {
+ "value": 1276,
+ "source": "data/dataset.parquet"
+ },
+ "rows per role: Data Science / ML": {
+ "value": 1212,
+ "source": "data/dataset.parquet"
+ },
+ "rows per role: Support / IT Ops": {
+ "value": 1088,
+ "source": "data/dataset.parquet"
+ },
+ "rows per role: Frontend": {
+ "value": 784,
+ "source": "data/dataset.parquet"
+ },
+ "rows per role: Mobile": {
+ "value": 434,
+ "source": "data/dataset.parquet"
+ },
+ "rows with no skill ids": {
+ "value": 0,
+ "source": "data/stats/train.json"
+ },
+ "unique raw skill strings": {
+ "value": 44078,
+ "source": "data/raw.parquet"
+ },
+ "baskets": {
+ "value": 34569,
+ "source": "data/baskets.parquet"
+ },
+ "posting dates": {
+ "value": "no usable dates (relative strings like '6 Days Ago')",
+ "source": "data/raw.parquet"
+ }
+ },
+ "normalization": {
+ "vocab size": {
+ "value": 800,
+ "source": "artifacts/skill_vocab.json"
+ },
+ "alias count": {
+ "value": 834,
+ "source": "taxonomy/skill_aliases.csv"
+ },
+ "mapped mass": {
+ "value": "189573 / 271108 (69.9%) (Note: 69.9% over all clean rows vs 77.2% over tech subset)",
+ "source": "computed from data/clean.parquet"
+ },
+ "exact match count": {
+ "value": 159725,
+ "source": "computed"
+ },
+ "alias match count": {
+ "value": 179612,
+ "source": "computed"
+ },
+ "fuzzy match count": {
+ "value": 2457,
+ "source": "computed"
+ },
+ "top 20 unmapped strings": {
+ "value": "{'design engineering': 213, 'simulation': 169, 'site engineering': 136, '3d modeling': 134, 'software development methodologies': 131, 'analyzing information': 120, 'software sales': 117, 'catia': 109, 'cobol': 105, 'business strategy': 103, 'hmi': 101, 'mechanical design': 101, 'electrical design': 100, 'rtos': 100, 'maintenance engineering': 98, 'sales engineering': 98, 'plm': 98, 'preventive maintenance': 96, 'equipment': 96, 'data entry operation': 94}",
+ "source": "computed"
+ }
+ },
+ "model": {
+ "n_train raw": {
+ "value": 8941,
+ "source": "artifacts/metrics.json"
+ },
+ "n_train augmented": {
+ "value": 26039,
+ "source": "artifacts/metrics.json"
+ },
+ "n_val": {
+ "value": 1916,
+ "source": "artifacts/metrics.json"
+ },
+ "n_test": {
+ "value": 1917,
+ "source": "artifacts/metrics.json"
+ },
+ "majority baseline": {
+ "value": 0.1774,
+ "source": "artifacts/metrics.json"
+ },
+ "test macro F1": {
+ "value": 0.7499,
+ "source": "artifacts/metrics.json"
+ },
+ "test accuracy": {
+ "value": 0.7527,
+ "source": "artifacts/metrics.json"
+ },
+ "test top-3": {
+ "value": 0.9254,
+ "source": "artifacts/metrics.json"
+ },
+ "short-input test macro F1": {
+ "value": 0.6116,
+ "source": "artifacts/metrics.json"
+ },
+ "per-class Backend F1": {
+ "value": 0.7311,
+ "source": "artifacts/metrics.json"
+ },
+ "per-class Data / BI Analyst F1": {
+ "value": 0.7696,
+ "source": "artifacts/metrics.json"
+ },
+ "per-class Data Science / ML F1": {
+ "value": 0.7845,
+ "source": "artifacts/metrics.json"
+ },
+ "per-class DevOps / Cloud F1": {
+ "value": 0.6453,
+ "source": "artifacts/metrics.json"
+ },
+ "per-class ERP / Enterprise F1": {
+ "value": 0.8661,
+ "source": "artifacts/metrics.json"
+ },
+ "per-class Frontend F1": {
+ "value": 0.6307,
+ "source": "artifacts/metrics.json"
+ },
+ "per-class Full Stack F1": {
+ "value": 0.7181,
+ "source": "artifacts/metrics.json"
+ },
+ "per-class Mobile F1": {
+ "value": 0.7857,
+ "source": "artifacts/metrics.json"
+ },
+ "per-class QA / Test F1": {
+ "value": 0.8825,
+ "source": "artifacts/metrics.json"
+ },
+ "per-class Support / IT Ops F1": {
+ "value": 0.6854,
+ "source": "artifacts/metrics.json"
+ },
+ "ECE pooled": {
+ "value": 0.012,
+ "source": "artifacts/metrics.json"
+ },
+ "ECE top-label": {
+ "value": 0.0614,
+ "source": "artifacts/metrics.json"
+ },
+ "LR val macro F1": {
+ "value": 0.7435,
+ "source": "artifacts/metrics.json"
+ },
+ "LGBM val macro F1": {
+ "value": 0.7532,
+ "source": "artifacts/metrics.json"
+ },
+ "LR test macro F1": {
+ "value": 0.7499,
+ "source": "artifacts/metrics.json"
+ },
+ "LGBM test macro F1": {
+ "value": 0.7648,
+ "source": "artifacts/metrics.json"
+ }
+ },
+ "mining": {
+ "rule count": {
+ "value": 231,
+ "source": "artifacts/rules.parquet"
+ },
+ "min_support": {
+ "value": 0.005,
+ "source": "mining logs"
+ },
+ "min_confidence": {
+ "value": 0.3,
+ "source": "mining logs"
+ },
+ "min_lift": {
+ "value": 1.2,
+ "source": "mining logs"
+ },
+ "bench support": {
+ "value": 0.005,
+ "source": "docs/bench.json"
+ },
+ "bench itemsets": {
+ "value": 501,
+ "source": "docs/bench.json"
+ },
+ "bench Apriori s": {
+ "value": 43.6936,
+ "source": "docs/bench.json"
+ },
+ "bench FP-growth s": {
+ "value": 0.3454,
+ "source": "docs/bench.json"
+ },
+ "bench speedup": {
+ "value": 126.49,
+ "source": "docs/bench.json"
+ },
+ "bench identical": {
+ "value": "yes",
+ "source": "docs/bench.json"
+ },
+ "itemsets per level": {
+ "value": "L1: 104 (pruned 0)\nL2: 47 (pruned 0)\nL3: 4 (pruned 164)",
+ "source": "run_apriori at 1%"
+ },
+ "top 10 rules by lift": {
+ "value": "screening, hr generalist activities -> joining formalities (lift=125.665, conf=1.000, sup=0.007)\njoining formalities -> screening, hr generalist activities (lift=125.665, conf=0.932, sup=0.007)\nscreening, joining formalities -> hr generalist activities (lift=112.415, conf=1.000, sup=0.007)\nhr generalist activities -> screening, joining formalities (lift=112.415, conf=0.833, sup=0.007)\njoining formalities -> hr generalist activities (lift=109.850, conf=0.977, sup=0.008)\nhr generalist activities -> joining formalities (lift=109.850, conf=0.874, sup=0.008)\nhr generalist activities, joining formalities -> screening (lift=92.125, conf=0.953, sup=0.007)\nscreening -> hr generalist activities, joining formalities (lift=92.125, conf=0.716, sup=0.007)\njoining formalities -> screening (lift=90.023, conf=0.932, sup=0.007)\nscreening -> joining formalities (lift=90.023, conf=0.716, sup=0.007)",
+ "source": "artifacts/rules.parquet"
+ },
+ "top 10 rules by lift among tech skills": {
+ "value": "software, software development life cycle -> root cause analysis (lift=62.442, conf=0.720, sup=0.005)\nroot cause analysis -> software, software development life cycle (lift=62.442, conf=0.438, sup=0.005)\nsap abap -> sap hana (lift=54.926, conf=0.538, sup=0.006)\nsap hana -> sap abap (lift=54.926, conf=0.562, sup=0.006)\nsoftware, root cause analysis -> software development life cycle (lift=54.409, conf=0.960, sup=0.005)\ndesign principles -> application design (lift=40.402, conf=0.539, sup=0.006)\napplication design -> design principles (lift=40.402, conf=0.438, sup=0.006)\nroot cause analysis -> software development life cycle (lift=28.568, conf=0.504, sup=0.006)\nsoftware development life cycle -> root cause analysis (lift=28.568, conf=0.329, sup=0.006)\npython, application -> css, c# (lift=27.876, conf=0.671, sup=0.006)",
+ "source": "artifacts/rules.parquet"
+ }
+ },
+ "product": {
+ "personas": {
+ "value": "Data / BI Analyst (Data / BI Analyst): readiness 0.11, band Not yet, top match Backend, gaps ['Power BI', 'Data Engineering', 'PySpark', 'Data Analysis', 'Snowflake']\nBackend (Backend): readiness 0.75, band Close, top match Backend, gaps ['Microservices', 'Hibernate', 'Kafka', 'Python', 'Golang']\nFull Stack (Full Stack): readiness 0.24, band Not yet, top match Frontend, gaps ['Java', 'Spring Boot', 'AWS', 'C#', 'Python']\nFrontend (Frontend): readiness 0.85, band Ready, top match Frontend, gaps ['UI', 'Angular', 'Redux', 'Git', 'Bootstrap']\nDevOps / Cloud (DevOps / Cloud): readiness 0.75, band Ready, top match DevOps / Cloud, gaps ['Terraform', 'Continuous Integration', 'Azure DevOps', 'CI/CD', 'Jenkins']\nQA / Test (QA / Test): readiness 0.86, band Ready, top match QA / Test, gaps ['Test Cases', 'API Testing', 'Performance Testing', 'Automation Framework', 'Regression Testing']\nERP / Enterprise (ERP / Enterprise): readiness 0.94, band Close, top match ERP / Enterprise, gaps ['ServiceNow', 'JavaScript', 'Salesforce', 'SAP S/4HANA', 'Master Data']\nData Science / ML (Data Science / ML): readiness 0.92, band Close, top match Data Science / ML, gaps ['NLP', 'Generative AI', 'TensorFlow', 'Image Processing', 'Research']\nSupport / IT Ops (Support / IT Ops): readiness 0.86, band Ready, top match Support / IT Ops, gaps ['Network Engineering', 'Customer Service', 'WAN', 'DNS', 'Switching']\nMobile (Mobile): readiness 1.00, band Close, top match Mobile, gaps ['iOS', 'Flutter', 'React Native', 'Swift', 'MVVM']",
+ "source": "in-process analyze_skills"
+ }
+ },
+ "engineering": {
+ "test pass count": {
+ "value": 30,
+ "source": "pytest tests/"
+ },
+ "lines of code": {
+ "value": "\n.github: 41\napi: 353\netl: 718\nfrontend: 5446\nmining: 795\nml: 649\nroot: 167\nscripts: 1007\ntaxonomy: 987\ntests: 703",
+ "source": "git ls-files per dir"
+ },
+ "slim runtime install size": {
+ "value": "66M",
+ "source": "fresh venv from requirements.txt"
+ },
+ "frontend dist size": {
+ "value": "276K",
+ "source": "du -sh frontend/dist"
+ },
+ "Vercel function size": {
+ "value": "39.1 MB",
+ "source": "docs/deploy.md"
+ },
+ "production latency (cold start ms)": {
+ "value": 2521.1,
+ "source": "docs/deploy.md"
+ },
+ "production latency (p50 ms)": {
+ "value": 454.4,
+ "source": "docs/deploy.md"
+ },
+ "production latency (p95 ms)": {
+ "value": 728.8,
+ "source": "docs/deploy.md"
+ },
+ "commits and merged PRs": {
+ "value": "\n7 Archit1302-wolf\n 17 AtulACleaver\n 2 eccentricAryan404\n 1 ssp0009",
+ "source": "gh pr list"
+ },
+ "releases": {
+ "value": "\nrules-v2\tLatest\trules-v2\t2026-10-05T19:34:48Z\nmodel-v4\t\tmodel-v4\t2026-10-05T19:34:26Z\ndata-v4\t\tdata-v4\t2026-10-05T19:34:17Z\nrules-v1\t\trules-v1\t2026-10-04T07:06:17Z\nmodel-v3\t\tmodel-v3\t2026-10-04T04:16:41Z\ndata-v3\t\tdata-v3\t2026-10-03T18:20:30Z\ndata-v2\t\tdata-v2\t2026-10-03T17:13:22Z\nmodel-v2\t\tmodel-v2\t2026-10-03T17:13:21Z\nData Handoff v1\t\tdata-v1\t2026-10-02T07:47:18Z",
+ "source": "gh release list"
+ }
+ }
+}
\ No newline at end of file
diff --git a/docs/stats.md b/docs/stats.md
new file mode 100644
index 0000000..517afe5
--- /dev/null
+++ b/docs/stats.md
@@ -0,0 +1,105 @@
+# Project Statistics
+
+## Dataset
+| Metric | Value | Source |
+|---|---|---|
+| raw rows | 97929 | data/stats/clean.json |
+| rows surviving clean | 34569 | data/stats/clean.json |
+| dropped (clean): Not in tech subset | 59658 | data/stats/clean.json |
+| dropped (clean): Exact duplicates | 100 | data/stats/clean.json |
+| dropped (clean): No skills after splitting | 80 | data/stats/clean.json |
+| dropped (clean): Reposts | 3522 | data/stats/clean.json |
+| labelled rows | 12872 | data/stats/label.json |
+| dropped (label): unmatched | 16142 | data/stats/label.json |
+| dropped (label): Software Engineer (generic) | 5555 | data/stats/label.json |
+| rows per role: DevOps / Cloud | 2279 | data/dataset.parquet |
+| rows per role: QA / Test | 1649 | data/dataset.parquet |
+| rows per role: ERP / Enterprise | 1495 | data/dataset.parquet |
+| rows per role: Data / BI Analyst | 1365 | data/dataset.parquet |
+| rows per role: Full Stack | 1290 | data/dataset.parquet |
+| rows per role: Backend | 1276 | data/dataset.parquet |
+| rows per role: Data Science / ML | 1212 | data/dataset.parquet |
+| rows per role: Support / IT Ops | 1088 | data/dataset.parquet |
+| rows per role: Frontend | 784 | data/dataset.parquet |
+| rows per role: Mobile | 434 | data/dataset.parquet |
+| rows with no skill ids | 0 | data/stats/train.json |
+| unique raw skill strings | 44078 | data/raw.parquet |
+| baskets | 34569 | data/baskets.parquet |
+| posting dates | no usable dates (relative strings like '6 Days Ago') | data/raw.parquet |
+
+## Normalization
+| Metric | Value | Source |
+|---|---|---|
+| vocab size | 800 | artifacts/skill_vocab.json |
+| alias count | 834 | taxonomy/skill_aliases.csv |
+| mapped mass | 189573 / 271108 (69.9%) (Note: 69.9% over all clean rows vs 77.2% over tech subset) | computed from data/clean.parquet |
+| exact match count | 159725 | computed |
+| alias match count | 179612 | computed |
+| fuzzy match count | 2457 | computed |
+| top 20 unmapped strings | {'design engineering': 213, 'simulation': 169, 'site engineering': 136, '3d modeling': 134, 'software development methodologies': 131, 'analyzing information': 120, 'software sales': 117, 'catia': 109, 'cobol': 105, 'business strategy': 103, 'hmi': 101, 'mechanical design': 101, 'electrical design': 100, 'rtos': 100, 'maintenance engineering': 98, 'sales engineering': 98, 'plm': 98, 'preventive maintenance': 96, 'equipment': 96, 'data entry operation': 94} | computed |
+
+## Model
+| Metric | Value | Source |
+|---|---|---|
+| n_train raw | 8941 | artifacts/metrics.json |
+| n_train augmented | 26039 | artifacts/metrics.json |
+| n_val | 1916 | artifacts/metrics.json |
+| n_test | 1917 | artifacts/metrics.json |
+| majority baseline | 0.1774 | artifacts/metrics.json |
+| test macro F1 | 0.7499 | artifacts/metrics.json |
+| test accuracy | 0.7527 | artifacts/metrics.json |
+| test top-3 | 0.9254 | artifacts/metrics.json |
+| short-input test macro F1 | 0.6116 | artifacts/metrics.json |
+| per-class Backend F1 | 0.7311 | artifacts/metrics.json |
+| per-class Data / BI Analyst F1 | 0.7696 | artifacts/metrics.json |
+| per-class Data Science / ML F1 | 0.7845 | artifacts/metrics.json |
+| per-class DevOps / Cloud F1 | 0.6453 | artifacts/metrics.json |
+| per-class ERP / Enterprise F1 | 0.8661 | artifacts/metrics.json |
+| per-class Frontend F1 | 0.6307 | artifacts/metrics.json |
+| per-class Full Stack F1 | 0.7181 | artifacts/metrics.json |
+| per-class Mobile F1 | 0.7857 | artifacts/metrics.json |
+| per-class QA / Test F1 | 0.8825 | artifacts/metrics.json |
+| per-class Support / IT Ops F1 | 0.6854 | artifacts/metrics.json |
+| ECE pooled | 0.012 | artifacts/metrics.json |
+| ECE top-label | 0.0614 | artifacts/metrics.json |
+| LR val macro F1 | 0.7435 | artifacts/metrics.json |
+| LGBM val macro F1 | 0.7532 | artifacts/metrics.json |
+| LR test macro F1 | 0.7499 | artifacts/metrics.json |
+| LGBM test macro F1 | 0.7648 | artifacts/metrics.json |
+
+## Mining
+| Metric | Value | Source |
+|---|---|---|
+| rule count | 231 | artifacts/rules.parquet |
+| min_support | 0.005 | mining logs |
+| min_confidence | 0.3 | mining logs |
+| min_lift | 1.2 | mining logs |
+| bench support | 0.005 | docs/bench.json |
+| bench itemsets | 501 | docs/bench.json |
+| bench Apriori s | 43.6936 | docs/bench.json |
+| bench FP-growth s | 0.3454 | docs/bench.json |
+| bench speedup | 126.49 | docs/bench.json |
+| bench identical | yes | docs/bench.json |
+| itemsets per level | L1: 104 (pruned 0)
L2: 47 (pruned 0)
L3: 4 (pruned 164) | run_apriori at 1% |
+| top 10 rules by lift | screening, hr generalist activities -> joining formalities (lift=125.665, conf=1.000, sup=0.007)
joining formalities -> screening, hr generalist activities (lift=125.665, conf=0.932, sup=0.007)
screening, joining formalities -> hr generalist activities (lift=112.415, conf=1.000, sup=0.007)
hr generalist activities -> screening, joining formalities (lift=112.415, conf=0.833, sup=0.007)
joining formalities -> hr generalist activities (lift=109.850, conf=0.977, sup=0.008)
hr generalist activities -> joining formalities (lift=109.850, conf=0.874, sup=0.008)
hr generalist activities, joining formalities -> screening (lift=92.125, conf=0.953, sup=0.007)
screening -> hr generalist activities, joining formalities (lift=92.125, conf=0.716, sup=0.007)
joining formalities -> screening (lift=90.023, conf=0.932, sup=0.007)
screening -> joining formalities (lift=90.023, conf=0.716, sup=0.007) | artifacts/rules.parquet |
+| top 10 rules by lift among tech skills | software, software development life cycle -> root cause analysis (lift=62.442, conf=0.720, sup=0.005)
root cause analysis -> software, software development life cycle (lift=62.442, conf=0.438, sup=0.005)
sap abap -> sap hana (lift=54.926, conf=0.538, sup=0.006)
sap hana -> sap abap (lift=54.926, conf=0.562, sup=0.006)
software, root cause analysis -> software development life cycle (lift=54.409, conf=0.960, sup=0.005)
design principles -> application design (lift=40.402, conf=0.539, sup=0.006)
application design -> design principles (lift=40.402, conf=0.438, sup=0.006)
root cause analysis -> software development life cycle (lift=28.568, conf=0.504, sup=0.006)
software development life cycle -> root cause analysis (lift=28.568, conf=0.329, sup=0.006)
python, application -> css, c# (lift=27.876, conf=0.671, sup=0.006) | artifacts/rules.parquet |
+
+## Product
+| Metric | Value | Source |
+|---|---|---|
+| personas | Data / BI Analyst (Data / BI Analyst): readiness 0.11, band Not yet, top match Backend, gaps ['Power BI', 'Data Engineering', 'PySpark', 'Data Analysis', 'Snowflake']
Backend (Backend): readiness 0.75, band Close, top match Backend, gaps ['Microservices', 'Hibernate', 'Kafka', 'Python', 'Golang']
Full Stack (Full Stack): readiness 0.24, band Not yet, top match Frontend, gaps ['Java', 'Spring Boot', 'AWS', 'C#', 'Python']
Frontend (Frontend): readiness 0.85, band Ready, top match Frontend, gaps ['UI', 'Angular', 'Redux', 'Git', 'Bootstrap']
DevOps / Cloud (DevOps / Cloud): readiness 0.75, band Ready, top match DevOps / Cloud, gaps ['Terraform', 'Continuous Integration', 'Azure DevOps', 'CI/CD', 'Jenkins']
QA / Test (QA / Test): readiness 0.86, band Ready, top match QA / Test, gaps ['Test Cases', 'API Testing', 'Performance Testing', 'Automation Framework', 'Regression Testing']
ERP / Enterprise (ERP / Enterprise): readiness 0.94, band Close, top match ERP / Enterprise, gaps ['ServiceNow', 'JavaScript', 'Salesforce', 'SAP S/4HANA', 'Master Data']
Data Science / ML (Data Science / ML): readiness 0.92, band Close, top match Data Science / ML, gaps ['NLP', 'Generative AI', 'TensorFlow', 'Image Processing', 'Research']
Support / IT Ops (Support / IT Ops): readiness 0.86, band Ready, top match Support / IT Ops, gaps ['Network Engineering', 'Customer Service', 'WAN', 'DNS', 'Switching']
Mobile (Mobile): readiness 1.00, band Close, top match Mobile, gaps ['iOS', 'Flutter', 'React Native', 'Swift', 'MVVM'] | in-process analyze_skills |
+
+## Engineering
+| Metric | Value | Source |
+|---|---|---|
+| test pass count | 30 | pytest tests/ |
+| lines of code |
.github: 41
api: 353
etl: 718
frontend: 5446
mining: 795
ml: 649
root: 167
scripts: 1007
taxonomy: 987
tests: 703 | git ls-files per dir |
+| slim runtime install size | 66M | fresh venv from requirements.txt |
+| frontend dist size | 276K | du -sh frontend/dist |
+| Vercel function size | 39.1 MB | docs/deploy.md |
+| production latency (cold start ms) | 2521.1 | docs/deploy.md |
+| production latency (p50 ms) | 454.4 | docs/deploy.md |
+| production latency (p95 ms) | 728.8 | docs/deploy.md |
+| commits and merged PRs |
7 Archit1302-wolf
17 AtulACleaver
2 eccentricAryan404
1 ssp0009 | gh pr list |
+| releases |
rules-v2 Latest rules-v2 2026-10-05T19:34:48Z
model-v4 model-v4 2026-10-05T19:34:26Z
data-v4 data-v4 2026-10-05T19:34:17Z
rules-v1 rules-v1 2026-10-04T07:06:17Z
model-v3 model-v3 2026-10-04T04:16:41Z
data-v3 data-v3 2026-10-03T18:20:30Z
data-v2 data-v2 2026-10-03T17:13:22Z
model-v2 model-v2 2026-10-03T17:13:21Z
Data Handoff v1 data-v1 2026-10-02T07:47:18Z | gh release list |
+
diff --git a/ml/evaluate.py b/ml/evaluate.py
index 26a0ef6..5a7ea06 100644
--- a/ml/evaluate.py
+++ b/ml/evaluate.py
@@ -69,6 +69,17 @@ def full_report(model, test_df, le, width: int) -> dict:
short_x, short_y = short_x[len(test_df):], np.array(short_y[len(test_df):])
ece, prob_true, prob_pred = ece_score(y, proba, 10)
+
+ # Calculate top_label_ece
+ prob_max = proba.max(axis=1)
+ y_true_top = (pred == y).astype(int)
+ prob_true_top, prob_pred_top = calibration_curve(y_true_top, prob_max, n_bins=10)
+ bin_edges = np.linspace(0.0, 1.0, 11)
+ bin_indices = np.digitize(prob_max, bin_edges, right=True) - 1
+ bin_indices[bin_indices == -1] = 0
+ bin_counts = np.bincount(bin_indices, minlength=10)
+ valid_bins = bin_counts > 0
+ top_label_ece = float(np.sum(np.abs(prob_true_top - prob_pred_top) * bin_counts[valid_bins]) / len(y))
try:
import lightgbm
@@ -84,8 +95,9 @@ def full_report(model, test_df, le, width: int) -> dict:
output_dict=True, zero_division=0),
"confusion_matrix": confusion_matrix(y, pred).tolist(),
"classes": list(le.classes_),
- "calibration": {
- "ece": round(ece, 4),
+ "test_calibration": {
+ "pooled_ovr_ece": round(ece, 4),
+ "top_label_ece": round(top_label_ece, 4),
"prob_true": prob_true,
"prob_pred": prob_pred
},
@@ -94,7 +106,9 @@ def full_report(model, test_df, le, width: int) -> dict:
"lightgbm": lgb_ver
},
"band_thresholds": {"Ready": 0.60, "Close": 0.30, "Not yet": 0.0},
- "data_release": "data-v3",
+ "data_release": "data-v4",
+ "model_version": "model-v4",
+ "rules_version": "rules-v2",
"seed": 42
}
@@ -119,9 +133,23 @@ def main():
with open(os.path.join(ARTIFACTS_DIR, "label_encoder.pkl"), "rb") as f:
le = pickle.load(f)
width = features.n_features(features.load_vocab())
- _, _, test = split(load_dataset())
+ df, _ = load_dataset()
+ _, _, test = split(df)
r = full_report(clf, test, le, width)
print_report(r)
+
+ metrics_path = os.path.join(ARTIFACTS_DIR, "metrics.json")
+ if os.path.exists(metrics_path):
+ import json
+ with open(metrics_path, "r") as f:
+ metrics = json.load(f)
+ metrics.update(r) # r contains 'test', 'test_short_input', 'test_calibration', etc.
+ with open(metrics_path, "w") as f:
+ json.dump(metrics, f, indent=2)
+ else:
+ import json
+ with open(metrics_path, "w") as f:
+ json.dump(r, f, indent=2)
if __name__ == "__main__":
diff --git a/ml/train.py b/ml/train.py
index b6e2a6a..4b03165 100644
--- a/ml/train.py
+++ b/ml/train.py
@@ -114,6 +114,14 @@ def main():
report = evaluate.full_report(clf, test, le, width)
report["model"] = best
report["val"] = results
+
+ # Compute test scores for both models
+ X_test = features.to_matrix(test["skill_ids"], width)
+ y_test = le.transform(test["role_family"])
+ report["test_scores_both_models"] = {}
+ for name, m_obj in fitted.items():
+ report["test_scores_both_models"][name] = evaluate.score(m_obj, X_test, y_test)
+
report["n_train_raw"], report["n_train_aug"] = len(train), int(X_tr.shape[0])
report["n_dropped_no_skills"] = dropped_rows
report["n_val"], report["n_test"] = len(val), len(test)
@@ -127,14 +135,6 @@ def main():
with open(os.path.join(ARTIFACTS_DIR, "role_profiles.json"), "w") as f:
json.dump(build_role_profiles(train, vocab), f, indent=2)
metrics_path = os.path.join(ARTIFACTS_DIR, "metrics.json")
- if os.path.exists(metrics_path):
- try:
- with open(metrics_path, "r") as f:
- saved = json.load(f)
- saved.update(report)
- report = saved
- except (json.JSONDecodeError, OSError) as e:
- print(f"[warn] Could not load existing metrics.json: {e}")
with open(metrics_path, "w") as f:
json.dump(report, f, indent=2)
diff --git a/scripts/check_norm.py b/scripts/check_norm.py
new file mode 100644
index 0000000..125061b
--- /dev/null
+++ b/scripts/check_norm.py
@@ -0,0 +1,68 @@
+import time
+from collections import Counter
+from pathlib import Path
+
+import pandas as pd
+
+from etl.normalize import (
+ _aliases,
+ _clean_map,
+ _clean_token,
+ load_vocab,
+ normalize_skill,
+)
+
+
+def main() -> None:
+ t0 = time.time()
+ data_path = Path(__file__).resolve().parents[1] / "data" / "clean.parquet"
+
+ if not data_path.exists():
+ raise FileNotFoundError(
+ f"{data_path} is missing. Run the ETL pipeline or download the data artifact."
+ )
+
+ raw = pd.read_parquet(data_path)
+ all_tokens = []
+
+ for skills in raw["tagsAndSkills"].dropna():
+ all_tokens.extend(
+ token.strip().lower()
+ for token in skills.split(",")
+ if token.strip()
+ )
+
+ token_counts = Counter(all_tokens)
+ print(
+ f"Total tokens: {len(all_tokens)}, "
+ f"Unique tokens: {len(token_counts)}, "
+ f"Time so far: {time.time() - t0:.2f}s"
+ )
+
+ load_vocab()
+ mapped_mass = 0
+ fuzzy_count = 0
+
+ for index, (token, count) in enumerate(token_counts.items()):
+ cleaned = _clean_token(token)
+ if not cleaned:
+ continue
+
+ if cleaned in _clean_map or cleaned in _aliases:
+ mapped_mass += count
+ elif normalize_skill(token) is not None:
+ fuzzy_count += count
+ mapped_mass += count
+
+ if index % 5000 == 0:
+ print(f"Processed {index} items...")
+
+ print(
+ f"Mapped mass: {mapped_mass}, "
+ f"fuzzy: {fuzzy_count}, "
+ f"Total time: {time.time() - t0:.2f}s"
+ )
+
+
+if __name__ == "__main__":
+ main()
diff --git a/scripts/collect_stats.py b/scripts/collect_stats.py
new file mode 100644
index 0000000..8f7790c
--- /dev/null
+++ b/scripts/collect_stats.py
@@ -0,0 +1,497 @@
+import json
+import os
+import subprocess
+from pathlib import Path
+
+import matplotlib.pyplot as plt
+import numpy as np
+import pandas as pd
+import seaborn as sns
+
+stats = {
+ "dataset": {},
+ "normalization": {},
+ "model": {},
+ "mining": {},
+ "product": {},
+ "engineering": {}
+}
+
+def safe_run(cmd):
+ try:
+ return subprocess.check_output(cmd, shell=True, text=True, stderr=subprocess.DEVNULL).strip()
+ except Exception: # noqa: BLE001
+ return None
+
+def _fuzzy_match(t, cleaned, count, choices):
+ from rapidfuzz import fuzz, process
+ match = process.extractOne(cleaned, choices, scorer=fuzz.ratio, score_cutoff=88)
+ return (t, count, match is not None)
+
+def dataset_stats():
+ clean_stats = json.loads(Path('data/stats/clean.json').read_text())
+ label_stats = json.loads(Path('data/stats/label.json').read_text())
+ train_stats = json.loads(Path('data/stats/train.json').read_text())
+
+ stats['dataset']['raw rows'] = {"value": clean_stats['rows_in'], "source": "data/stats/clean.json"}
+ stats['dataset']['rows surviving clean'] = {"value": clean_stats['rows_out'], "source": "data/stats/clean.json"}
+
+ for k, v in clean_stats['drops_by_reason'].items():
+ stats['dataset'][f"dropped (clean): {k}"] = {"value": v, "source": "data/stats/clean.json"}
+
+ stats['dataset']['labelled rows'] = {"value": label_stats['rows_out'], "source": "data/stats/label.json"}
+ for k, v in label_stats['drops_by_reason'].items():
+ stats['dataset'][f"dropped (label): {k}"] = {"value": v, "source": "data/stats/label.json"}
+
+ df = pd.read_parquet('data/dataset.parquet')
+ role_counts = df['role_family'].value_counts()
+ for role, count in role_counts.items():
+ stats['dataset'][f"rows per role: {role}"] = {"value": int(count), "source": "data/dataset.parquet"}
+
+ stats['dataset']['rows with no skill ids'] = {"value": train_stats['drops_by_reason'].get('No skill IDs', 0), "source": "data/stats/train.json"}
+
+ raw = pd.read_parquet('data/raw.parquet')
+ skills_series = raw['tagsAndSkills'].dropna()
+ unique_skills = set()
+ for s in skills_series:
+ unique_skills.update([t.strip().lower() for t in s.split(',') if t.strip()])
+ stats['dataset']['unique raw skill strings'] = {"value": len(unique_skills), "source": "data/raw.parquet"}
+
+ baskets = pd.read_parquet('data/baskets.parquet')
+ stats['dataset']['baskets'] = {"value": len(baskets), "source": "data/baskets.parquet"}
+ if 'jobUploaded' in raw.columns:
+ _samples = raw['jobUploaded'].dropna().head(10).tolist()
+ stats['dataset']['posting dates'] = {"value": "no usable dates (relative strings like '6 Days Ago')", "source": "data/raw.parquet"}
+
+ # Figure 1: funnel.png
+ plt.figure(figsize=(8, 6), dpi=150)
+ stages = ['Raw', 'Tech Subset', 'Clean', 'Labelled', 'Baskets']
+ # 59658 dropped in tech subset implies raw - 59658
+ tech_subset = clean_stats['rows_in'] - clean_stats['drops_by_reason'].get('Not in tech subset', 0)
+ counts = [clean_stats['rows_in'], tech_subset, clean_stats['rows_out'], label_stats['rows_out'], len(baskets)]
+ sns.barplot(x=stages, y=counts, color='steelblue')
+ plt.title("Data Pipeline Funnel")
+ plt.ylabel("Rows")
+ for i, v in enumerate(counts):
+ plt.text(i, v + 1000, f"{v:,}", ha='center')
+ plt.tight_layout()
+ plt.savefig('docs/figures/funnel.png')
+ plt.close()
+
+ # Figure 2: class_distribution.png
+ plt.figure(figsize=(10, 6), dpi=150)
+ sns.barplot(x=role_counts.values, y=role_counts.index, color='steelblue')
+ plt.title("Rows per Role Family")
+ plt.xlabel("Count")
+ plt.ylabel("Role Family")
+ plt.tight_layout()
+ plt.savefig('docs/figures/class_distribution.png')
+ plt.close()
+
+def normalization_stats():
+ print("Starting normalization_stats...")
+ vocab = json.loads(Path('artifacts/skill_vocab.json').read_text())
+ stats['normalization']['vocab size'] = {"value": len(vocab), "source": "artifacts/skill_vocab.json"}
+
+ aliases = pd.read_csv('taxonomy/skill_aliases.csv', names=['merge_from', 'keep'])
+ stats['normalization']['alias count'] = {"value": len(aliases), "source": "taxonomy/skill_aliases.csv"}
+
+
+ from etl.normalize import _aliases, _clean_map, _clean_token, _vocab, load_vocab
+ load_vocab()
+ _choices = [c for c in _vocab if len(c) >= 4]
+
+ raw = pd.read_parquet('data/clean.parquet')
+ all_tokens = []
+ for s in raw['tagsAndSkills'].dropna():
+ all_tokens.extend([t.strip().lower() for t in s.split(',') if t.strip()])
+
+ from collections import Counter
+ token_counts = Counter(all_tokens)
+
+ total = sum(token_counts.values())
+ exact_count = 0
+ alias_count = 0
+ fuzzy_count = 0
+ unmapped = []
+
+ # We can get mapped mass directly from label pipeline output, but let's approximate
+ for t, count in token_counts.items():
+ cleaned = _clean_token(t)
+ if not cleaned:
+ unmapped.extend([t] * count)
+ elif cleaned in _clean_map:
+ exact_count += count
+ elif cleaned in _aliases:
+ alias_count += count
+ else:
+ unmapped.extend([t] * count)
+
+ # From pipeline logs: Mapped mass is 77917 out of 100912
+ # So fuzzy_count = 77917 - exact_count - alias_count
+ # Wait, the pipeline only keeps counts for tokens in _vocab (which is top 800)
+ # Our unmapped list is technically those that didn't match exactly or alias.
+ # Actually, we can just use normalize_skill WITHOUT multiprocessing, but with the built-in fuzzy_cache!
+ # Let's just use normalize_skill!
+ from etl.normalize import normalize_skill
+ unmapped = []
+ mapped_mass = 0
+ fuzzy_count = 0
+ import etl.normalize
+ for t, count in token_counts.items():
+ cleaned = _clean_token(t)
+ if not cleaned:
+ unmapped.extend([t] * count)
+ continue
+ if cleaned in etl.normalize._clean_map:
+ exact_count += count
+ mapped_mass += count
+ elif cleaned in etl.normalize._aliases:
+ alias_count += count
+ mapped_mass += count
+ else:
+ if normalize_skill(t) is not None:
+ fuzzy_count += count
+ mapped_mass += count
+ else:
+ unmapped.extend([t] * count)
+
+ stats['normalization']['mapped mass'] = {"value": f"{mapped_mass} / {total} ({mapped_mass/total*100:.1f}%) (Note: 69.9% over all clean rows vs 77.2% over tech subset)", "source": "computed from data/clean.parquet"}
+ stats['normalization']['exact match count'] = {"value": exact_count, "source": "computed"}
+ stats['normalization']['alias match count'] = {"value": alias_count, "source": "computed"}
+ stats['normalization']['fuzzy match count'] = {"value": fuzzy_count, "source": "computed"}
+
+ top_unmapped = pd.Series(unmapped).value_counts().head(20).to_dict()
+ stats['normalization']['top 20 unmapped strings'] = {"value": str(top_unmapped), "source": "computed"}
+
+ unmapped_set = set(unmapped)
+ freq = pd.Series([t for t in all_tokens if t not in unmapped_set]).value_counts().values
+ cum_share = np.cumsum(freq) / total
+ plt.figure(figsize=(8, 6), dpi=150)
+ plt.plot(np.arange(1, len(cum_share) + 1), cum_share, color='steelblue')
+ plt.title("Token Coverage Curve")
+ plt.xlabel("Top-k Skills")
+ plt.ylabel("Share of Total Mentions")
+ plt.tight_layout()
+ plt.savefig('docs/figures/token_coverage_curve.png')
+ plt.close()
+
+
+def model_stats():
+ print("Starting model_stats...")
+ m = json.loads(Path('artifacts/metrics.json').read_text())
+
+ stats['model']['n_train raw'] = {"value": m['n_train_raw'], "source": "artifacts/metrics.json"}
+ stats['model']['n_train augmented'] = {"value": m['n_train_aug'], "source": "artifacts/metrics.json"}
+ stats['model']['n_val'] = {"value": m['n_val'], "source": "artifacts/metrics.json"}
+ stats['model']['n_test'] = {"value": m['n_test'], "source": "artifacts/metrics.json"}
+ stats['model']['majority baseline'] = {"value": m['majority_baseline_acc'], "source": "artifacts/metrics.json"}
+ stats['model']['test macro F1'] = {"value": m['test']['macro_f1'], "source": "artifacts/metrics.json"}
+ stats['model']['test accuracy'] = {"value": m['test']['accuracy'], "source": "artifacts/metrics.json"}
+ stats['model']['test top-3'] = {"value": m['test']['top3_accuracy'], "source": "artifacts/metrics.json"}
+ stats['model']['short-input test macro F1'] = {"value": m['test_short_input']['macro_f1'], "source": "artifacts/metrics.json"}
+
+ for cls in m['classes']:
+ stats['model'][f"per-class {cls} F1"] = {"value": round(m['per_class'][cls]['f1-score'], 4), "source": "artifacts/metrics.json"}
+
+ stats['model']['ECE pooled'] = {"value": round(m['test_calibration'].get('pooled_ovr_ece', m['test_calibration'].get('ece')), 4), "source": "artifacts/metrics.json"}
+ stats['model']['ECE top-label'] = {"value": round(m['test_calibration'].get('top_label_ece', 0.0), 4) if 'top_label_ece' in m['test_calibration'] else "N/A", "source": "artifacts/metrics.json"}
+
+ # confusion_matrix.png (row-normalised)
+ cm = np.array(m['confusion_matrix'])
+ cm_norm = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
+ plt.figure(figsize=(10, 8), dpi=150)
+ sns.heatmap(cm_norm, annot=True, fmt=".2f", cmap='Blues', xticklabels=m['classes'], yticklabels=m['classes'])
+ plt.title("Confusion Matrix (Row-Normalized)")
+ plt.xlabel("Predicted")
+ plt.ylabel("True")
+ plt.tight_layout()
+ plt.savefig('docs/figures/confusion_matrix.png')
+ plt.close()
+
+ # per_class_f1.png
+ f1s = [m['per_class'][c]['f1-score'] for c in m['classes']]
+ plt.figure(figsize=(10, 6), dpi=150)
+ sns.barplot(x=f1s, y=m['classes'], color='steelblue')
+ plt.title("Per-Class F1 Score")
+ plt.xlabel("F1 Score")
+ plt.tight_layout()
+ plt.savefig('docs/figures/per_class_f1.png')
+ plt.close()
+
+ # full_vs_short.png
+ plt.figure(figsize=(6, 6), dpi=150)
+ labels = ['Full Input', 'Short Input']
+ scores = [m['test']['macro_f1'], m['test_short_input']['macro_f1']]
+ sns.barplot(x=labels, y=scores, color='steelblue')
+ plt.title("Macro F1: Full vs Short Input")
+ plt.ylabel("Macro F1")
+ plt.tight_layout()
+ plt.savefig('docs/figures/full_vs_short.png')
+ plt.close()
+
+ # logreg_vs_lgbm.png
+ # Wait, some metrics don't have test_scores_both_models if LGBM wasn't run or something?
+ # The prompt says: "LR vs LightGBM on val and test"
+ # m['val']['logreg'], m['val']['lightgbm']
+ lr_val = m.get('val', {}).get('logreg', {}).get('macro_f1', 0)
+ lgbm_val = m.get('val', {}).get('lightgbm', {}).get('macro_f1', 0)
+ stats['model']['LR val macro F1'] = {"value": lr_val, "source": "artifacts/metrics.json"}
+ stats['model']['LGBM val macro F1'] = {"value": lgbm_val, "source": "artifacts/metrics.json"}
+
+ lr_test = m.get('test_scores_both_models', {}).get('logreg', {}).get('macro_f1', 0)
+ lgbm_test = m.get('test_scores_both_models', {}).get('lightgbm', {}).get('macro_f1', 0)
+ stats['model']['LR test macro F1'] = {"value": lr_test, "source": "artifacts/metrics.json"}
+ stats['model']['LGBM test macro F1'] = {"value": lgbm_test, "source": "artifacts/metrics.json"}
+
+ if lr_test and lgbm_test:
+ plt.figure(figsize=(8, 6), dpi=150)
+ df_plot = pd.DataFrame({
+ 'Model': ['LogReg', 'LogReg', 'LightGBM', 'LightGBM'],
+ 'Split': ['Val', 'Test', 'Val', 'Test'],
+ 'Macro F1': [lr_val, lr_test, lgbm_val, lgbm_test]
+ })
+ sns.barplot(data=df_plot, x='Split', y='Macro F1', hue='Model')
+ plt.title("LogReg vs LightGBM")
+ plt.tight_layout()
+ plt.savefig('docs/figures/logreg_vs_lgbm.png')
+ plt.close()
+
+ # calibration.png
+ calib = m.get('calibration', {})
+ if 'prob_pred' in calib and 'prob_true' in calib:
+ plt.figure(figsize=(6, 6), dpi=150)
+ plt.plot(calib['prob_pred'], calib['prob_true'], marker='o', label='Model')
+ plt.plot([0, 1], [0, 1], linestyle='--', label='Perfect Calibration')
+ plt.title("Reliability Diagram")
+ plt.xlabel("Mean Predicted Probability")
+ plt.ylabel("Fraction of Positives")
+ plt.legend()
+ plt.tight_layout()
+ plt.savefig('docs/figures/calibration.png')
+ plt.close()
+
+ # band_split.png
+ band_split = m.get('test_band_split', {})
+ if band_split:
+ df_band = pd.DataFrame(band_split).T
+ df_band.plot(kind='bar', stacked=True, figsize=(12, 6))
+ plt.title("Band Split per True Role (Test Set)")
+ plt.xlabel("Role")
+ plt.ylabel("Count")
+ plt.tight_layout()
+ plt.savefig('docs/figures/band_split.png')
+ plt.close()
+def mining_stats():
+ print("Starting mining_stats...")
+ rules = pd.read_parquet('artifacts/rules.parquet')
+ stats['mining']['rule count'] = {"value": len(rules), "source": "artifacts/rules.parquet"}
+
+ # Actually wait, are min_support etc. inside artifacts/rules.parquet?
+ # Usually they are arguments or metadata. Let's see if we can extract them from rules.json or just put them manually if they are in the script.
+ # The prompt says: "min_support, min_confidence, min_lift"
+ # make all logs have it: "Mining frequent itemsets with min_sup=0.50%", "Generating rules with min_confidence=0.3, min_lift=1.2"
+ stats['mining']['min_support'] = {"value": 0.005, "source": "mining logs"}
+ stats['mining']['min_confidence'] = {"value": 0.3, "source": "mining logs"}
+ stats['mining']['min_lift'] = {"value": 1.2, "source": "mining logs"}
+
+ # "the benchmark from docs/bench.json"
+ if os.path.exists('docs/bench.json'):
+ bench_list = json.loads(Path('docs/bench.json').read_text())
+ bench = bench_list[-1]
+ stats['mining']['bench support'] = {"value": bench.get('support'), "source": "docs/bench.json"}
+ stats['mining']['bench itemsets'] = {"value": bench.get('itemsets'), "source": "docs/bench.json"}
+ stats['mining']['bench Apriori s'] = {"value": bench.get('apriori_time_sec'), "source": "docs/bench.json"}
+ stats['mining']['bench FP-growth s'] = {"value": bench.get('fpgrowth_time_sec'), "source": "docs/bench.json"}
+ stats['mining']['bench speedup'] = {"value": bench.get('speedup'), "source": "docs/bench.json"}
+ stats['mining']['bench identical'] = {"value": bench.get('identical'), "source": "docs/bench.json"}
+
+ # apriori_vs_fpgrowth.png
+ supports = [b.get('support') for b in bench_list]
+ apriori = [b.get('apriori_time_sec') for b in bench_list]
+ fp = [b.get('fpgrowth_time_sec') for b in bench_list]
+ if supports:
+ plt.figure(figsize=(8, 6), dpi=150)
+ plt.plot(supports, apriori, label='Apriori', marker='o')
+ plt.plot(supports, fp, label='FP-Growth', marker='o')
+ plt.yscale('log')
+ plt.gca().invert_xaxis()
+ plt.title("Execution Time: Apriori vs FP-Growth")
+ plt.xlabel("Min Support")
+ plt.ylabel("Time (s) [Log Scale]")
+ plt.legend()
+ plt.tight_layout()
+ plt.savefig('docs/figures/apriori_vs_fpgrowth.png')
+ plt.close()
+
+ # "itemsets per level with pruned counts"
+ from mining.apriori import run_apriori
+ baskets_list = pd.read_parquet('data/baskets.parquet')['skill_ids'].tolist()
+ # To save time, we will run it on 0.01 (1%) instead of 0.005 (0.5%), or just 0.005. 0.01 takes 8s, 0.005 takes 43s. The prompt doesn't specify which support. Let's use 0.01 for speed.
+ _, level_stats = run_apriori(baskets_list, 0.01, verbose=False)
+
+ levels_str = []
+ for k, v in level_stats.items():
+ levels_str.append(f"L{k}: {v['survivors']} (pruned {v['candidates_pruned']})")
+ stats['mining']['itemsets per level'] = {"value": "\n".join(levels_str), "source": "run_apriori at 1%"}
+
+ levels = list(level_stats.keys())
+ sizes = [level_stats[l]['survivors'] for l in levels]
+ cands = [level_stats[l]['candidates_generated'] for l in levels]
+ plt.figure(figsize=(8, 6), dpi=150)
+ plt.plot(levels, cands, label='Candidates', marker='o')
+ plt.plot(levels, sizes, label='Frequent', marker='o')
+ plt.title("Itemsets per Level")
+ plt.xlabel("Itemset Size (Level)")
+ plt.ylabel("Count")
+ plt.legend()
+ plt.tight_layout()
+ plt.savefig('docs/figures/apriori_levels.png')
+ plt.close()
+
+ vocab = json.loads(Path('artifacts/skill_vocab.json').read_text())
+ def _fmt_rule(r):
+ ant = ", ".join([vocab[int(i)] for i in r['antecedent']])
+ con = ", ".join([vocab[int(i)] for i in r['consequent']])
+ return f"{ant} -> {con} (lift={r['lift']:.3f}, conf={r['confidence']:.3f}, sup={r['support']:.3f})"
+
+ top10 = rules.sort_values('lift', ascending=False).head(10)
+ top10_str = []
+ for _, r in top10.iterrows():
+ top10_str.append(_fmt_rule(r))
+ stats['mining']['top 10 rules by lift'] = {"value": "\n".join(top10_str), "source": "artifacts/rules.parquet"}
+
+ # Top tech skills (excluding HR terms)
+ exclude_terms = {'screening', 'joining formalities', 'hr generalist activities', 'hr', 'recruitment', 'sourcing', 'talent acquisition'}
+ top_tech_str = []
+ for _, r in rules.sort_values('lift', ascending=False).iterrows():
+ ant_terms = {vocab[int(i)] for i in r['antecedent']}
+ con_terms = {vocab[int(i)] for i in r['consequent']}
+ all_terms = ant_terms | con_terms
+ if not all_terms.intersection(exclude_terms):
+ top_tech_str.append(_fmt_rule(r))
+ if len(top_tech_str) == 10:
+ break
+ stats['mining']['top 10 rules by lift among tech skills'] = {"value": "\n".join(top_tech_str), "source": "artifacts/rules.parquet"}
+
+ close_to_1 = rules[(rules['lift'] >= 1.0) & (rules['lift'] <= 1.05)].head(1)
+ if not close_to_1.empty:
+ r = close_to_1.iloc[0]
+ stats['mining']['rule with lift ~ 1'] = {"value": _fmt_rule(r), "source": "artifacts/rules.parquet"}
+
+ # top_rules.png
+ plt.figure(figsize=(8, 6), dpi=150)
+ plt.scatter(rules['support'], rules['confidence'], c=rules['lift'], cmap='viridis', alpha=0.7)
+ plt.colorbar(label='Lift')
+ plt.title("Association Rules: Support vs Confidence")
+ plt.xlabel("Support")
+ plt.ylabel("Confidence")
+ plt.tight_layout()
+ plt.savefig('docs/figures/top_rules.png')
+ plt.close()
+
+
+def product_stats():
+ print("Starting product_stats...")
+ try:
+ from api.main import analyze
+ from api.schemas import AnalyzeRequest
+
+ personas = json.loads(Path('tests/data/personas.json').read_text())
+ results = []
+ for p in personas:
+ req = AnalyzeRequest(skills=p["skills"], desired_role=p["role"])
+ resp = analyze(req)
+ data = resp.model_dump()
+
+ readiness = data.get("readiness", {})
+ match = data.get("match", {}).get("matches", [{}])[0].get("role", "None")
+ gaps = data.get("gap", {}).get("recommendations", [])[:5]
+ gap_names = [g["skill"] for g in gaps]
+ results.append(f"{p['name']} ({p['role']}): readiness {readiness.get('probability', 0):.2f}, band {readiness.get('band')}, top match {match}, gaps {gap_names}")
+
+ stats['product']['personas'] = {"value": "\n".join(results), "source": "in-process analyze_skills"}
+ except Exception as e: # noqa: BLE001
+ stats['product']['personas'] = {"value": None, "reason": str(e), "source": "in-process analyze_skills"}
+
+
+def engineering_stats():
+ print("Starting engineering_stats...")
+ # run pytest
+ pytest_out = safe_run("PYTHONPATH=. .venv/bin/python -m pytest tests/ | grep -o '[0-9]* passed' | cut -d' ' -f1")
+ stats['engineering']['test pass count'] = {"value": int(pytest_out) if pytest_out.isdigit() else pytest_out, "source": "pytest tests/"}
+
+ # loc
+ tracked_files = safe_run("git ls-files").split('\n')
+ loc_by_dir = {}
+ for f in tracked_files:
+ if not f or f.startswith(('artifacts/', 'docs/')):
+ continue
+ d = f.split('/')[0] if '/' in f else 'root'
+ try:
+ loc = sum(1 for line in Path(f).read_text().splitlines())
+ loc_by_dir[d] = loc_by_dir.get(d, 0) + loc
+ except Exception: # noqa: BLE001, S110
+ pass
+ loc_str = "\n".join(f"{d}: {c}" for d, c in sorted(loc_by_dir.items()))
+ stats['engineering']['lines of code'] = {"value": "\n" + loc_str, "source": "git ls-files per dir"}
+
+ safe_run("python3.12 -m venv /tmp/slim && /tmp/slim/bin/pip install -r requirements.txt")
+ stats['engineering']['slim runtime install size'] = {"value": safe_run("du -sh /tmp/slim | cut -f1"), "source": "fresh venv from requirements.txt"}
+ stats['engineering']['frontend dist size'] = {"value": safe_run("du -sh frontend/dist | cut -f1"), "source": "du -sh frontend/dist"}
+ stats['engineering']['Vercel function size'] = {"value": "39.1 MB", "source": "docs/deploy.md"}
+
+ import re
+ deploy_md = Path("docs/deploy.md").read_text()
+ cold = re.search(r'Cold start.*?:\s*([\d.]+)\s*ms', deploy_md)
+ p50 = re.search(r'p50:\s*([\d.]+)\s*ms', deploy_md)
+ p95 = re.search(r'p95:\s*([\d.]+)\s*ms', deploy_md)
+ stats['engineering']['production latency (cold start ms)'] = {"value": float(cold.group(1)) if cold else None, "source": "docs/deploy.md"}
+ stats['engineering']['production latency (p50 ms)'] = {"value": float(p50.group(1)) if p50 else None, "source": "docs/deploy.md"}
+ stats['engineering']['production latency (p95 ms)'] = {"value": float(p95.group(1)) if p95 else None, "source": "docs/deploy.md"}
+
+ prs = safe_run("gh pr list --state merged --limit 200 --json author --jq '.[].author.login' | sort | uniq -c")
+ stats['engineering']['commits and merged PRs'] = {"value": "\n" + str(prs), "source": "gh pr list"}
+
+ releases = safe_run("gh release list")
+ stats['engineering']['releases'] = {"value": "\n" + str(releases), "source": "gh release list"}
+
+
+if __name__ == '__main__':
+ dataset_stats()
+ normalization_stats()
+ model_stats()
+ mining_stats()
+ product_stats()
+ engineering_stats()
+
+ # cross checks
+ m = json.loads(Path('artifacts/metrics.json').read_text())
+ rules = pd.read_parquet('artifacts/rules.parquet')
+ df = pd.read_parquet('data/dataset.parquet')
+
+ assert sum([v['value'] for k,v in stats['dataset'].items() if 'rows per role:' in k]) == stats['dataset']['labelled rows']['value'], "Role counts sum mismatch"
+ assert stats['model']['test macro F1']['value'] == m['test']['macro_f1'], "F1 mismatch"
+ assert stats['mining']['rule count']['value'] == len(rules), "Rule count mismatch"
+ support_sum = sum([m['per_class'][c]['support'] for c in m['classes']])
+ assert support_sum == m['n_test'], "Support sum mismatch"
+ assert stats['model']['ECE pooled']['value'] == round(m['test_calibration']['pooled_ovr_ece'], 4), "ECE mismatch"
+ assert stats['model']['LR test macro F1']['value'] == m['test_scores_both_models']['logreg']['macro_f1'], "LR F1 mismatch"
+ assert stats['model']['LGBM test macro F1']['value'] == m['test_scores_both_models']['lightgbm']['macro_f1'], "LGBM F1 mismatch"
+
+ with open('docs/stats.json', 'w') as f:
+ json.dump(stats, f, indent=2)
+
+ # generate markdown
+ md = "# Project Statistics\n\n"
+ for section, keys in stats.items():
+ md += f"## {section.title()}\n"
+ md += "| Metric | Value | Source |\n"
+ md += "|---|---|---|\n"
+ for k, v in keys.items():
+ val = str(v.get('value', v.get('reason', 'N/A'))).replace('\n', '
')
+ md += f"| {k} | {val} | {v.get('source', '')} |\n"
+ md += "\n"
+
+ with open('docs/stats.md', 'w') as f:
+ f.write(md)