Repository navigation
Expand file tree
/
Copy pathstage2_report.py
More file actions
53 lines (47 loc) · 14.5 KB
/
Copy pathstage2_report.py
File metadata and controls
53 lines (47 loc) · 14.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
"""Render completed Stage 2 screen results and existing qualitative annotations."""
import json
from pathlib import Path
from collections import Counter
from stage2_screen import ROOT,CONDITIONS,CLASSES,read_lines
def pct(x):return 'N/A' if x is None else f'{100*x:.2f}%'
def main():
run=ROOT/'runs/stage2-screen'
r=json.loads((run/'evaluation.json').read_text())
review=read_lines(run/'explanation_review.jsonl')
assert len(review)==84 and all(a['unsupported'] is not None or a['status']!='valid' for a in review)
responses=read_lines(run/'responses.jsonl')
lines=['# PrivSense Stage 2: approved 14-target screening results','','## Scope and execution','','Exactly 84 API requests were executed: 14 matched targets × C000, C010, C100, C001, C111 and R0. No repeats, interaction cells or full 372-target evaluation were run. Stage 1 artifacts remain unchanged. This is a direct-inference experiment; no planner, tools or trained classifier supplies Qwen predictions.','','Targets were selected from 372 legitimate 500-sample blocks in users 8–9 right-pocket recordings. Each target is the final 100 samples of a block, with the preceding 400 supplied only when T=1. Seed 42 selects one target per subject/activity pair; seed 43 freezes an interleaved condition rotation. Seven fixed training User 1 references are supplied only in A=1. All 14 target streams and histories are constant, giving only two observable bit patterns per condition. The balanced screen’s deterministic pattern bound is 4/14 = 28.57%, not the original 1,947-window score of 30.61%.','','Prompts are rendered exactly from the approved design, with R0 using the original Stage 1 message function. Frozen manifests and exact requests are in `data/stage2-screen/`. Model: qwen/qwen3.5-35b-a3b; temperature 0.1; maximum output 600 tokens; reasoning disabled; JSON-object output; no provider pin or effective sampling seed assumed. Each request is stateless. Local IDs/condition names and evaluator provenance do not enter the model messages.','','## Main result','','**No condition increased exact-activity accuracy: each scored 4/14.** Sensor metadata and longer history did not change any predicted class relative to C000. Auxiliary examples and combined information changed which moving class was guessed, exchanging correct and incorrect cases without any net gain. This is not evidence that more information identified the hidden activity.','','| Condition | Valid / 14 | Accuracy | Balanced accuracy | Macro-F1 | Moving/stationary (all targets) | Mean confidence (valid) | Insufficient (valid) |','|---|---:|---:|---:|---:|---:|---:|---:|']
for name in CONDITIONS:
c=r['conditions'][name]
lines.append(f"| {name} | {c['status_counts'].get('valid',0)} | {pct(c['accuracy'])} | {pct(c['balanced_accuracy'])} | {c['macro_f1']:.5f} | {pct(c['moving_stationary_accuracy'])} | {c['mean_confidence']:.3f} | {pct(c['insufficient_fraction'])} |")
lines += ['','C000 = minimal; C010 = sensor/task knowledge; C100 = preceding history; C001 = references; C111 = combined; R0 = original prompt. Invalid outputs count as errors in all-target metrics. All **valid** outputs classified the motion group correctly. The reduced all-target motion-group scores in C001/C111 reflect format failures, not wrong motion-group predictions.','','Macro-F1 changes must not be described as an accuracy gain. Switching the chosen class and producing invalid outputs changes precision/recall denominators. In particular, invalid predictions do not add false positives to a named activity class. Report these F1 values with accuracy, failure counts and matched valid-pair metrics rather than selecting a favorable metric.','','## Exact prediction behavior and paired changes','','| Condition | Predicted labels/counts | Changes versus C000 | Wrong→correct | Correct→wrong |','|---|---|---:|---:|---:|']
for name in CONDITIONS:
c=r['conditions'][name];d=r['contrasts'].get(name+'-C000',{})
lines.append(f"| {name} | {json.dumps(c['prediction_counts'])} | {d.get('prediction_changes',0)} | {d.get('wrong_to_correct',0)} | {d.get('correct_to_wrong',0)} |")
lines += ['','C000/C010/C100/R0 choose Jogging for eight all-one targets and Laying for six all-zero targets. C001 chooses Downstairs for the same eight all-one targets; C111 chooses Walking for seven of eight, with the eighth response invalid. C001 also has two invalid all-zero responses. The correct-class exchanges are predictable tie-breaking among observationally identical activities. The first matching moving reference is Downstairs, consistent with the explicit first-match choice in some C001 explanations. C111 frequently invokes an unsupported Walking prevalence assumption.','','The 10 C001 and eight C111 changed outputs include invalid-response transitions; they are not all valid class changes. No complete condition produced inconsistent valid class predictions within an identical-input group: each maps zeros to Laying and ones to a single chosen moving class. Each condition’s empirical pattern bound is 28.57%.','','## Baselines on exactly these 14 targets','','| Baseline | Accuracy | Macro-F1 | Moving/stationary |','|---|---:|---:|---:|']
for name in ['training_majority','fixed_rule','reference_rule']:
c=r['baselines'][name];lines.append(f"| {name} | {pct(c['accuracy'])} | {c['macro_f1']:.5f} | {pct(c['moving_stationary_accuracy'])} |")
for name in ['uniform_guess','training_prior_guess']:
c=r['baselines'][name];lines.append(f"| {name} (analytic) | {pct(c['expected_accuracy'])} | {c['macro_f1_from_expected_confusion']:.5f}* | {pct(c['expected_moving_stationary_accuracy'])} |")
lines += ['','*Guessing F1 is computed from expected confusion, not the expectation of finite-sample F1. Training priors come from the existing users 1–7 training labels, available only to the evaluator. Fixed rule: mostly ones→Walking, otherwise Sitting. Reference rule: first exact matching authorized reference, with a predefined majority fallback. The empirical pattern bound uses hidden labels for diagnosis and is not an attacker baseline.','','## Valid-response sensitivity and group summaries','','| Contrast (same valid targets) | N | C000 accuracy | Condition accuracy | Condition moving/stationary |','|---|---:|---:|---:|---:|']
for name,c in r['valid_pair_contrasts'].items():
lines.append(f"| {name} | {c['n']} | {pct(c['baseline']['accuracy'])} | {pct(c['condition']['accuracy'])} | {pct(c['condition']['moving_stationary_accuracy'])} |")
lines += ['','This sensitivity analysis excludes invalid cases identically from both sides. It does not replace all-target metrics or prove a benefit on a selected surviving subset.','','| Condition | User 8 accuracy | User 9 accuracy | Equal-recording accuracy |','|---|---:|---:|---:|']
for name,c in r['conditions'].items():
lines.append(f"| {name} | {pct(c['by_subject']['8']['accuracy'])} | {pct(c['by_subject']['9']['accuracy'])} | {pct(c['mean_recording_accuracy'])} |")
lines += ['','Each screen has one target per subject/class and 14 distinct source files. Equal-recording aggregation therefore provides no extra independent observations. The two subjects are insufficient for population-level significance claims. The repeated identical prompt inputs are not independent physiological evidence.','','## Confidence and uncertainty','','All 81 valid responses set sufficient_information=false. C000 confidence averages 0.614 versus 0.707 for R0 on the same target bits: prompt framing alone changes self-reported confidence without changing a single prediction. Sensor metadata raises confidence to 0.629; redundant history lowers it to 0.579. References lower it to 0.318 among valid responses; combined information yields 0.569. These are descriptive single-run differences, not calibrated probabilities or established causal effects of individual sentences.','','| Condition | Confidence when correct | Confidence when wrong | High-confidence wrong (≥0.8) | True label in alternatives (valid) |','|---|---:|---:|---:|---:|']
for name,c in r['conditions'].items():
lines.append(f"| {name} | {c['confidence_correct']:.3f} | {c['confidence_wrong']:.3f} | {c['high_confidence_wrong']} | {pct(c['alternative_coverage'])} |")
lines += ['','Alternative coverage excludes the predicted label by schema; a low value is not necessarily bad when the prediction is correct. Uncertainty acknowledgment receives no accuracy credit. Confidence comparisons involving C001/C111 use different valid-response counts, so missingness is a caveat.','','## Explanation review','','All 84 outputs were inspected; 81 had valid explanations. The saved review sheet omits true labels, subjects, recordings and correctness, while condition and predicted activity remain visible. Annotation was a **single qualitative review by the implementation assistant**, not an independent human-validated assessment. No additional LLM judge/API was used. Rates below are provisional rubric assessments; a human blinded audit is needed before publication.','','The rubric flags unsupported physical dynamics/uniqueness, inferred stillness or unprovided duration, incorrect counts/durations, false reference distinctions and asserted population priors without supplied evidence. Qualified forced-choice guesses and explicitly arbitrary reference tie-breaking are not automatically flagged. Two C001 explanations explicitly self-correct earlier speculation and conclude that the label is arbitrary; they are not counted as unretracted unsupported claims.','','| Condition | Flagged explanations / valid | Rate |','|---|---:|---:|']
for name in CONDITIONS:
rr=[x for x in review if x['condition']==name and x['status']=='valid'];n=sum(x['unsupported'] for x in rr)
lines.append(f'| {name} | {n}/{len(rr)} | {pct(n/len(rr))} |')
lines += ['','Concrete failure examples:','','- `target-0050-C000` counts 80 samples although the target contains 100.','- `target-0077-C010` states a 1.28-second window despite the supplied 100 samples at 50 Hz.','- `target-0294-C111` states 80 samples / 1.6 seconds and asserts only Laying matches the zero references, while Sitting and Standing have identical zero examples.','- Several all-one C000/C010/C100/R0 responses claim high-frequency, high-intensity or rhythmic motion that the constant output does not measure.','- C111 all-one explanations choose Walking because it is supposedly most common; no prevalence data was supplied.','- C001 moving-target explanations generally acknowledge that Downstairs/Jogging/Upstairs/Walking are indistinguishable and describe their choice as arbitrary or first in the reference list.','','Auxiliary examples improved ambiguity descriptions in many valid responses but also caused long self-correcting explanations, format failures and occasional misreading of the references. Sensor metadata did not reliably eliminate unsupported physical interpretations. The combined condition did not preserve the auxiliary-only explanation benefit. With missing interaction cells and one repeat, do not infer which component caused that behavior.','','## Invalid responses and cost','','Three requests returned invalid responses: two exceeded the fixed 600-token output budget (`target-0008-C111`, `target-0262-C001`), and one used the key `" explanation"` instead of `"explanation"` (`target-0294-C001`). The last is syntactically valid JSON but fails the frozen schema. Raw responses remain saved. They were not repaired, retried, or given a larger budget after inspecting results. No HTTP errors occurred.','','| Condition | Reported tokens | Reported USD |','|---|---:|---:|']
for name,c in r['conditions'].items():lines.append(f"| {name} | {c['usage']['total_tokens']} | ${c['usage']['reported_cost_usd']:.6f} |")
total=sum(c['usage']['reported_cost_usd'] for c in r['conditions'].values());tokens=sum(c['usage']['total_tokens'] for c in r['conditions'].values())
lines += ['',f'Total: **{tokens:,} tokens; ${total:.6f} reported API cost** for exactly 84 requests. Invalid-output requests are included. Added examples/history increase token consumption without increasing exact accuracy here.','','## Confusion matrices','','Columns are Downstairs, Jogging, Laying, Sitting, Standing, Upstairs, Walking, INVALID_OR_MISSING. Rows follow the seven true labels.']
for name,c in r['conditions'].items():lines+=['',f'### {name}','```json',json.dumps(c['confusion_matrix']),'```']
lines += ['','## What the screen establishes—and what it does not','','It establishes that, for these fixed constant binary observations and this one run, knowledge changes confidence, explanation quality and class tie-breaking more than exact recognition. Authentic longer context contains no added variation and did not change labels. All conditions match the balanced-set pattern bound in all-target accuracy, including three invalid outputs that happened not to remove a correct answer. This does not establish better activity discrimination, a general failure of temporal inference, an information-theoretic impossibility for other interfaces, or a robust ranking of prompts.','','No full 372-target evaluation, interaction expansion or repeated-run selection was performed. The next priority is to define independently validated information-bearing interfaces alongside this information-limited control, not to spend more calls on constant repetitions. See `binary_interface_benchmark_design.md` for the read-only survey and predefined selection protocol.','','## Reproduction and artifacts','','```bash','source .venv/bin/activate','# Already prepared/executed in this workspace; use new paths only for a separately authorized repeat.','python stage2_screen.py prepare --data data/stage2-screen-new','python stage2_screen.py infer --data data/stage2-screen-new --run runs/stage2-screen-new','python stage2_screen.py evaluate --data data/stage2-screen-new --run runs/stage2-screen-new','python stage2_report.py','```','','Frozen inputs: `data/stage2-screen/manifest.json`, `requests.jsonl`, `truth.jsonl`, selected observations and reference provenance. Outputs: `runs/stage2-screen/responses.jsonl`, `evaluation.json`, `explanation_review.jsonl`. Exact prompts and metadata differences are logged for every request. `--resume` skips all completed responses, including invalid ones; it does not expand the experiment or retry until success. The report renderer reads the default completed run. Data/run directories and credentials remain ignored by Git.']
(ROOT/'reports/stage2_screening_results.md').write_text('\n'.join(lines)+'\n')
print('Wrote reports/stage2_screening_results.md')
if __name__=='__main__':main()