# Post-hoc checks: counts and a resample made after the result

Made after the result, not part of the frozen method. Each figure below is a recount of the published files (out/score-00.json to score-23.json, out/score2-00.json to score2-05.json, out/option-A.json and option-B.json), read by row number: rows c0001 to c0830 are the YouTube comments and c0831 to c1161 the Twitter posts. The plan's own results are in out/analysis-1.txt; the distance and cosine readings are in out/analysis-2.txt and the what-if in out/analysis-3.txt. Nothing here changes the plan's metric or its reported result.

## How it was recomputed

A comment is "with a reason" when it is not flagged off-topic and at least one of its seven numbers is not 0 (289 rows). The numbers are the scores of the seven reasons, -2 to +2. A comment leans not-cutting when the sum of its seven numbers is below 0, cut when above 0, mixed when 0. "Corruption not counted" sets the corruption number to 0 before the sum (comments that then have no reason are mixed with sum 0, so the 166 comments with a reason other than corruption are listed on their own). "Corruption end flipped" reverses the sign of the corruption number. The resample draws 289 comments with replacement 5,000 times (random generator seed 1), takes each option's mean dot product with the drawn comments, and counts which option is first; it uses the 289 comment vectors and the option vectors of out/option-A.json and out/option-B.json. The same seed gives the same counts; another seed moves them by about a point.

## Two things about the plan and the video

- The plan (section 3) said the two most-mentioned reasons would be drawn as lines for the video: corruption (138) and family health (70). The video draws state revenue (49, the third) and family health (70). This choice is not in the plan; corruption, whose direction is the least reliable part of the scoring (18 of 25), is left out of the drawing.
- The group the what-if gives more weight is called in the video 'the side that says shops are needed'. It is the comments whose seven numbers sum below 0, not a count of support for the shops.

## Numbers

- Rows: 1,161 (830 YouTube, 331 Twitter); off-topic 810; with a reason 289 (YouTube 165, Twitter 124); on topic with no reason 62.
- The 289 comment vectors hold 2,023 numbers: 1,668 are 0, 282 are 1 or -1, 73 are 2 or -2.
- Strength by reason (-2, -1, +1, +2): state revenue 4, 19, 18, 8; family health 3, 5, 38, 24; illicit liquor 4, 6, 10, 1; neighbourhood 1, 6, 11, 6; closures or private bars 6, 14, 9, 5; welfare 0, 2, 14, 3; corruption 5, 82, 48, 3.
- Comments with two or more reasons: 59. Comments with only the corruption reason: 123.
- Off-topic YouTube run: rows c0067 to c0262 (196 consecutive YouTube rows) are all flagged off-topic; by the raw file, which is not published, 192 of them are one Polish debate on beer advertising (192 of 830 comments, 23.1%); the other 4 rows of the run cannot be accounted for from the published files. The 165 YouTube comments with a reason come from 21 videos by the raw file.
- Lean, not-cutting / cut / mixed, as scored: all 130 / 153 / 6; YouTube 94 / 67 / 4; Twitter 36 / 86 / 2.
- Lean with the corruption number set to 0, among the 166 comments that have another reason: all 52 / 111 / 3; YouTube 24 / 49 / 2; Twitter 28 / 62 / 1.
- Lean with the corruption end flipped: all 91 / 187 / 11; YouTube 39 / 119 / 7; Twitter 52 / 68 / 4.
- Agreement of the second scoring with the first, on the same 300 rows: off-topic flag the same on 266; 2,100 cells (300 x 7), equal on 2,033; of the 120 cells where either scoring gave a number other than 0, 53 are exactly equal; where both gave one (70 cells), the same end (sign) in 63.
- Resample, 5,000 draws, first place by mean dot product. Draw A: full prohibition 4,999, keep as it is 1. Draw B: full prohibition 2,683 (53.7%), phased cut 1,565 (31.3%), managed reduction 744 (14.9%), buyback and digital pay only 8.
- Mean dot product with corruption not counted (O1 keep, O2 buyback, O3 phased cut, O4 full prohibition, O5 managed reduction). Draw A: -0.45, -0.45, 0.37, 0.79, 0.42. Draw B: -0.51, -0.51, 0.63, 0.79, 0.73. With the corruption end flipped, draw A: -0.58, -0.58, 0.51, 0.92, 0.55; draw B: -0.64, -0.77, 0.76, 1.05, 1.00. Full prohibition is first in all four.

## The code (run in the tasmac folder of the research files)

```python
import json, glob
import numpy as np
K = list(json.load(open('out/score-00.json'))[0]['scores'])
sc = {}
for f in sorted(glob.glob('out/score-??.json')):
    for r in json.load(open(f)): sc[r['id']] = r
ids = sorted(sc)
N = lambda i: int(i[1:])
V = np.array([[sc[i]['scores'][k] for k in K] for i in ids], float)
off = np.array([sc[i]['off_topic'] for i in ids]); has = (np.abs(V).sum(1) > 0) & ~off
yt = np.array([N(i) <= 830 for i in ids])
H = V[has]; Y = yt[has]
print('rows', len(ids), 'yt', yt.sum(), 'tw', (~yt).sum(), 'off', off.sum(), 'with reason', has.sum(), 'no reason', (~off & ~has).sum(), 'yt', (has & yt).sum(), 'tw', (has & ~yt).sum())
print('numbers', H.size, 'zero', (H == 0).sum(), 'size1', (abs(H) == 1).sum(), 'size2', (abs(H) == 2).sum())
for j, k in enumerate(K): print(k, {v: int((H[:, j] == v).sum()) for v in (-2, -1, 1, 2)})
print('two or more reasons', int(((H != 0).sum(1) >= 2).sum()))
c = K.index('system_corruption')
print('only corruption', int((((H != 0).sum(1) == 1) & (H[:, c] != 0)).sum()))
def lean(M):
    t = M.sum(1); return (int((t < 0).sum()), int((t > 0).sum()), int((t == 0).sum()))
F = H.copy(); F[:, c] *= -1
W = H.copy(); W[:, c] = 0
for name, M in (('as scored', H), ('corruption not counted', W), ('corruption flipped', F)):
    print(name, 'all', lean(M), 'youtube', lean(M[Y]), 'twitter', lean(M[~Y]))
Wsel = (W != 0).any(1); print('comments with a reason other than corruption', int(Wsel.sum()), lean(W[Wsel]), 'youtube', lean(W[Wsel & Y]), 'twitter', lean(W[Wsel & ~Y]))
best = (0, 0); run = 0
for n, o in enumerate(off):
    if yt[n] and o: run += 1
    else: run = 0
    if run > best[0]: best = (run, n)
print('longest run of consecutive off-topic YouTube rows', best[0], 'ending at', ids[best[1]])
sc2 = {}
for f in sorted(glob.glob('out/score2-??.json')):
    for r in json.load(open(f)): sc2[r['id']] = r
com = [i for i in sc2 if i in sc]; print('second scoring rows', len(com))
print('off flag same', sum(sc[i]['off_topic'] == sc2[i]['off_topic'] for i in com))
cells = eq = either = exact = both = same = 0
for i in com:
    for k in K:
        a, b = sc[i]['scores'][k], sc2[i]['scores'][k]; cells += 1; eq += a == b
        if a or b: either += 1; exact += a == b
        if a and b: both += 1; same += (a > 0) == (b > 0)
print('cells', cells, 'equal', eq, 'either', either, 'exact', exact, 'both', both, 'same end', same)
names = ['O1', 'O2', 'O3', 'O4', 'O5']
rng = np.random.default_rng(1)
for t in 'AB':
    o = json.load(open(f'out/option-{t}.json')); M = np.array([[o[n][k] for k in K] for n in names], float)
    P = H @ M.T; cnt = np.zeros(5, int)
    for _ in range(5000):
        ix = rng.integers(0, len(H), len(H)); cnt[P[ix].mean(0).argmax()] += 1
    print('draw', t, dict(zip(names, cnt.tolist())))
    for nm, X, MM in (('corruption not counted', W, M), ('corruption end flipped', F, M)):
        print(' ', nm, dict(zip(names, (X @ MM.T).mean(0).round(2).tolist())))
```
