Spaces:
Sleeping
Sleeping
File size: 1,936 Bytes
0fff343 | 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 54 55 56 57 58 59 60 61 | """Typed grammar for engine_v2.
The grammar covers the FULL DSL:
- ``Matrix`` β a (sub)matrix of opaque-ID columns.
- ``Vector`` β one score per patient.
- ``Scalar`` β a single number (e.g. an Associate / Effect output).
- ``Model`` β a fitted classifier (Fit) we can Apply.
``FeatureSet`` is a leaf payload (a list of opaque IDs carried by Select);
``Agg`` / ``Op`` / ``Kind`` are enum-like string payloads. ``Predicate``
is carried by ``Split`` as a small dataclass.
"""
from __future__ import annotations
from enum import Enum
class TType(str, Enum):
"""Return type of an AST node β what a parent slot demands."""
MATRIX = "Matrix"
VECTOR = "Vector"
SCALAR = "Scalar"
MODEL = "Model"
# Reduce aggregators. Must mirror dsl.operators._REDUCE_AGGS.
AGGS = ("mean", "median", "max", "min", "var")
# Pairwise vector combinators. ``protected_div`` guards against zero.
OPS = ("add", "sub", "mul", "protected_div", "mean")
# Association kinds for the ``Associate`` and ``Effect`` operators.
ASSOC_KINDS = ("pearson", "spearman")
# Predicate kinds β the variable a ``Split`` partitions on:
# - "score" : threshold the input Vector at its median (NAME-BLIND).
# - "stage_late" : clinical predicate, True for AJCC stage III / IV.
PREDICATE_KINDS = ("score", "stage_late")
# Adjustment columns the ``Effect`` operator residualises on. Clinical
# only β never gene names.
EFFECT_ADJUST = ("stage", "age")
# Targets the engine may Associate / Effect / Fit against. Each is a
# named column on the cohort labels β NOT a gene.
ASSOC_TARGETS = ("msi", "tmb")
MIN_GENES_PER_SET = 1
DEFAULT_MAX_GENES_PER_SET = 8
DEFAULT_MAX_DEPTH = 4
DEFAULT_MAX_NODES = 24
# Hard caps for the recursive ``Search`` operator. Off by default; if the
# nested cost is acceptable, enable via the search-rate knob β never
# silently drop.
SEARCH_MAX_K = 4
SEARCH_MAX_COLS = 200
|