ClarusC64 commited on
Commit
8a9f257
·
verified ·
1 Parent(s): c50fb06

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +272 -112
README.md CHANGED
@@ -1,112 +1,272 @@
1
- import csv
2
- import json
3
- import sys
4
- from typing import Dict, List
5
-
6
-
7
- DEFAULT_INPUT_PATH = "data/tester.csv"
8
-
9
-
10
- def _safe_float(value, default: float = 0.0) -> float:
11
- try:
12
- return float(value)
13
- except (TypeError, ValueError):
14
- return default
15
-
16
-
17
- def _read_csv(path: str) -> List[Dict[str, str]]:
18
- with open(path, "r", encoding="utf-8") as f:
19
- return list(csv.DictReader(f))
20
-
21
-
22
- def _detect_id_column(fieldnames: List[str]) -> str:
23
- preferred = ["id", "row_id", "sample_id", "case_id", "record_id"]
24
- for col in preferred:
25
- if col in fieldnames:
26
- return col
27
- return ""
28
-
29
-
30
- def heuristic_score(row: Dict[str, str]) -> float:
31
- oxygen_delivery_score = _safe_float(row.get("oxygen_delivery_score"))
32
- buffer_capacity_index = _safe_float(row.get("buffer_capacity_index"))
33
- latent_coupling_pressure = _safe_float(row.get("latent_coupling_pressure"))
34
- compensation_fatigue_score = _safe_float(row.get("compensation_fatigue_score"))
35
- drift_gradient = _safe_float(row.get("drift_gradient"))
36
- coherence_stability_score = _safe_float(row.get("coherence_stability_score"))
37
- context_integrity_score = _safe_float(row.get("context_integrity_score"))
38
- decision_readiness_score = _safe_float(row.get("decision_readiness_score"))
39
-
40
- score = 0.0
41
- score += max(0.0, 1.0 - oxygen_delivery_score) * 1.1
42
- score += max(0.0, 1.0 - buffer_capacity_index) * 1.2
43
- score += latent_coupling_pressure * 1.3
44
- score += compensation_fatigue_score * 1.1
45
- score += max(0.0, drift_gradient) * 1.4
46
- score += max(0.0, 1.0 - coherence_stability_score) * 1.1
47
- score += max(0.0, 1.0 - context_integrity_score) * 1.0
48
- score += max(0.0, 1.0 - decision_readiness_score) * 1.0
49
-
50
- if score < 0.0:
51
- return 0.0
52
- if score > 1.0:
53
- return 1.0
54
- return round(score, 6)
55
-
56
-
57
- def generate_predictions(
58
- input_path: str = DEFAULT_INPUT_PATH,
59
- output_path: str = "predictions.csv",
60
- threshold: float = 0.5,
61
- ) -> Dict[str, object]:
62
- rows = _read_csv(input_path)
63
- if not rows:
64
- raise ValueError("Input file is empty.")
65
-
66
- fieldnames = list(rows[0].keys())
67
- id_col = _detect_id_column(fieldnames)
68
-
69
- output_rows = []
70
- positive_predictions = 0
71
-
72
- for idx, row in enumerate(rows):
73
- row_id = row[id_col] if id_col else str(idx)
74
- pred_score = heuristic_score(row)
75
- pred_label = 1 if pred_score >= threshold else 0
76
- positive_predictions += pred_label
77
-
78
- output_rows.append(
79
- {
80
- "id": row_id,
81
- "prediction_score": pred_score,
82
- "prediction": pred_label,
83
- }
84
- )
85
-
86
- with open(output_path, "w", encoding="utf-8", newline="") as f:
87
- writer = csv.DictWriter(f, fieldnames=["id", "prediction_score", "prediction"])
88
- writer.writeheader()
89
- writer.writerows(output_rows)
90
-
91
- return {
92
- "input_path": input_path,
93
- "output_path": output_path,
94
- "rows_processed": len(rows),
95
- "threshold_used": threshold,
96
- "predicted_positive_support": positive_predictions,
97
- "predicted_negative_support": len(rows) - positive_predictions,
98
- "note": "This is a dataset-specific baseline heuristic, not the canonical evaluation scorer.",
99
- }
100
-
101
-
102
- if __name__ == "__main__":
103
- input_path = sys.argv[1] if len(sys.argv) > 1 else DEFAULT_INPUT_PATH
104
- output_path = sys.argv[2] if len(sys.argv) > 2 else "predictions.csv"
105
- threshold = float(sys.argv[3]) if len(sys.argv) > 3 else 0.5
106
-
107
- result = generate_predictions(
108
- input_path=input_path,
109
- output_path=output_path,
110
- threshold=threshold,
111
- )
112
- print(json.dumps(result, indent=2))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ language: en
3
+ license: mit
4
+ task_categories:
5
+ - text-classification
6
+ tags:
7
+ - clinical-trials
8
+ - trajectory-aware
9
+ - clarus
10
+ - latent-cross-coupling
11
+ - oxygen
12
+ - buffer
13
+ size_categories:
14
+ - n<1K
15
+ pretty_name: Clinical Latent Cross Coupling Oxygen Buffer Instability v0.2
16
+ ---
17
+
18
+ # Clinical Latent Cross Coupling Oxygen Buffer Instability v0.2
19
+
20
+ ## What this is
21
+
22
+ A small dataset that tests one question:
23
+
24
+ Can you detect when an oxygen-buffer system is moving toward hidden instability, not just carrying visible strain?
25
+
26
+ This repo focuses on latent cross coupling between oxygen delivery and buffer capacity.
27
+
28
+ It models a system where:
29
+
30
+ - oxygen delivery may weaken
31
+ - buffer capacity may erode
32
+ - latent coupling pressure may rise
33
+ - compensation fatigue may accumulate before overt collapse appears
34
+
35
+ ## Run this first
36
+
37
+ Generate baseline predictions:
38
+
39
+ ```bash
40
+ python baseline_heuristic.py data/tester.csv predictions.csv
41
+
42
+ Score them:
43
+
44
+ python scorer.py data/tester.csv predictions.csv
45
+
46
+ That is enough to see the full evaluation loop.
47
+
48
+ You will get:
49
+
50
+ standard metrics
51
+
52
+ trajectory detection performance
53
+
54
+ oxygen-buffer instability detection errors
55
+
56
+ What to try next
57
+
58
+ Replace the baseline.
59
+
60
+ Build your own model.
61
+
62
+ Output a file like:
63
+
64
+ id,prediction_score
65
+ 0,0.12
66
+ 1,0.81
67
+ 2,0.67
68
+
69
+ Then run:
70
+
71
+ python scorer.py data/tester.csv your_predictions.csv
72
+ What matters
73
+
74
+ Not just accuracy.
75
+
76
+ The key signals are:
77
+
78
+ recall_trajectory_deterioration_detection
79
+
80
+ false_stable_trajectory_rate
81
+
82
+ These tell you:
83
+
84
+ are you catching systems that are getting worse
85
+
86
+ are you missing hidden oxygen-buffer collapse
87
+
88
+ Data
89
+
90
+ Each row represents a latent oxygen-buffer coupling state.
91
+
92
+ Core variables:
93
+
94
+ oxygen_delivery_score
95
+
96
+ buffer_capacity_index
97
+
98
+ latent_coupling_pressure
99
+
100
+ compensation_fatigue_score
101
+
102
+ drift_gradient
103
+
104
+ coherence_stability_score
105
+
106
+ context_integrity_score
107
+
108
+ decision_readiness_score
109
+
110
+ Target:
111
+
112
+ label_oxygen_buffer_instability
113
+
114
+ Important distinction
115
+
116
+ There are two different components in this repo.
117
+
118
+ scorer.py
119
+
120
+ evaluates predictions
121
+
122
+ domain-agnostic
123
+
124
+ works across all v0.2 datasets
125
+
126
+ does not generate predictions
127
+
128
+ baseline_heuristic.py
129
+
130
+ generates predictions
131
+
132
+ domain-specific
133
+
134
+ uses the variables in this dataset
135
+
136
+ Do not reuse the heuristic across datasets.
137
+
138
+ It is only a local reference.
139
+
140
+ What changed from v0.1
141
+
142
+ v0.1:
143
+
144
+ static latent coupling classification
145
+
146
+ v0.2:
147
+
148
+ adds direction via drift_gradient
149
+
150
+ This allows you to separate:
151
+
152
+ strained but stabilizing coupling states
153
+
154
+ strained and deteriorating coupling states
155
+
156
+ Why this exists
157
+
158
+ Most models answer:
159
+
160
+ what is happening now
161
+
162
+ This tests:
163
+
164
+ where the hidden interaction is going
165
+
166
+ That difference is where failure appears early.
167
+
168
+ Files
169
+
170
+ data/train.csv — training data
171
+
172
+ data/tester.csv — evaluation data
173
+
174
+ scorer.py — canonical evaluation script
175
+
176
+ baseline_heuristic.py — dataset-specific reference model
177
+
178
+ README.md — dataset card
179
+
180
+ Evaluation
181
+
182
+ Primary metric:
183
+
184
+ recall_trajectory_deterioration_detection
185
+
186
+ Secondary metric:
187
+
188
+ false_stable_trajectory_rate
189
+
190
+ Standard metrics are also reported:
191
+
192
+ accuracy
193
+
194
+ precision
195
+
196
+ recall
197
+
198
+ f1
199
+
200
+ The scorer supports binary predictions or score-based predictions.
201
+
202
+ License
203
+
204
+ MIT
205
+
206
+ Structural Note
207
+
208
+ Clarus datasets are structural instruments.
209
+
210
+ They are designed to expose instability geometry, not just predict isolated outcomes.
211
+
212
+ This v0.2 repo adds directional state movement so the dataset can separate static oxygen-buffer strain from active deterioration in latent cross coupling.
213
+
214
+ Production Deployment
215
+
216
+ This dataset can be used in:
217
+
218
+ respiratory instability research
219
+
220
+ compensation failure monitoring
221
+
222
+ hidden coupling benchmarking
223
+
224
+ critical care trajectory modeling
225
+
226
+ model benchmarking for trajectory-aware latent coupling reasoning
227
+
228
+ It is suitable for research and prototyping.
229
+
230
+ It is not a substitute for live clinical judgment.
231
+
232
+ Enterprise & Research Collaboration
233
+
234
+ Clarus builds datasets for:
235
+
236
+ instability detection
237
+
238
+ trajectory tracking
239
+
240
+ intervention reasoning
241
+
242
+ These structures are not domain-bound.
243
+
244
+ They apply wherever systems move toward or away from failure.
245
+
246
+ Applicable domains include:
247
+
248
+ healthcare systems
249
+
250
+ financial markets
251
+
252
+ energy infrastructure
253
+
254
+ logistics networks
255
+
256
+ artificial intelligence systems
257
+
258
+ manufacturing systems
259
+
260
+ supply chains
261
+
262
+ climate systems
263
+
264
+ Any environment where:
265
+
266
+ capacity and demand interact
267
+
268
+ delays and coupling exist
269
+
270
+ trajectory determines outcome
271
+
272
+ This dataset is one instance of a general stability framework.