Skip to content

SVM Models API

Both public classes are experimental heuristics. They do not claim equivalence to a published incremental One-Class SVM optimizer.

IncrementalOneClassSVMAdaptiveKernel

Python
IncrementalOneClassSVMAdaptiveKernel(nu: float = 0.1, initial_gamma: float = 1.0, gamma_bounds: tuple[float, float] = (0.001, 100.0), adaptation_rate: float = 0.1, buffer_size: int = 200, sv_budget: int = 100, tolerance: float = 1e-06, seed: int | None = None)

Bases: BaseModel

Experimental incremental one-class kernel model with adaptive gamma.

This is a custom budgeted support-vector heuristic, not an implementation of a published incremental One-Class SVM optimizer. Support vectors and the recent-data buffer are stored in raw feature coordinates. Kernel values are computed after applying the current running standardization to both operands, so all comparisons use one consistent coordinate system.

Parameters:

Name Type Description Default
nu float

Heuristic support-vector weight scale in (0, 1]. It controls the initial weight and caps weights added for negative margins; it does not carry a solver-backed One-Class SVM nu guarantee.

0.1
initial_gamma float

Initial positive RBF-kernel coefficient.

1.0
gamma_bounds tuple[float, float]

Positive inclusive lower and upper bounds for adaptive gamma. The interval must contain initial_gamma.

(0.001, 100.0)
adaptation_rate float

Interpolation fraction in (0, 1] toward the median-distance gamma estimate at each adaptation step.

0.1
buffer_size int

Maximum recent raw samples used to estimate gamma.

200
sv_budget int

Maximum retained support vectors.

100
tolerance float

Non-negative margin tolerance used for support-vector insertion and predict_one.

1e-06
seed int | None

Seed for the model-local subsampling generator used by gamma estimation.

None

learn_one

Python
learn_one(x: dict[str, float]) -> None

Incrementally learn from one sample.

predict_one

Python
predict_one(x: dict[str, float]) -> int

Predict normal (1) or anomalous (-1).

score_one

Python
score_one(x: dict[str, float]) -> float

Compute anomaly score (higher means more anomalous).

get_model_info

Python
get_model_info() -> dict[str, object]

Return current model diagnostics.

GraphGatedOneClassSVM

Python
GraphGatedOneClassSVM(graph: dict[int, list[int]] | None = None, threshold: float = 0.0, learning_rate: float = 0.01, nu: float = 0.5, lambda_reg: float = 0.01)

Bases: BaseModel

Graph-gated ensemble of incremental linear one-class SVM heuristics.

The graph determines which node models are updated and scored. This custom anomaly detector is unrelated to the published GADGET distributed averaging and optimization algorithm.

Traversal starts at nodes with no incoming edge. A node's outgoing edges are traversed only when its local score exceeds threshold. Each visited node owns an incremental linear hinge-style heuristic.

Parameters:

Name Type Description Default
graph dict[int, list[int]] | None

Directed adjacency mapping from integer node identifiers to child-node lists. None uses the chain 0 -> 1 -> 2. The mapping and child lists are copied.

None
threshold float

Local score gate for traversing outgoing edges.

0.0
learning_rate float

Step size used by every node model.

0.01
nu float

Coefficient in every node model's bias update. This custom update does not provide the guarantees of a solved One-Class SVM.

0.5
lambda_reg float

Weight-decay coefficient used by every node model.

0.01