Jacobian-Ranked Simplex Features / simplex_track.py

✓✓ Beats tuned baseline

Raw ⬇ ZIP
 1import numpy as np
 2
 3META = {
 4    "name": "jacobian_simplex_triangle",
 5    "domain": "geometric_graph",
 6    "description": "Invariant triangle edge lengths with Heron area and angle-sensitive regression target.",
 7}
 8
 9def get_dataset(seed, n_train, n_test):
10    def sample(n, s):
11        rng = np.random.RandomState(s)
12        p = rng.normal(size=(n, 3, 3)).astype(np.float32)
13        near = rng.rand(n) < 0.25
14        if near.any():
15            p[near, 2] = p[near, 1] + 0.04 * rng.normal(size=(near.sum(), 3)).astype(np.float32)
16        p *= (0.6 + 1.4 * rng.rand(n, 1, 1)).astype(np.float32)
17        a = np.linalg.norm(p[:, 0] - p[:, 1], axis=1)
18        b = np.linalg.norm(p[:, 1] - p[:, 2], axis=1)
19        c = np.linalg.norm(p[:, 2] - p[:, 0], axis=1)
20        sides = np.stack([a, b, c], axis=1).astype(np.float32)
21        ss = sides.sum(1) / 2
22        rad = ss * (ss-a) * (ss-b) * (ss-c)
23        area = np.sqrt(np.maximum(rad, 1e-10)).astype(np.float32)
24        y = (2 * area / np.maximum(a*c, 1e-7)).clip(0, 1).astype(np.float32)
25        return sides, y[:, None]
26    xtr, ytr = sample(n_train, seed)
27    xte, yte = sample(n_test, seed + 5000)
28    return {"xtr": xtr, "ytr": ytr, "xte": xte, "yte": yte,
29            "task": "regression", "metric": "mse", "out_dim": 1}