Upload README.md with huggingface_hub
Browse files16 unmodified lines17181920212223242526272829303132333435363738394041423 unmodified lines464748495051525354551 unmodified line575859606162637 unmodified lines717273747576777816 unmodified linesRandom Forest that estimates defect risk from 21 NASA/PROMISE code metrics.Part of a three-agent DevSecOps auditor (metrics → transformer → gatekeeper).> For a Hugging Face repo, upload this file as `README.md` alongside> `agent1_rf.joblib` and `agent1_rf.meta.json`.## Files| File | Contents ||---|---|| `agent1_rf.joblib` | `model`, `raw_cols`, `feature_cols`, `threshold` || `agent1_rf.meta.json` | Dataset, seed, threshold, best params |## InputA row of 21 numeric metrics:```loc, vg, evg, ivg, n, v, l, d, i, e, b, t, locode, locomment,loccodeandcomment, loblank, uniq_op, uniq_opnd, total_op, total_opnd, branchcount```Five ratios are derived at inference time (already expected by `feature_cols`):```complexity_density = vg / (loc + 1)3 unmodified linesoperand_reuse = total_opnd / (uniq_opnd + 1)```## Output`predict_proba(X)[:, 1]` — defect risk in `[0, 1]`, uncalibrated.Decision threshold: **0.3183** (tuned on training CV with F2, recall-weighted).## Usage1 unmodified lineimport joblibimport pandas as pdb = joblib.load("agent1_rf.joblib")df = pd.DataFrame([metrics])[b["raw_cols"]].apply(pd.to_numeric)df["complexity_density"] = df["vg"] / (df["loc"] + 1)7 unmodified lineshigh_risk = score >= b["threshold"]```Trained on `data/pc1.csv` (NASA PROMISE). Metrics from other languages ordomains are out-of-distribution.## License16 unmodified lines17181920212223242526272829303132333435363738394041424344454647484950515253545556575859603 unmodified lines6465666768697071727374757677787980811 unmodified line838485868788897 unmodified lines97989910010110210310416 unmodified linesRandom Forest that estimates defect risk from 21 NASA/PROMISE code metrics.Part of a three-agent DevSecOps auditor (metrics → transformer → gatekeeper).## Model details| Field | Value ||---|---|| Version | 1.0.0 (initial release) || Artifact | `model.joblib` (bundle: `model`, `raw_cols`, `feature_cols`, `threshold`) || Task | Binary tabular classification (defect / no defect) || Threshold | **0.3183** (tuned on training CV with F2) || Training data | NASA/PROMISE PC1 (`pc1.csv`) || Dataset version | Not pinned — static PC1 snapshot, no revision hash recorded || Seed | 42 |`metadata.json` mirrors the dataset, threshold, and best params.## Input features21 numeric metrics:```loc, vg, evg, ivg, n, v, l, d, i, e, b, t,locode, locomment, loccodeandcomment, loblank,uniq_op, uniq_opnd, total_op, total_opnd, branchcount```Five derived features are added before prediction. Final `feature_cols` order(26 columns, must match exactly):```loc, vg, evg, ivg, n, v, l, d, i, e, b, t,locode, locomment, loccodeandcomment, loblank,uniq_op, uniq_opnd, total_op, total_opnd, branchcount,complexity_density, effort_per_loc, comment_ratio, branch_density, operand_reuse```## Preprocessing- All 21 inputs must be numeric; no missing values (nothing is imputed).- Derive ratios with `+1` denominators:```complexity_density = vg / (loc + 1)3 unmodified linesoperand_reuse = total_opnd / (uniq_opnd + 1)```- Select `b["feature_cols"]` in the order above.## OutputRaw: `predict_proba(X)[0, 1]` — defect risk in `[0, 1]`, uncalibrated.`high_risk = score >= 0.3183`.Reference wrapper output:```json{"struct_risk_score": 0.5105, "high_risk": true, "threshold": 0.3183, "status": "ok", "reason": ""}```## Usage1 unmodified lineimport joblibimport pandas as pdb = joblib.load("model.joblib")df = pd.DataFrame([metrics])[b["raw_cols"]].apply(pd.to_numeric)df["complexity_density"] = df["vg"] / (df["loc"] + 1)7 unmodified lineshigh_risk = score >= b["threshold"]```Trained on NASA PROMISE PC1. Metrics from other languages or domains areout-of-distribution.## License
README.md+43-17