27. Transductive API¶
This page documents the transductive API. For a full run, see the transductive tutorial.
27.1 What it is for¶
The transductive brick provides registries and utilities for graph-based SSL methods. [1][2]
27.2 Examples¶
Run label propagation on a small graph:
import numpy as np
from modssc.graph import GraphBuilderSpec, build_graph
from modssc.graph.artifacts import NodeDataset
from modssc.transductive import get_method_class
from modssc.transductive.methods.classic.label_propagation import LabelPropagationSpec
X = np.random.randn(10, 4).astype(np.float32)
G = build_graph(X, spec=GraphBuilderSpec(scheme="knn", metric="cosine", k=3), seed=0, cache=False)
train_mask = np.zeros((10,), dtype=bool)
train_mask[:2] = True
node_ds = NodeDataset(X=X, y=np.zeros((10,), dtype=np.int64), graph=G, masks={"train_mask": train_mask})
method = get_method_class("label_propagation")(spec=LabelPropagationSpec())
method.fit(node_ds)
proba = method.predict_proba(node_ds)
print(proba.shape)
List available method IDs:
from modssc.transductive import available_methods
print(available_methods())
The method registry is defined in src/modssc/transductive/registry.py. [1]
27.3 API reference¶
Transductive semi supervised learning.
This package provides the math and integration layer: - backend abstraction (numpy, torch) - graph operators (normalization, laplacian, spmm) - generic solvers (fixed point, conjugate gradient) - PyG adapter (optional) - strict input validation
Algorithms (Label Propagation, Poisson Learning, GNNs, etc.) are added in later waves.
27.4
DeviceSpec
dataclass
¶
Device and dtype settings.
device
- cpu: always CPU
- cuda: use CUDA (error if unavailable)
- mps: use Apple MPS (error if unavailable)
- auto: pick cuda if available, else mps, else cpu
dtype: numeric precision to use for math operators
Source code in src/modssc/transductive/types.py
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |
27.5
OptionalDependencyError
dataclass
¶
Bases: PackageOptionalDependencyMessageMixin, ImportError
Raised when an optional dependency (extra) is required but missing.
Source code in src/modssc/transductive/errors.py
8 9 10 11 12 13 14 | |
27.6
TransductiveValidationError
¶
Bases: ValueError
Raised when inputs are invalid for transductive methods.
Source code in src/modssc/transductive/errors.py
17 18 | |
27.7
validate_node_dataset(data)
¶
Validate the minimal invariants needed by transductive algorithms.
Source code in src/modssc/transductive/validation.py
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 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |