MODULE REFERENCE
generic
anomx.models.genericAdapters for user supplied estimators, functions, and PyTorch modules.
GenericModel
GenericModel(model: Any, *, family: str = 'predictive', fit_fn: Callable | None = None, predict_fn: Callable | None = None, epochs: int = 20, batch_size: int = 32, learning_rate: float = 0.001, loss_fn: Callable | None = None, optimizer_factory: Callable | None = None, device: str = 'cpu', random_state: int = 42)Bases: NormalityModel
Adapt an estimator, callable, or torch.nn.Module to Anomx.
fit_fn(model, x, y) and predict_fn(model, x) explicitly override the underlying implementation. Estimators otherwise use their fit and predict methods; callable models support inference without fitting. The observation axis is always first. Prediction must preserve its length, while the remaining axes may change (for example for embeddings).
PyTorch modules receive float32 inputs and train with Adam/MSE unless an optimizer factory or loss function is provided. Classification uses integer class targets and cross-entropy; prediction returns class logits. Reconstruction models may omit targets; other families require them. No scaling, window creation, or forecast alignment is implicit. Use TorchForecastingModel for sliding-window forecasting. Torch remains an optional dependency.
Parameters
- model
Estimator, callable, or torch module owned by this adapter.
- family
predictive,forecasting,reconstruction,representation, orclassification. Describes purpose without restricting tensor axes.- epochs, batch_size, learning_rate
Positive PyTorch training settings; ignored by estimator backends.
| Parameter | Type | Default |
|---|---|---|
model | Any | required |
familykeyword only | str | 'predictive' |
fit_fnkeyword only | Callable | None | None |
predict_fnkeyword only | Callable | None | None |
epochskeyword only | int | 20 |
batch_sizekeyword only | int | 32 |
learning_ratekeyword only | float | 0.001 |
loss_fnkeyword only | Callable | None | None |
optimizer_factorykeyword only | Callable | None | None |
devicekeyword only | str | 'cpu' |
random_statekeyword only | int | 42 |
Members
component_typeattribute
component_type = 'model'component_keyattribute
component_key = 'generic_model'component_nameattribute
component_name = 'Generic Model'component_discoverableattribute
component_discoverable = Falseis_torchproperty
is_torch: boolWhether the wrapped object inherits from torch.nn.Module.
Returns bool
fitmethod
fit(data: Any, target: Any = None, *, verbose: bool = False) -> GenericModelFit only the supplied observations; record PyTorch epoch losses.
| Parameter | Type | Default |
|---|---|---|
data | Any | required |
target | Any | None |
verbosekeyword only | bool | False |
Returns GenericModel
predictmethod
predict(data: Any) -> AnyPredict while retaining a DataFrame index or TimeSeries coordinates.
| Parameter | Type | Default |
|---|---|---|
data | Any | required |
Returns Any
savemethod
save(path: str) -> NoneSerialize this adapter; only load trusted pickle files.
| Parameter | Type | Default |
|---|---|---|
path | str | required |
Returns None
loadmethod
load(path: str) -> GenericModelReplace adapter state from a trusted file written by save.
| Parameter | Type | Default |
|---|---|---|
path | str | required |
Returns GenericModel
Inherited members
partial_fitNormalityModelscore_batchNormalityModelis_component_abstractBaseComponentget_component_typeBaseComponentget_component_keyBaseComponentget_component_nameBaseComponentget_component_docsBaseComponentget_component_descriptionBaseComponentget_component_iconBaseComponentget_component_image_pathBaseComponentget_component_statusBaseComponentget_component_default_configBaseComponentget_component_config_schemaBaseComponentget_component_code_versionBaseComponentget_component_source_pathBaseComponentget_component_import_pathBaseComponentget_component_capabilitiesBaseComponentget_component_signatureBaseComponentget_component_parametersBaseComponentget_configBaseComponent