Skip to content

Configuration Utilities

API reference for configuration helpers that let you persist ANFIS setups, manage presets, and export trained models.

anfis_toolbox.config

Configuration utilities for ANFIS models.

ANFISConfig

ANFISConfig()

Configuration manager for ANFIS models.

__repr__

__repr__() -> str

String representation of configuration.

add_input_config

add_input_config(
    name: str,
    range_min: float,
    range_max: float,
    n_mfs: int = 3,
    mf_type: str = "gaussian",
    overlap: float = 0.5,
) -> ANFISConfig

Add input configuration.

Parameters:

Name Type Description Default
name str

Input variable name

required
range_min float

Minimum input range

required
range_max float

Maximum input range

required
n_mfs int

Number of membership functions

3
mf_type str

Type of membership functions

'gaussian'
overlap float

Overlap factor

0.5

Returns:

Type Description
ANFISConfig

Self for method chaining

build_model

build_model() -> TSKANFIS

Build ANFIS model from configuration.

Returns:

Type Description
TSKANFIS

Configured ANFIS model

load classmethod

load(filepath: str | Path) -> ANFISConfig

Load configuration from JSON file.

Parameters:

Name Type Description Default
filepath str | Path

Path to configuration file

required

Returns:

Type Description
ANFISConfig

ANFISConfig object

save

save(filepath: str | Path) -> None

Save configuration to JSON file.

Parameters:

Name Type Description Default
filepath str | Path

Path to save configuration file

required

set_training_config

set_training_config(
    method: str = "hybrid",
    epochs: int = 50,
    learning_rate: float = 0.01,
    verbose: bool = False,
) -> ANFISConfig

Set training configuration.

Parameters:

Name Type Description Default
method str

Training method ('hybrid' or 'backprop')

'hybrid'
epochs int

Number of training epochs

50
learning_rate float

Learning rate

0.01
verbose bool

Whether to show training progress

False

Returns:

Type Description
ANFISConfig

Self for method chaining

to_dict

to_dict() -> _ConfigDict

Convert configuration to dictionary.

Returns:

Type Description
_ConfigDict

Configuration dictionary

ANFISModelManager

Model management utilities for saving/loading trained ANFIS models.

load_model staticmethod

load_model(filepath: str | Path) -> TSKANFIS

Load trained ANFIS model from file.

Parameters:

Name Type Description Default
filepath str | Path

Path to model file

required

Returns:

Type Description
TSKANFIS

Loaded ANFIS model

save_model staticmethod

save_model(
    model: TSKANFIS,
    filepath: str | Path,
    include_config: bool = True,
) -> None

Save trained ANFIS model to file.

Parameters:

Name Type Description Default
model TSKANFIS

Trained ANFIS model

required
filepath str | Path

Path to save model file

required
include_config bool

Whether to save model configuration

True

create_config_from_preset

create_config_from_preset(preset_name: str) -> ANFISConfig

Create configuration from predefined preset.

Parameters:

Name Type Description Default
preset_name str

Name of predefined configuration

required

Returns:

Type Description
ANFISConfig

ANFISConfig object

Raises:

Type Description
ValueError

If preset name not found

list_presets

list_presets() -> dict[str, str]

List available predefined configurations.

Returns:

Type Description
dict[str, str]

Dictionary mapping preset names to descriptions