Delete README.md
Browse files12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879# Agent 1 — Structural Risk (Random Forest)
Predicts defect risk from NASA/PROMISE code metrics. Trained on `data/pc1.csv`.This model is a single artifact, so its README lives beside it as`agent1_rf.README.md`.
## Files
| File | Contents ||---|---|| `agent1_rf.joblib` | Model bundle: `model`, `raw_cols`, `feature_cols`, `threshold` || `agent1_rf.meta.json` | Human-readable copy: dataset, seed, threshold, best params |
Code: `agents/agent1_metrics.py`.
## Input
One dict containing all 21 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```
Keys are normalized (lowercased, stripped, parentheses removed), so `v(g)` and`iv(G)` become `vg` and `ivg`. Values must be numeric. Five derived ratiosare computed internally (`complexity_density`, `effort_per_loc`, `comment_ratio`,`branch_density`, `operand_reuse`) — do not supply them.
Missing keys or non-numeric values return an error; nothing is imputed atinference time.
## Output
Success:```json{ "struct_risk_score": 0.5105, "high_risk": true, "threshold": 0.3183, "status": "ok", "reason": ""}```
Error (note: no `threshold` key):```json{ "struct_risk_score": null, "high_risk": null, "status": "error", "reason": "missing features: ['loc', 'vg']"}```
| Key | Success | Error ||---|---|---|| `struct_risk_score` | float 0–1 | `null` || `high_risk` | `score >= threshold` | `null` || `threshold` | `0.3183` | key absent || `status` | `"ok"` | `"error"` || `reason` | `""` | error detail |
`struct_risk_score` is an uncalibrated model score. `status != "ok"` meansAgent 3 will return `REVIEW`.
## Usage
```bash# Train (needs data/pc1.csv)python agents/agent1_metrics.py train --data data/pc1.csv
# Predictpython -c "from agents.agent1_metrics import predict_struct_risk; \print(predict_struct_risk({'loc': 200, 'vg': 25, ...}))"
# Testpython test_agent1.py```README.mdDeleted-79