Spaces:
Running
Running
CarolinePascal commited on
chore(format): formatting code
Browse files
src/app/[org]/[dataset]/[episode]/fetch-data.ts
CHANGED
|
@@ -1619,9 +1619,7 @@ export async function loadCrossEpisodeActionVariance(
|
|
| 1619 |
{ length: cappedMaxEpisodes },
|
| 1620 |
(_, i) =>
|
| 1621 |
allEps[
|
| 1622 |
-
Math.round(
|
| 1623 |
-
(i * (allEps.length - 1)) / (cappedMaxEpisodes - 1),
|
| 1624 |
-
)
|
| 1625 |
],
|
| 1626 |
);
|
| 1627 |
|
|
@@ -1677,9 +1675,7 @@ export async function loadCrossEpisodeActionVariance(
|
|
| 1677 |
? sampledIndices.map((i) => states[i])
|
| 1678 |
: null;
|
| 1679 |
episodeActions.push({ index: ep.index, actions: sampledActions });
|
| 1680 |
-
episodeStates.push(
|
| 1681 |
-
stateKey ? sampledStates : null,
|
| 1682 |
-
);
|
| 1683 |
}
|
| 1684 |
}
|
| 1685 |
} catch {
|
|
@@ -1732,9 +1728,7 @@ export async function loadCrossEpisodeActionVariance(
|
|
| 1732 |
? sampledIndices.map((i) => states[i])
|
| 1733 |
: null;
|
| 1734 |
episodeActions.push({ index: ep.index, actions: sampledActions });
|
| 1735 |
-
episodeStates.push(
|
| 1736 |
-
stateKey ? sampledStates : null,
|
| 1737 |
-
);
|
| 1738 |
}
|
| 1739 |
} catch {
|
| 1740 |
/* skip */
|
|
@@ -2082,8 +2076,14 @@ export async function loadCrossEpisodeActionVariance(
|
|
| 2082 |
|
| 2083 |
for (let pi = 0; pi < pairs.length; pi++) {
|
| 2084 |
const [ai, si] = pairs[pi];
|
| 2085 |
-
const aDeltas = Array.from(
|
| 2086 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2087 |
const effN = aDeltas.length;
|
| 2088 |
if (effN < 4) continue;
|
| 2089 |
const aM = aDeltas.reduce((a, b) => a + b, 0) / effN;
|
|
|
|
| 1619 |
{ length: cappedMaxEpisodes },
|
| 1620 |
(_, i) =>
|
| 1621 |
allEps[
|
| 1622 |
+
Math.round((i * (allEps.length - 1)) / (cappedMaxEpisodes - 1))
|
|
|
|
|
|
|
| 1623 |
],
|
| 1624 |
);
|
| 1625 |
|
|
|
|
| 1675 |
? sampledIndices.map((i) => states[i])
|
| 1676 |
: null;
|
| 1677 |
episodeActions.push({ index: ep.index, actions: sampledActions });
|
| 1678 |
+
episodeStates.push(stateKey ? sampledStates : null);
|
|
|
|
|
|
|
| 1679 |
}
|
| 1680 |
}
|
| 1681 |
} catch {
|
|
|
|
| 1728 |
? sampledIndices.map((i) => states[i])
|
| 1729 |
: null;
|
| 1730 |
episodeActions.push({ index: ep.index, actions: sampledActions });
|
| 1731 |
+
episodeStates.push(stateKey ? sampledStates : null);
|
|
|
|
|
|
|
| 1732 |
}
|
| 1733 |
} catch {
|
| 1734 |
/* skip */
|
|
|
|
| 2076 |
|
| 2077 |
for (let pi = 0; pi < pairs.length; pi++) {
|
| 2078 |
const [ai, si] = pairs[pi];
|
| 2079 |
+
const aDeltas = Array.from(
|
| 2080 |
+
{ length: n - 1 },
|
| 2081 |
+
(_, t) => (actions[t + 1][ai] ?? 0) - (actions[t][ai] ?? 0),
|
| 2082 |
+
);
|
| 2083 |
+
const sDeltas = Array.from(
|
| 2084 |
+
{ length: n - 1 },
|
| 2085 |
+
(_, t) => (states[t + 1][si] ?? 0) - (states[t][si] ?? 0),
|
| 2086 |
+
);
|
| 2087 |
const effN = aDeltas.length;
|
| 2088 |
if (effN < 4) continue;
|
| 2089 |
const aM = aDeltas.reduce((a, b) => a + b, 0) / effN;
|
src/components/action-insights-panel.tsx
CHANGED
|
@@ -1284,10 +1284,17 @@ function StateActionAlignmentSection({
|
|
| 1284 |
// Per-pair cross-correlation (Δaction vs Δstate)
|
| 1285 |
const pairCorrs: number[][] = [];
|
| 1286 |
for (const [aKey, sKey] of pairs) {
|
| 1287 |
-
const aDeltas = data
|
| 1288 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1289 |
const n = Math.min(aDeltas.length, sDeltas.length);
|
| 1290 |
-
if (n < 4) {
|
|
|
|
|
|
|
|
|
|
| 1291 |
const aM = aDeltas.slice(0, n).reduce((a, b) => a + b, 0) / n;
|
| 1292 |
const sM = sDeltas.slice(0, n).reduce((a, b) => a + b, 0) / n;
|
| 1293 |
|
|
|
|
| 1284 |
// Per-pair cross-correlation (Δaction vs Δstate)
|
| 1285 |
const pairCorrs: number[][] = [];
|
| 1286 |
for (const [aKey, sKey] of pairs) {
|
| 1287 |
+
const aDeltas = data
|
| 1288 |
+
.slice(1)
|
| 1289 |
+
.map((row, i) => (row[aKey] ?? 0) - (data[i][aKey] ?? 0));
|
| 1290 |
+
const sDeltas = data
|
| 1291 |
+
.slice(1)
|
| 1292 |
+
.map((row, i) => (row[sKey] ?? 0) - (data[i][sKey] ?? 0));
|
| 1293 |
const n = Math.min(aDeltas.length, sDeltas.length);
|
| 1294 |
+
if (n < 4) {
|
| 1295 |
+
pairCorrs.push(Array(2 * maxLag + 1).fill(0));
|
| 1296 |
+
continue;
|
| 1297 |
+
}
|
| 1298 |
const aM = aDeltas.slice(0, n).reduce((a, b) => a + b, 0) / n;
|
| 1299 |
const sM = sDeltas.slice(0, n).reduce((a, b) => a + b, 0) / n;
|
| 1300 |
|