ictonyx.config
ModelConfig and configuration helpers.
- class ictonyx.config.ModelConfig(params=None)[source]
Bases:
objectTraining configuration container with validation and factory methods.
Stores hyperparameters as a flat dictionary with typed property accessors for common parameters (epochs, batch_size, learning_rate). Supports dictionary-style access, method chaining, deep copying, and parameter validation.
Use the factory classmethods to create pre-configured defaults for common model types.
- Parameters:
params (Dict[str, Any] | None) – Dictionary of hyperparameters. If
None, an empty config is created.
Example:
config = ModelConfig({'epochs': 20, 'batch_size': 64}) config.learning_rate = 0.001 config.set('dropout', 0.3).set('optimizer', 'adam')
See also
from_defaults(),for_cnn(),for_xgboost(),for_variability_study()- update(other_params)[source]
Update multiple parameters at once and return self for chaining.
- Parameters:
- Return type:
- merge(other_params)[source]
Alias for
update().Deprecated since version 0.3.9:
merge()is identical toupdate()and will be removed in v0.5.0. Useupdate()instead.- Parameters:
- Return type:
- has(key)[source]
Check if parameter exists.
Deprecated since version 0.3.9: Use the
inoperator instead:'key' in config. Will be removed in v0.5.0.
- copy()[source]
Create a deep copy of the configuration.
The frozen state is preserved: a frozen config produces a frozen copy.
- Return type:
- freeze()[source]
Make this config read-only to prevent mutation after construction.
Once frozen, any attempt to set or update parameters raises
RuntimeError. Returnsselffor method chaining.Example:
config = ModelConfig({"epochs": 10}).freeze() config.set("epochs", 20) # raises RuntimeError
- Return type:
- classmethod from_defaults()[source]
Create a config with sensible defaults for a generic training run.
- Returns:
A
ModelConfigwithepochs=10,batch_size=32,learning_rate=0.001,verbose=0, andcleanup_threshold=0.8.- Return type:
- classmethod for_cnn(input_shape=(128, 128, 3), num_classes=10)[source]
Create a config with defaults suitable for a CNN model.
Extends
from_defaults()with CNN-specific parameters and a more aggressive cleanup threshold (0.75) for memory-intensive models.- Parameters:
- Returns:
A
ModelConfigwith CNN-appropriate defaults.- Return type:
- classmethod for_xgboost(num_classes=10)[source]
Create a config with defaults suitable for an XGBoost model.
Extends
from_defaults()withn_estimators=180,max_depth=7, and the appropriate objective function (binary:logisticfor 2 classes,multi:softprobotherwise).- Parameters:
num_classes (int) – Number of output classes.
- Returns:
A
ModelConfigwith XGBoost-appropriate defaults.- Return type:
- classmethod for_variability_study(base_config, num_runs=20)[source]
Create a config for a variability study from an existing base config.
Copies the base config and adds study-specific parameters (
num_runs,epochs_per_run).- Parameters:
base_config (ModelConfig) – An existing
ModelConfigto use as a template.num_runs (int) – Number of independent training runs. Default 20.
- Returns:
A new
ModelConfigwith study parameters added.- Return type: