dfm-python 0.6.13__tar.gz → 0.6.14__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. {dfm_python-0.6.13 → dfm_python-0.6.14}/PKG-INFO +1 -1
  2. {dfm_python-0.6.13 → dfm_python-0.6.14}/config/ddfm_exchange.yaml +13 -22
  3. {dfm_python-0.6.13 → dfm_python-0.6.14}/config/ddfm_finance.yaml +12 -11
  4. dfm_python-0.6.14/config/ivdfm_exchange.yaml +39 -0
  5. dfm_python-0.6.14/config/ivdfm_finance.yaml +38 -0
  6. dfm_python-0.6.14/config/ivdfm_macro.yaml +40 -0
  7. {dfm_python-0.6.13 → dfm_python-0.6.14}/pyproject.toml +1 -1
  8. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/config/constants.py +59 -0
  9. dfm_python-0.6.14/src/dfm_python/config/schema/__init__.py +19 -0
  10. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/config/schema/model.py +264 -0
  11. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/config/schema/params.py +183 -0
  12. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/config/schema/results.py +173 -84
  13. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/dataset/__init__.py +2 -0
  14. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/dataset/ddfm_dataset.py +21 -0
  15. dfm_python-0.6.14/src/dfm_python/dataset/ivdfm_dataset.py +368 -0
  16. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/functional/krylov.py +2 -61
  17. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/layer/mlp.py +4 -2
  18. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/logger/__init__.py +8 -0
  19. dfm_python-0.6.14/src/dfm_python/logger/ivdfm_logger.py +92 -0
  20. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/models/ddfm/ddfm.py +17 -8
  21. dfm_python-0.6.14/src/dfm_python/models/ivdfm/__init__.py +16 -0
  22. dfm_python-0.6.14/src/dfm_python/models/ivdfm/decoder.py +137 -0
  23. dfm_python-0.6.14/src/dfm_python/models/ivdfm/encoder.py +193 -0
  24. dfm_python-0.6.14/src/dfm_python/models/ivdfm/ivdfm.py +1271 -0
  25. dfm_python-0.6.14/src/dfm_python/models/ivdfm/prior.py +560 -0
  26. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/numeric/builder.py +209 -0
  27. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/ssm/__init__.py +6 -0
  28. dfm_python-0.6.14/src/dfm_python/ssm/base.py +208 -0
  29. dfm_python-0.6.14/src/dfm_python/ssm/companion.py +292 -0
  30. dfm_python-0.6.14/src/dfm_python/utils/loss.py +392 -0
  31. dfm_python-0.6.14/src/test/dataset/test_ivdfm_dataset.py +284 -0
  32. dfm_python-0.6.14/src/test/models/test_ivdfm.py +472 -0
  33. dfm_python-0.6.14/tutorial/tutorial_exchange_ivdfm.py +122 -0
  34. {dfm_python-0.6.13 → dfm_python-0.6.14}/tutorial/tutorial_finance_ddfm.py +38 -14
  35. dfm_python-0.6.14/tutorial/tutorial_finance_ivdfm.py +163 -0
  36. dfm_python-0.6.14/tutorial/tutorial_macro_ivdfm.py +148 -0
  37. dfm_python-0.6.13/src/dfm_python/config/schema/__init__.py +0 -19
  38. dfm_python-0.6.13/src/dfm_python/functional/cauchy.py +0 -236
  39. dfm_python-0.6.13/src/dfm_python/logger/ivdfm_logger.py +0 -0
  40. dfm_python-0.6.13/src/dfm_python/models/ivdfm/__init__.py +0 -0
  41. dfm_python-0.6.13/src/dfm_python/models/ivdfm/decoder.py +0 -0
  42. dfm_python-0.6.13/src/dfm_python/models/ivdfm/encoder.py +0 -0
  43. dfm_python-0.6.13/src/dfm_python/models/ivdfm/ivdfm.py +0 -708
  44. dfm_python-0.6.13/src/dfm_python/utils/loss.py +0 -330
  45. {dfm_python-0.6.13 → dfm_python-0.6.14}/.cursor/agents/test-runner.md +0 -0
  46. {dfm_python-0.6.13 → dfm_python-0.6.14}/.gitignore +0 -0
  47. {dfm_python-0.6.13 → dfm_python-0.6.14}/.python-version +0 -0
  48. {dfm_python-0.6.13 → dfm_python-0.6.14}/=0.11.0 +0 -0
  49. {dfm_python-0.6.13 → dfm_python-0.6.14}/MANIFEST.in +0 -0
  50. {dfm_python-0.6.13 → dfm_python-0.6.14}/config/ddfm_macro.yaml +0 -0
  51. {dfm_python-0.6.13 → dfm_python-0.6.14}/config/dfm_exchange.yaml +0 -0
  52. {dfm_python-0.6.13 → dfm_python-0.6.14}/config/dfm_finance.yaml +0 -0
  53. {dfm_python-0.6.13 → dfm_python-0.6.14}/config/dfm_macro.yaml +0 -0
  54. {dfm_python-0.6.13 → dfm_python-0.6.14}/data/exchange_rate.csv +0 -0
  55. {dfm_python-0.6.13 → dfm_python-0.6.14}/data/finance.csv +0 -0
  56. {dfm_python-0.6.13 → dfm_python-0.6.14}/data/macro.csv +0 -0
  57. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/__init__.py +0 -0
  58. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/config/__init__.py +0 -0
  59. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/config/adapter.py +0 -0
  60. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/config/schema/block.py +0 -0
  61. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/config/types.py +0 -0
  62. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/dataset/dfm_dataset.py +0 -0
  63. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/dataset/time.py +0 -0
  64. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/functional/__init__.py +0 -0
  65. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/functional/em.py +0 -0
  66. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/layer/pca.py +0 -0
  67. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/logger/ddfm_logger.py +0 -0
  68. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/logger/dfm_logger.py +0 -0
  69. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/logger/inference_logger.py +0 -0
  70. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/logger/logger.py +0 -0
  71. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/logger/train_logger.py +0 -0
  72. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/models/__init__.py +0 -0
  73. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/models/base.py +0 -0
  74. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/models/ddfm/__init__.py +0 -0
  75. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/models/ddfm/decoder.py +0 -0
  76. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/models/ddfm/encoder.py +0 -0
  77. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/models/ddfm/sampling.py +0 -0
  78. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/models/dfm/__init__.py +0 -0
  79. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/models/dfm/dfm.py +0 -0
  80. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/models/dfm/initialization.py +0 -0
  81. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/models/dfm/mixed_freq.py +0 -0
  82. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/models/dfm/tent.py +0 -0
  83. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/numeric/estimator.py +0 -0
  84. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/numeric/stability.py +0 -0
  85. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/numeric/statistic.py +0 -0
  86. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/numeric/validator.py +0 -0
  87. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/ssm/kalman.py +0 -0
  88. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/utils/__init__.py +0 -0
  89. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/utils/checkpoint.py +0 -0
  90. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/utils/errors.py +0 -0
  91. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/utils/helper.py +0 -0
  92. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/utils/metric.py +0 -0
  93. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/utils/misc.py +0 -0
  94. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/dfm_python/utils/validation.py +0 -0
  95. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/__init__.py +0 -0
  96. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/config/__init__.py +0 -0
  97. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/config/schema/__init__.py +0 -0
  98. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/config/schema/test_block.py +0 -0
  99. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/config/schema/test_model.py +0 -0
  100. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/config/schema/test_results.py +0 -0
  101. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/config/test_adapter.py +0 -0
  102. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/config/test_constants.py +0 -0
  103. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/config/test_tent_weights_config.py +0 -0
  104. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/config/test_types.py +0 -0
  105. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/conftest.py +0 -0
  106. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/dataset/test_ddfm_dataset.py +0 -0
  107. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/dataset/test_dfm_dataset.py +0 -0
  108. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/functional/__init__.py +0 -0
  109. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/functional/test_em.py +0 -0
  110. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/functional/test_em_correctness.py +0 -0
  111. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/functional/test_em_properties.py +0 -0
  112. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/logger/__init__.py +0 -0
  113. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/logger/test_inference_logger.py +0 -0
  114. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/logger/test_logger.py +0 -0
  115. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/logger/test_train_logger.py +0 -0
  116. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/models/__init__.py +0 -0
  117. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/models/test_ddfm.py +0 -0
  118. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/models/test_ddfm_sampling.py +0 -0
  119. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/models/test_dfm.py +0 -0
  120. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/numeric/__init__.py +0 -0
  121. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/numeric/test_builder.py +0 -0
  122. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/numeric/test_cov_rowvar_regression.py +0 -0
  123. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/numeric/test_estimator.py +0 -0
  124. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/numeric/test_initialization.py +0 -0
  125. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/numeric/test_stability.py +0 -0
  126. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/numeric/test_validator.py +0 -0
  127. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/ssm/__init__.py +0 -0
  128. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/ssm/test_kalman.py +0 -0
  129. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/ssm/test_kalman_correctness.py +0 -0
  130. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/utils/__init__.py +0 -0
  131. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/utils/test_errors.py +0 -0
  132. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/utils/test_helper.py +0 -0
  133. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/utils/test_metric.py +0 -0
  134. {dfm_python-0.6.13 → dfm_python-0.6.14}/src/test/utils/test_misc.py +0 -0
  135. {dfm_python-0.6.13 → dfm_python-0.6.14}/tutorial/tutorial_exchange_ddfm.py +0 -0
  136. {dfm_python-0.6.13 → dfm_python-0.6.14}/tutorial/tutorial_exchange_dfm.py +0 -0
  137. {dfm_python-0.6.13 → dfm_python-0.6.14}/tutorial/tutorial_finance_dfm.py +0 -0
  138. {dfm_python-0.6.13 → dfm_python-0.6.14}/tutorial/tutorial_macro_ddfm.py +0 -0
  139. {dfm_python-0.6.13 → dfm_python-0.6.14}/tutorial/tutorial_macro_dfm.py +0 -0
  140. {dfm_python-0.6.13 → dfm_python-0.6.14}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dfm-python
3
- Version: 0.6.13
3
+ Version: 0.6.14
4
4
  Summary: Dynamic Factor Model (DFM) estimation and forecasting in Python
5
5
  Project-URL: Homepage, https://github.com/yourusername/dfm-python
6
6
  Project-URL: Documentation, https://github.com/yourusername/dfm-python#readme
@@ -9,16 +9,20 @@ encoder_layers: [16, 4] # Hidden layers: [16] -> latent: 4 (matching original s
9
9
  activation: relu # Matching original link='relu'
10
10
  use_batch_norm: true # Matching original batch_norm=True
11
11
 
12
- # Training Parameters (matching original TensorFlow DDFM)
13
- learning_rate: 0.005 # Matching original learning_rate=0.005
14
- n_mc_samples: 10 # Number of MC samples per MCMC iteration (matching original epochs=10)
15
- window_size: 100 # Time-step batch size for training (matching original batch_size=100)
12
+ # Training Parameters
13
+ # NOTE: for fair comparison with iVDFM exchange tutorial/config, we align the
14
+ # effective window length and training budget (see ivdfm_exchange.yaml).
15
+ learning_rate: 0.005
16
+ n_mc_samples: 10
17
+ window_size: 200 # Align with iVDFM sequence_length=200
16
18
 
17
- # MCMC/Iterative Parameters (matching original TensorFlow DDFM)
18
- max_epoch: 200 # Maximum MCMC iterations (matching original max_iter=200)
19
- tolerance: 0.0005 # Convergence tolerance (matching original tolerance=0.0005)
20
- disp: 10 # Display frequency for training progress (matching original disp=10)
21
- seed: 3 # Random seed (matching original seed=3)
19
+ # MCMC/Iterative Parameters
20
+ # NOTE: DDFM uses max_epoch as an iteration budget; iVDFM uses max_epochs.
21
+ # We set this to 10 here to make the tutorials comparable in runtime budget.
22
+ max_epoch: 10
23
+ tolerance: 0.0005
24
+ disp: 10
25
+ seed: 3
22
26
 
23
27
  # Interpolation Parameters
24
28
  interpolation_method: linear # Interpolation method for missing values
@@ -28,16 +32,3 @@ interpolation_limit_direction: both # Direction to fill ('forward', 'backward',
28
32
  # Data Handling (used by Dataset, not Model)
29
33
  clock: d # Daily clock frequency (all series are daily)
30
34
  scaler: null # No scaler - data should be pre-scaled before passing to Dataset
31
-
32
- # Frequency mapping (all series are daily)
33
- # If not specified, all series use clock frequency (d)
34
- # Format: {"series_name": "frequency_code"}
35
- # frequency:
36
- # AUD_USD: d
37
- # GBP_USD: d
38
- # CAD_USD: d
39
- # CHF_USD: d
40
- # CNY_USD: d
41
- # JPY_USD: d
42
- # SGD_USD: d
43
- # NZD_USD: d
@@ -3,17 +3,24 @@
3
3
  # Clock: Monthly (m) - all series are monthly frequency
4
4
 
5
5
  # Neural Network Architecture
6
- encoder_layers: [64, 32, 2] # Hidden layers: [64, 32] -> latent: 2 factors
6
+ # Match iVDFM depth/width more closely: 3 hidden layers of size ~200
7
+ encoder_layers: [64, 32, 5] # Hidden layers: [200, 200] -> latent: 5 factors (match iVDFM capacity)
7
8
  activation: relu # Activation function: 'tanh', 'relu', 'sigmoid'
8
9
  use_batch_norm: true # Use batch normalization
10
+ decoder_type: mlp # Use non-linear (MLP) decoder instead of linear
11
+
12
+ # Target/covariate split
13
+ # For DDFM finance: covariates are ALL columns except the target.
14
+ target_col: market_forward_excess_returns
15
+ covariates: all_except_target
9
16
 
10
17
  # Training Parameters
11
18
  learning_rate: 0.001 # Learning rate for optimizer
12
- n_mc_samples: 1 # Number of MC samples per MCMC iteration (reduced for faster execution)
13
- window_size: 100 # Time-step batch size for training
19
+ n_mc_samples: 10 # Number of MC samples per MCMC iteration
20
+ window_size: 200 # Align with iVDFM sequence_length=200
14
21
 
15
22
  # MCMC/Iterative Parameters
16
- max_epoch: 200 # Maximum MCMC iterations
23
+ max_epoch: 10 # Align with iVDFM max_epochs=10
17
24
  tolerance: 0.0005 # Convergence tolerance
18
25
  disp: 10 # Display frequency for training progress
19
26
  seed: null # Random seed (None uses default)
@@ -27,10 +34,4 @@ interpolation_limit_direction: both # Direction to fill ('forward', 'backward',
27
34
  clock: m # Monthly clock frequency
28
35
  scaler: standard # Scaler for target series: 'standard', 'robust', 'minmax', 'maxabs', 'quantile', or null
29
36
 
30
- # Frequency mapping (optional)
31
- # If not specified, all series use clock frequency
32
- # Format: {"series_name": "frequency_code"}
33
- # frequency:
34
- # gdp: q
35
- # unemployment: m
36
- # interest_rate: m
37
+
@@ -0,0 +1,39 @@
1
+ # iVDFM Configuration for Exchange Rate Dataset
2
+ # Data: 8 exchange rate series (AUD_USD, GBP_USD, CAD_USD, CHF_USD, CNY_USD, JPY_USD, SGD_USD, NZD_USD)
3
+ # Clock: Daily (d) - all series are daily frequency
4
+ # Date range: 1990-01-01 to 2010-10-10
5
+
6
+ # ===== Model Structure =====
7
+ # Latent dimension
8
+ num_factors: 2
9
+ sequence_length: 200 # Sequence length for sliding windows
10
+ context: null # Column names (DataFrame) or indices (array) for context variables. If None, time-based context is generated.
11
+ context_dim: 1 # Dimension of context. Used when context is None (generates time-based context) or when context is multivariate.
12
+
13
+ # ===== Neural Network Architecture =====
14
+ encoder_hidden_dim: 200 # Encoder hidden dimension
15
+ encoder_n_layers: 3 # Number of encoder layers
16
+ decoder_hidden_dim: 200 # Decoder hidden dimension
17
+ decoder_n_layers: 3 # Number of decoder layers
18
+ prior_hidden_dim: 100 # Prior network hidden dimension
19
+ prior_n_layers: 2 # Number of prior network layers
20
+ activation: lrelu # Activation function: 'relu', 'lrelu', 'tanh', 'sigmoid'
21
+ slope: 0.1 # Leaky ReLU slope
22
+
23
+ # ===== Dynamics and Distribution Parameters =====
24
+ factor_order: 1 # AR order for factors (p in AR(p))
25
+ innovation_distribution: laplace # Innovation distribution: 'laplace', 'gaussian', 'student_t'
26
+ decoder_var: 0.01 # Decoder variance (observation noise)
27
+
28
+ # ===== Training Parameters =====
29
+ learning_rate: 0.001 # Learning rate for optimizer
30
+ optimizer: Adam # Optimizer type: 'Adam', 'AdamW', 'SGD'
31
+ batch_size: 256 # Batch size for training (larger to reduce #batches/epoch)
32
+ max_epochs: 10 # Maximum training epochs
33
+ tolerance: 1.0e-5 # Convergence tolerance
34
+ seed: null # Random seed (None uses default)
35
+
36
+ # ===== Base Model Config (inherited) =====
37
+ frequency: null # iVDFM doesn't use mixed-frequency structure
38
+ clock: d # Daily clock frequency (all series are daily)
39
+ scaler: null # Scaler for targets: 'standard', 'robust', 'minmax', 'maxabs', 'quantile', or null. Applied to targets only (not context/auxiliary variables)
@@ -0,0 +1,38 @@
1
+ # iVDFM Configuration for Finance Dataset
2
+ # Data: Finance data with market_forward_excess_returns as target variable
3
+ # Clock: Monthly (m) - all series are monthly frequency
4
+
5
+ # ===== Model Structure =====
6
+ # Latent dimension
7
+ num_factors: 5
8
+ sequence_length: 200 # Sequence length for sliding windows
9
+ context: null # Column names (DataFrame) or indices (array) for context variables. If None, time-based context is generated.
10
+ context_dim: 1 # Dimension of context. Used when context is None (generates time-based context) or when context is multivariate.
11
+
12
+ # ===== Neural Network Architecture =====
13
+ encoder_hidden_dim: 50 # Encoder hidden dimension
14
+ encoder_n_layers: 2 # Number of encoder layers
15
+ decoder_hidden_dim: 50 # Decoder hidden dimension
16
+ decoder_n_layers: 2 # Number of decoder layers
17
+ prior_hidden_dim: 100 # Prior network hidden dimension
18
+ prior_n_layers: 2 # Number of prior network layers
19
+ activation: lrelu # Activation function: 'relu', 'lrelu', 'tanh', 'sigmoid'
20
+ slope: 0.1 # Leaky ReLU slope
21
+
22
+ # ===== Dynamics and Distribution Parameters =====
23
+ factor_order: 2 # AR order for factors (p in AR(p))
24
+ innovation_distribution: laplace # Innovation distribution: 'laplace', 'gaussian', 'student_t'
25
+ decoder_var: 0.01 # Decoder variance (observation noise)
26
+
27
+ # ===== Training Parameters =====
28
+ learning_rate: 0.001 # Learning rate for optimizer
29
+ optimizer: Adam # Optimizer type: 'Adam', 'AdamW', 'SGD'
30
+ batch_size: 128 # Batch size for training (larger to reduce #batches/epoch)
31
+ max_epochs: 10 # Maximum training epochs
32
+ tolerance: 1.0e-5 # Convergence tolerance
33
+ seed: null # Random seed (None uses default)
34
+
35
+ # ===== Base Model Config (inherited) =====
36
+ frequency: null # iVDFM doesn't use mixed-frequency structure
37
+ clock: m # Monthly clock frequency
38
+ scaler: standard # Scaler for targets: 'standard', 'robust', 'minmax', 'maxabs', 'quantile', or null. Applied to targets only (not context/auxiliary variables)
@@ -0,0 +1,40 @@
1
+ # iVDFM Configuration for Macroeconomic Datasets
2
+ # Based on Korean economic indicators (KO* series)
3
+ # Data: 101 series, mixed weekly/monthly frequency (1985-04-05 to 2025-11-21)
4
+ # Clock: Weekly (w) - base frequency for latent factors
5
+ # Target: KOEQUIPTE (Investment, Equipment, Estimation, SA)
6
+
7
+ # ===== Model Structure =====
8
+ # Latent dimension
9
+ num_factors: 5
10
+ sequence_length: 200 # Sequence length for sliding windows
11
+ context: null # Column names (DataFrame) or indices (array) for context variables. If None, time-based context is generated.
12
+ context_dim: 1 # Dimension of context. Used when context is None (generates time-based context) or when context is multivariate.
13
+
14
+ # ===== Neural Network Architecture =====
15
+ encoder_hidden_dim: 200 # Encoder hidden dimension
16
+ encoder_n_layers: 3 # Number of encoder layers
17
+ decoder_hidden_dim: 200 # Decoder hidden dimension
18
+ decoder_n_layers: 3 # Number of decoder layers
19
+ prior_hidden_dim: 100 # Prior network hidden dimension
20
+ prior_n_layers: 2 # Number of prior network layers
21
+ activation: lrelu # Activation function: 'relu', 'lrelu', 'tanh', 'sigmoid'
22
+ slope: 0.1 # Leaky ReLU slope
23
+
24
+ # ===== Dynamics and Distribution Parameters =====
25
+ factor_order: 3 # AR order for factors (p in AR(p))
26
+ innovation_distribution: laplace # Innovation distribution: 'laplace', 'gaussian', 'student_t'
27
+ decoder_var: 0.01 # Decoder variance (observation noise)
28
+
29
+ # ===== Training Parameters =====
30
+ learning_rate: 0.001 # Learning rate for optimizer
31
+ optimizer: Adam # Optimizer type: 'Adam', 'AdamW', 'SGD'
32
+ batch_size: 256 # Batch size for training (larger to reduce #batches/epoch)
33
+ max_epochs: 10 # Maximum training epochs
34
+ tolerance: 1.0e-5 # Convergence tolerance
35
+ seed: null # Random seed (None uses default)
36
+
37
+ # ===== Base Model Config (inherited) =====
38
+ frequency: null # iVDFM doesn't use mixed-frequency structure
39
+ clock: w # Weekly clock frequency (base frequency for latent factors)
40
+ scaler: standard # Scaler for targets: 'standard', 'robust', 'minmax', 'maxabs', 'quantile', or null. Applied to targets only (not context/auxiliary variables)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "dfm-python"
3
- version = "0.6.13"
3
+ version = "0.6.14"
4
4
  description = "Dynamic Factor Model (DFM) estimation and forecasting in Python"
5
5
  requires-python = ">=3.10"
6
6
  license = {text = "MIT"}
@@ -344,6 +344,47 @@ COMPUTATION_ERROR_TYPES = (RuntimeError, ValueError, TypeError, AttributeError,
344
344
  DEFAULT_KDFM_AR_ORDER = 1 # Default AR order (VAR lag order p) for KDFM
345
345
  DEFAULT_KDFM_MA_ORDER = 0 # Default MA order (MA lag order q) for KDFM (0 = pure VAR)
346
346
 
347
+ # ============================================================================
348
+ # iVDFM Defaults
349
+ # ============================================================================
350
+
351
+ # iVDFM sequence and dimension defaults
352
+ DEFAULT_IVDFM_SEQUENCE_LENGTH = 100 # Default sequence length for sliding windows
353
+ DEFAULT_IVDFM_LATENT_DIM = 3 # Default number of factors
354
+ DEFAULT_IVDFM_AUX_DIM = 1 # Default auxiliary variable dimension
355
+
356
+ # iVDFM network architecture defaults
357
+ DEFAULT_IVDFM_ENCODER_HIDDEN_DIM = 200 # Default encoder hidden dimension
358
+ DEFAULT_IVDFM_ENCODER_N_LAYERS = 3 # Default encoder layers
359
+ DEFAULT_IVDFM_DECODER_HIDDEN_DIM = 200 # Default decoder hidden dimension
360
+ DEFAULT_IVDFM_DECODER_N_LAYERS = 3 # Default decoder layers
361
+ DEFAULT_IVDFM_PRIOR_HIDDEN_DIM = 100 # Default prior network hidden dimension
362
+ DEFAULT_IVDFM_PRIOR_N_LAYERS = 2 # Default prior network layers
363
+
364
+ # iVDFM dynamics and distribution defaults
365
+ DEFAULT_IVDFM_FACTOR_ORDER = 1 # Default AR order for factors
366
+ DEFAULT_IVDFM_INNOVATION_DIST = 'laplace' # Default innovation distribution
367
+ DEFAULT_IVDFM_DECODER_VAR = 0.01 # Default decoder variance
368
+ DEFAULT_IVDFM_ACTIVATION = 'lrelu' # Default activation function
369
+ DEFAULT_IVDFM_SLOPE = 0.1 # Default leaky ReLU slope
370
+
371
+ # iVDFM training defaults
372
+ DEFAULT_IVDFM_BATCH_SIZE = 32 # Default batch size
373
+ DEFAULT_IVDFM_MAX_EPOCHS = 100 # Default maximum epochs
374
+ DEFAULT_IVDFM_AUX_VARIABLE_TYPE = 'time' # Default auxiliary variable type
375
+
376
+ # iVDFM optimizer defaults
377
+ DEFAULT_IVDFM_OPTIMIZER_WEIGHT_DECAY = 0.0 # Default weight decay for optimizer
378
+ DEFAULT_IVDFM_OPTIMIZER_MOMENTUM = 0.9 # Default momentum for SGD
379
+
380
+ # iVDFM scheduler defaults
381
+ DEFAULT_IVDFM_SCHEDULER_TYPE = 'step' # Default scheduler type: 'step', 'plateau', 'cosine', 'exponential', None
382
+ DEFAULT_IVDFM_SCHEDULER_STEP_SIZE = None # Default step_size for StepLR (auto: max_epochs // 3)
383
+ DEFAULT_IVDFM_SCHEDULER_GAMMA = 0.5 # Default gamma for StepLR/ExponentialLR
384
+ DEFAULT_IVDFM_SCHEDULER_PATIENCE = 10 # Default patience for ReduceLROnPlateau
385
+ DEFAULT_IVDFM_SCHEDULER_FACTOR = 0.1 # Default factor for ReduceLROnPlateau
386
+ DEFAULT_IVDFM_SCHEDULER_MIN_LR = 0.0 # Default min_lr for ReduceLROnPlateau
387
+
347
388
  # ============================================================================
348
389
  # Tutorial Defaults
349
390
  # ============================================================================
@@ -564,6 +605,24 @@ __all__ = [
564
605
  # KDFM defaults
565
606
  'DEFAULT_KDFM_AR_ORDER',
566
607
  'DEFAULT_KDFM_MA_ORDER',
608
+ # iVDFM defaults
609
+ 'DEFAULT_IVDFM_SEQUENCE_LENGTH',
610
+ 'DEFAULT_IVDFM_LATENT_DIM',
611
+ 'DEFAULT_IVDFM_AUX_DIM',
612
+ 'DEFAULT_IVDFM_ENCODER_HIDDEN_DIM',
613
+ 'DEFAULT_IVDFM_ENCODER_N_LAYERS',
614
+ 'DEFAULT_IVDFM_DECODER_HIDDEN_DIM',
615
+ 'DEFAULT_IVDFM_DECODER_N_LAYERS',
616
+ 'DEFAULT_IVDFM_PRIOR_HIDDEN_DIM',
617
+ 'DEFAULT_IVDFM_PRIOR_N_LAYERS',
618
+ 'DEFAULT_IVDFM_FACTOR_ORDER',
619
+ 'DEFAULT_IVDFM_INNOVATION_DIST',
620
+ 'DEFAULT_IVDFM_DECODER_VAR',
621
+ 'DEFAULT_IVDFM_ACTIVATION',
622
+ 'DEFAULT_IVDFM_SLOPE',
623
+ 'DEFAULT_IVDFM_BATCH_SIZE',
624
+ 'DEFAULT_IVDFM_MAX_EPOCHS',
625
+ 'DEFAULT_IVDFM_AUX_VARIABLE_TYPE',
567
626
  # Tutorial defaults
568
627
  'TUTORIAL_MAX_PERIODS',
569
628
  'TUTORIAL_MAX_EPOCHS',
@@ -0,0 +1,19 @@
1
+ """Configuration schema package for DFM models.
2
+
3
+ This package contains:
4
+ - model.py: BaseModelConfig, DFMConfig, DDFMConfig - model configurations
5
+ - results.py: BaseResult, DFMResult, DDFMResult - result structures
6
+
7
+ Note: Series are specified via frequency dict mapping column names to frequencies.
8
+ """
9
+
10
+ from .model import BaseModelConfig, DFMConfig, DDFMConfig, iVDFMConfig
11
+ from .results import BaseResult, DFMResult, DDFMResult, iVDFMResult
12
+ from .params import DFMStateSpaceParams, DDFMStateSpaceParams, iVDFMModelState
13
+
14
+ __all__ = [
15
+ 'BaseModelConfig', 'DFMConfig', 'DDFMConfig', 'iVDFMConfig',
16
+ 'BaseResult', 'DFMResult', 'DDFMResult', 'iVDFMResult',
17
+ 'DFMStateSpaceParams', 'DDFMStateSpaceParams', 'iVDFMModelState',
18
+ ]
19
+
@@ -48,6 +48,14 @@ from ..constants import (
48
48
  DEFAULT_BATCH_SIZE,
49
49
  DEFAULT_DDFM_WINDOW_SIZE,
50
50
  DEFAULT_GRAD_CLIP_VAL,
51
+ DEFAULT_IVDFM_OPTIMIZER_WEIGHT_DECAY,
52
+ DEFAULT_IVDFM_OPTIMIZER_MOMENTUM,
53
+ DEFAULT_IVDFM_SCHEDULER_TYPE,
54
+ DEFAULT_IVDFM_SCHEDULER_STEP_SIZE,
55
+ DEFAULT_IVDFM_SCHEDULER_GAMMA,
56
+ DEFAULT_IVDFM_SCHEDULER_PATIENCE,
57
+ DEFAULT_IVDFM_SCHEDULER_FACTOR,
58
+ DEFAULT_IVDFM_SCHEDULER_MIN_LR,
51
59
  DEFAULT_REGULARIZATION_SCALE,
52
60
  DEFAULT_STRUCTURAL_REG_WEIGHT,
53
61
  DEFAULT_CONVERGENCE_THRESHOLD,
@@ -70,6 +78,23 @@ from ..constants import (
70
78
  DEFAULT_KDFM_MA_ORDER,
71
79
  FREQUENCY_HIERARCHY,
72
80
  DEFAULT_HIERARCHY_VALUE,
81
+ DEFAULT_IVDFM_SEQUENCE_LENGTH,
82
+ DEFAULT_IVDFM_LATENT_DIM,
83
+ DEFAULT_IVDFM_AUX_DIM,
84
+ DEFAULT_IVDFM_ENCODER_HIDDEN_DIM,
85
+ DEFAULT_IVDFM_ENCODER_N_LAYERS,
86
+ DEFAULT_IVDFM_DECODER_HIDDEN_DIM,
87
+ DEFAULT_IVDFM_DECODER_N_LAYERS,
88
+ DEFAULT_IVDFM_PRIOR_HIDDEN_DIM,
89
+ DEFAULT_IVDFM_PRIOR_N_LAYERS,
90
+ DEFAULT_IVDFM_FACTOR_ORDER,
91
+ DEFAULT_IVDFM_INNOVATION_DIST,
92
+ DEFAULT_IVDFM_DECODER_VAR,
93
+ DEFAULT_IVDFM_ACTIVATION,
94
+ DEFAULT_IVDFM_SLOPE,
95
+ DEFAULT_IVDFM_BATCH_SIZE,
96
+ DEFAULT_IVDFM_MAX_EPOCHS,
97
+ DEFAULT_IVDFM_AUX_VARIABLE_TYPE,
73
98
  )
74
99
 
75
100
 
@@ -136,6 +161,7 @@ class BaseModelConfig:
136
161
  # ========================================================================
137
162
  clock: str = 'm' # Required: Base frequency for latent factors (global clock): 'd', 'w', 'm', 'q', 'sa', 'a' (defaults to 'm' for monthly)
138
163
  target_scaler: Optional[ScalerType] = None # Fitted sklearn scaler instance (StandardScaler, RobustScaler, etc.) for target series only. Must be a fitted scaler object (call .fit() on target data first). Pass scaler object directly, not string. Feature series are assumed to be manually preprocessed. If None, target series are assumed to be already in the desired scale.
164
+ scaler: Optional[str] = None # Scaler type as string: 'standard', 'robust', 'minmax', 'maxabs', 'quantile', or null. Applied to targets only (not context/auxiliary variables). For iVDFM, this is the preferred way to specify scaler (like DDFM pattern).
139
165
 
140
166
  def __post_init__(self):
141
167
  """Validate basic model structure.
@@ -626,6 +652,244 @@ class DDFMConfig(BaseModelConfig):
626
652
  )
627
653
 
628
654
 
655
+ @dataclass
656
+ class iVDFMConfig(BaseModelConfig):
657
+ """Identifiable Variational Dynamic Factor Model configuration.
658
+
659
+ Uses 'scaler' (string) pattern like DDFM, not 'target_scaler' (instance).
660
+ Scaler is applied to targets only, not to context/auxiliary variables.
661
+ """
662
+ """Identifiable Variational Dynamic Factor Model configuration.
663
+
664
+ This configuration class extends BaseModelConfig with parameters specific
665
+ to iVDFM models trained using variational inference with identifiable
666
+ innovation priors.
667
+
668
+ Note: iVDFM does NOT use block structure. Use num_factors directly to specify
669
+ the number of factors.
670
+
671
+ The configuration can be built from:
672
+ - Main settings (training parameters) from config files
673
+ - Series definitions via frequency dict (column names -> frequencies)
674
+ """
675
+ # ========================================================================
676
+ # Model Structure
677
+ # ========================================================================
678
+ num_factors: Optional[int] = None # Number of factors (inferred from config if None)
679
+ sequence_length: int = DEFAULT_IVDFM_SEQUENCE_LENGTH # Sequence length for training
680
+ context: Optional[Union[List[str], List[int]]] = None # Column names (DataFrame) or indices (array) for context variables. If None, context_dim is used to generate time-based context.
681
+ context_dim: int = DEFAULT_IVDFM_AUX_DIM # Dimension of context. Used when context is None (generates time-based context) or when context is multivariate.
682
+
683
+ # ========================================================================
684
+ # Neural Network Architecture
685
+ # ========================================================================
686
+ encoder_hidden_dim: Union[int, List[int]] = DEFAULT_IVDFM_ENCODER_HIDDEN_DIM # Encoder architecture
687
+ encoder_n_layers: int = DEFAULT_IVDFM_ENCODER_N_LAYERS # Number of encoder layers
688
+ decoder_hidden_dim: Union[int, List[int]] = DEFAULT_IVDFM_DECODER_HIDDEN_DIM # Decoder architecture
689
+ decoder_n_layers: int = DEFAULT_IVDFM_DECODER_N_LAYERS # Number of decoder layers
690
+ prior_hidden_dim: Union[int, List[int]] = DEFAULT_IVDFM_PRIOR_HIDDEN_DIM # Prior network architecture
691
+ prior_n_layers: int = DEFAULT_IVDFM_PRIOR_N_LAYERS # Number of prior network layers
692
+ activation: str = DEFAULT_IVDFM_ACTIVATION # Activation function
693
+ slope: float = DEFAULT_IVDFM_SLOPE # Leaky ReLU slope
694
+
695
+ # ========================================================================
696
+ # Dynamics and Distribution Parameters
697
+ # ========================================================================
698
+ factor_order: int = DEFAULT_IVDFM_FACTOR_ORDER # AR order for factors
699
+ innovation_distribution: str = DEFAULT_IVDFM_INNOVATION_DIST # Innovation distribution type
700
+ decoder_var: float = DEFAULT_IVDFM_DECODER_VAR # Decoder variance
701
+
702
+ # ========================================================================
703
+ # Training Parameters
704
+ # ========================================================================
705
+ learning_rate: float = DEFAULT_LEARNING_RATE # Learning rate
706
+ optimizer: str = 'Adam' # Optimizer type
707
+ optimizer_weight_decay: float = DEFAULT_IVDFM_OPTIMIZER_WEIGHT_DECAY # Weight decay (L2 regularization)
708
+ optimizer_momentum: float = DEFAULT_IVDFM_OPTIMIZER_MOMENTUM # Momentum for SGD
709
+ batch_size: int = DEFAULT_IVDFM_BATCH_SIZE # Batch size
710
+ max_epochs: int = DEFAULT_IVDFM_MAX_EPOCHS # Maximum epochs
711
+ tolerance: float = DEFAULT_TOLERANCE # Convergence tolerance
712
+ seed: Optional[int] = None # Random seed
713
+
714
+ # ========================================================================
715
+ # Scheduler Parameters
716
+ # ========================================================================
717
+ scheduler_type: Optional[str] = DEFAULT_IVDFM_SCHEDULER_TYPE # Scheduler type: 'step', 'plateau', 'cosine', 'exponential', None
718
+ scheduler_step_size: Optional[int] = DEFAULT_IVDFM_SCHEDULER_STEP_SIZE # Step size for StepLR (None = auto: max_epochs // 3)
719
+ scheduler_gamma: float = DEFAULT_IVDFM_SCHEDULER_GAMMA # Gamma for StepLR/ExponentialLR
720
+ scheduler_patience: int = DEFAULT_IVDFM_SCHEDULER_PATIENCE # Patience for ReduceLROnPlateau
721
+ scheduler_factor: float = DEFAULT_IVDFM_SCHEDULER_FACTOR # Factor for ReduceLROnPlateau
722
+ scheduler_min_lr: float = DEFAULT_IVDFM_SCHEDULER_MIN_LR # Min learning rate for ReduceLROnPlateau
723
+
724
+ def __post_init__(self):
725
+ """Validate iVDFM configuration."""
726
+ super().__post_init__() # Validate base config
727
+
728
+ from ...utils.errors import ConfigurationError
729
+
730
+ # Validate sequence_length
731
+ if self.sequence_length < 1:
732
+ raise ConfigurationError(
733
+ f"sequence_length must be >= 1, got {self.sequence_length}"
734
+ )
735
+
736
+ # Validate context_dim
737
+ if self.context_dim < 1:
738
+ raise ConfigurationError(
739
+ f"context_dim must be >= 1, got {self.context_dim}"
740
+ )
741
+
742
+ # Validate num_factors if provided
743
+ if self.num_factors is not None and self.num_factors < 1:
744
+ raise ConfigurationError(
745
+ f"num_factors must be >= 1, got {self.num_factors}"
746
+ )
747
+
748
+ # Validate factor_order
749
+ if self.factor_order < 1:
750
+ raise ConfigurationError(
751
+ f"factor_order must be >= 1, got {self.factor_order}"
752
+ )
753
+
754
+ # Validate innovation_distribution
755
+ valid_dists = {'laplace', 'gaussian', 'student_t', 'gamma', 'beta', 'exponential'}
756
+ if self.innovation_distribution not in valid_dists:
757
+ raise ConfigurationError(
758
+ f"innovation_distribution must be one of {valid_dists}, got '{self.innovation_distribution}'"
759
+ )
760
+
761
+ # Validate activation
762
+ valid_activations = {'relu', 'lrelu', 'tanh', 'sigmoid'}
763
+ if self.activation not in valid_activations:
764
+ raise ConfigurationError(
765
+ f"activation must be one of {valid_activations}, got '{self.activation}'"
766
+ )
767
+
768
+ # Validate optimizer
769
+ from ..constants import VALID_OPTIMIZERS
770
+ if self.optimizer not in VALID_OPTIMIZERS:
771
+ raise ConfigurationError(
772
+ f"optimizer must be one of {VALID_OPTIMIZERS}, got '{self.optimizer}'"
773
+ )
774
+
775
+ # Validate scheduler_type
776
+ valid_schedulers = {'step', 'plateau', 'cosine', 'exponential', None}
777
+ if self.scheduler_type not in valid_schedulers:
778
+ raise ConfigurationError(
779
+ f"scheduler_type must be one of {valid_schedulers}, got '{self.scheduler_type}'"
780
+ )
781
+
782
+ # Validate scheduler parameters
783
+ if self.scheduler_gamma <= 0 or self.scheduler_gamma > 1:
784
+ raise ConfigurationError(
785
+ f"scheduler_gamma must be in (0, 1], got {self.scheduler_gamma}"
786
+ )
787
+
788
+ if self.scheduler_patience < 0:
789
+ raise ConfigurationError(
790
+ f"scheduler_patience must be >= 0, got {self.scheduler_patience}"
791
+ )
792
+
793
+ if self.scheduler_factor <= 0 or self.scheduler_factor > 1:
794
+ raise ConfigurationError(
795
+ f"scheduler_factor must be in (0, 1], got {self.scheduler_factor}"
796
+ )
797
+
798
+ if self.scheduler_min_lr < 0:
799
+ raise ConfigurationError(
800
+ f"scheduler_min_lr must be >= 0, got {self.scheduler_min_lr}"
801
+ )
802
+
803
+ @classmethod
804
+ def _extract_ivdfm(cls, data: Dict[str, Any]) -> Dict[str, Any]:
805
+ """Extract iVDFM-specific parameters from config dict."""
806
+ from ..constants import (
807
+ DEFAULT_IVDFM_SEQUENCE_LENGTH,
808
+ DEFAULT_IVDFM_LATENT_DIM,
809
+ DEFAULT_IVDFM_AUX_DIM,
810
+ DEFAULT_IVDFM_ENCODER_HIDDEN_DIM,
811
+ DEFAULT_IVDFM_ENCODER_N_LAYERS,
812
+ DEFAULT_IVDFM_DECODER_HIDDEN_DIM,
813
+ DEFAULT_IVDFM_DECODER_N_LAYERS,
814
+ DEFAULT_IVDFM_PRIOR_HIDDEN_DIM,
815
+ DEFAULT_IVDFM_PRIOR_N_LAYERS,
816
+ DEFAULT_IVDFM_FACTOR_ORDER,
817
+ DEFAULT_IVDFM_INNOVATION_DIST,
818
+ DEFAULT_IVDFM_DECODER_VAR,
819
+ DEFAULT_IVDFM_ACTIVATION,
820
+ DEFAULT_IVDFM_SLOPE,
821
+ DEFAULT_IVDFM_BATCH_SIZE,
822
+ DEFAULT_IVDFM_MAX_EPOCHS,
823
+ DEFAULT_IVDFM_AUX_VARIABLE_TYPE,
824
+ DEFAULT_IVDFM_OPTIMIZER_WEIGHT_DECAY,
825
+ DEFAULT_IVDFM_OPTIMIZER_MOMENTUM,
826
+ DEFAULT_IVDFM_SCHEDULER_TYPE,
827
+ DEFAULT_IVDFM_SCHEDULER_STEP_SIZE,
828
+ DEFAULT_IVDFM_SCHEDULER_GAMMA,
829
+ DEFAULT_IVDFM_SCHEDULER_PATIENCE,
830
+ DEFAULT_IVDFM_SCHEDULER_FACTOR,
831
+ DEFAULT_IVDFM_SCHEDULER_MIN_LR,
832
+ )
833
+
834
+ ivdfm_params = cls._extract_params(data, {
835
+ 'num_factors': None,
836
+ 'sequence_length': DEFAULT_IVDFM_SEQUENCE_LENGTH,
837
+ 'context': None,
838
+ 'context_dim': DEFAULT_IVDFM_AUX_DIM,
839
+ 'encoder_hidden_dim': DEFAULT_IVDFM_ENCODER_HIDDEN_DIM,
840
+ 'encoder_n_layers': DEFAULT_IVDFM_ENCODER_N_LAYERS,
841
+ 'decoder_hidden_dim': DEFAULT_IVDFM_DECODER_HIDDEN_DIM,
842
+ 'decoder_n_layers': DEFAULT_IVDFM_DECODER_N_LAYERS,
843
+ 'prior_hidden_dim': DEFAULT_IVDFM_PRIOR_HIDDEN_DIM,
844
+ 'prior_n_layers': DEFAULT_IVDFM_PRIOR_N_LAYERS,
845
+ 'activation': DEFAULT_IVDFM_ACTIVATION,
846
+ 'slope': DEFAULT_IVDFM_SLOPE,
847
+ 'factor_order': DEFAULT_IVDFM_FACTOR_ORDER,
848
+ 'innovation_distribution': DEFAULT_IVDFM_INNOVATION_DIST,
849
+ 'decoder_var': DEFAULT_IVDFM_DECODER_VAR,
850
+ 'learning_rate': DEFAULT_LEARNING_RATE,
851
+ 'optimizer': 'Adam',
852
+ 'optimizer_weight_decay': DEFAULT_IVDFM_OPTIMIZER_WEIGHT_DECAY,
853
+ 'optimizer_momentum': DEFAULT_IVDFM_OPTIMIZER_MOMENTUM,
854
+ 'batch_size': DEFAULT_IVDFM_BATCH_SIZE,
855
+ 'max_epochs': DEFAULT_IVDFM_MAX_EPOCHS,
856
+ 'tolerance': DEFAULT_TOLERANCE,
857
+ 'seed': None,
858
+ 'scheduler_type': DEFAULT_IVDFM_SCHEDULER_TYPE,
859
+ 'scheduler_step_size': DEFAULT_IVDFM_SCHEDULER_STEP_SIZE,
860
+ 'scheduler_gamma': DEFAULT_IVDFM_SCHEDULER_GAMMA,
861
+ 'scheduler_patience': DEFAULT_IVDFM_SCHEDULER_PATIENCE,
862
+ 'scheduler_factor': DEFAULT_IVDFM_SCHEDULER_FACTOR,
863
+ 'scheduler_min_lr': DEFAULT_IVDFM_SCHEDULER_MIN_LR,
864
+ 'scaler': None, # Scaler string: 'standard', 'robust', 'minmax', 'maxabs', 'quantile', or null
865
+ })
866
+
867
+ return ivdfm_params
868
+
869
+ @classmethod
870
+ def from_dict(cls, data: Dict[str, Any]) -> 'iVDFMConfig':
871
+ """Create iVDFMConfig from dictionary.
872
+
873
+ Parameters
874
+ ----------
875
+ data : Dict[str, Any]
876
+ Configuration dictionary
877
+
878
+ Returns
879
+ -------
880
+ iVDFMConfig
881
+ iVDFM configuration instance
882
+ """
883
+ # Extract base params
884
+ base_params = cls._extract_base(data)
885
+
886
+ # Extract iVDFM-specific params
887
+ ivdfm_params = cls._extract_ivdfm(data)
888
+
889
+ # Combine and create config
890
+ return cls(**base_params, **ivdfm_params)
891
+
892
+
629
893
  # ============================================================================
630
894
  # Validation Functions
631
895
  # ============================================================================