sadiqM commited on
Commit
382741d
·
1 Parent(s): 11e8ba2

Train model at Docker build time; stop committing binaries

Browse files

Hugging Face requires git-LFS for binary artifacts. Instead, generate the
model during the image build (deterministic: pinned deps + fixed seed) and
keep models/ out of git.

Files changed (3) hide show
  1. .gitignore +5 -3
  2. Dockerfile +4 -0
  3. models/metrics.json +0 -51
.gitignore CHANGED
@@ -17,6 +17,8 @@ Thumbs.db
17
  .vscode/
18
  .idea/
19
 
20
- # NOTE: models/ckd_pipeline.joblib and models/metrics.json are intentionally
21
- # committed so the app deploys without a training step. Regenerate with:
22
- # python -m nephroscreen.train
 
 
 
17
  .vscode/
18
  .idea/
19
 
20
+ # Trained artifacts are generated at Docker build time (see Dockerfile), and
21
+ # locally with `python -m nephroscreen.train` — not committed (Hugging Face
22
+ # requires git-LFS for binaries, and build-time training keeps the repo clean).
23
+ models/*.joblib
24
+ models/*.json
Dockerfile CHANGED
@@ -10,6 +10,10 @@ RUN pip install --no-cache-dir -r requirements.txt
10
  COPY . .
11
  RUN pip install --no-cache-dir -e .
12
 
 
 
 
 
13
  EXPOSE 8000
14
  # Render/Cloud Run set $PORT; default to 8000 locally.
15
  CMD ["sh", "-c", "uvicorn api.main:app --host 0.0.0.0 --port ${PORT:-8000}"]
 
10
  COPY . .
11
  RUN pip install --no-cache-dir -e .
12
 
13
+ # Train the model at build time (fast + deterministic: pinned deps, fixed seed).
14
+ # Keeps binaries out of git and guarantees the served model matches the code.
15
+ RUN python -m nephroscreen.train
16
+
17
  EXPOSE 8000
18
  # Render/Cloud Run set $PORT; default to 8000 locally.
19
  CMD ["sh", "-c", "uvicorn api.main:app --host 0.0.0.0 --port ${PORT:-8000}"]
models/metrics.json DELETED
@@ -1,51 +0,0 @@
1
- {
2
- "model": "RandomForestClassifier(n_estimators=100)",
3
- "trained_at": "2026-07-03T10:37:56.937655+00:00",
4
- "random_state": 42,
5
- "test_size": 0.2,
6
- "n_train": 320,
7
- "n_test": 80,
8
- "serving_threshold": 0.62,
9
- "metrics": {
10
- "Logistic Regression": {
11
- "accuracy": 98.75,
12
- "precision": 100.0,
13
- "recall": 98.0,
14
- "f1": 98.99,
15
- "roc_auc": 1.0,
16
- "cv_mean": 99.38,
17
- "cv_std": 1.25
18
- },
19
- "Random Forest": {
20
- "accuracy": 100.0,
21
- "precision": 100.0,
22
- "recall": 100.0,
23
- "f1": 100.0,
24
- "roc_auc": 1.0,
25
- "cv_mean": 98.75,
26
- "cv_std": 2.86
27
- },
28
- "Decision Tree": {
29
- "accuracy": 97.5,
30
- "precision": 98.0,
31
- "recall": 98.0,
32
- "f1": 98.0,
33
- "roc_auc": 0.9893,
34
- "cv_mean": 96.56,
35
- "cv_std": 2.19
36
- }
37
- },
38
- "top_features": {
39
- "hemo": 0.1771,
40
- "pcv": 0.1626,
41
- "sc": 0.1132,
42
- "kidney_stress_index": 0.1012,
43
- "rbcc": 0.0995,
44
- "sg": 0.0828,
45
- "htn": 0.0469,
46
- "al": 0.0412,
47
- "dm": 0.0309,
48
- "bu": 0.0306
49
- },
50
- "note": "Near-perfect scores reflect the high separability of this small UCI dataset (400 patients, 80-patient test set) \u2014 not clinical deployment readiness. See README for the honest interpretation."
51
- }