dfm-python 0.5.53__tar.gz → 0.5.54__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.
- {dfm_python-0.5.53 → dfm_python-0.5.54}/PKG-INFO +1 -1
- dfm_python-0.5.54/config/ddfm_macro.yaml +63 -0
- dfm_python-0.5.54/config/dfm_macro.yaml +84 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/pyproject.toml +1 -1
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/__init__.py +3 -3
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/config/adapter.py +17 -1
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/config/constants.py +97 -11
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/config/schema/model.py +125 -59
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/config/schema/results.py +101 -1
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/config/types.py +19 -4
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/datamodule/base.py +61 -55
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/datamodule/ddfm_dm.py +34 -49
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/datamodule/dfm_dm.py +55 -28
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/datamodule/kdfm_dm.py +9 -8
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/dataset/process.py +63 -64
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/decoder/mlp.py +12 -5
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/encoder/pca.py +15 -17
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/encoder/simple_encoder.py +80 -37
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/functional/dfm_block.py +9 -8
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/functional/em.py +211 -78
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/functional/irf.py +25 -17
- dfm_python-0.5.54/src/dfm_python/models/base.py +594 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/models/ddfm.py +273 -270
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/models/dfm.py +291 -196
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/models/kdfm.py +344 -224
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/numeric/builder.py +38 -82
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/numeric/estimator.py +73 -299
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/numeric/stability.py +128 -72
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/numeric/tent.py +8 -3
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/numeric/validator.py +81 -34
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/ssm/companion.py +37 -24
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/ssm/kalman.py +11 -9
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/ssm/structural.py +1 -1
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/trainer/__init__.py +12 -9
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/trainer/ddfm.py +77 -67
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/trainer/dfm.py +4 -3
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/trainer/kdfm.py +5 -4
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/utils/__init__.py +3 -4
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/utils/common.py +96 -10
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/utils/helper.py +32 -12
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/utils/metric.py +14 -8
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/utils/misc.py +6 -43
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/utils/tensor_utils.py +14 -7
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/utils/validation.py +32 -3
- dfm_python-0.5.54/src/test/config/schema/test_block.py +26 -0
- dfm_python-0.5.54/src/test/config/schema/test_model.py +22 -0
- dfm_python-0.5.54/src/test/config/schema/test_results.py +193 -0
- dfm_python-0.5.54/src/test/config/test_adapter.py +90 -0
- dfm_python-0.5.54/src/test/config/test_constants.py +158 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/config/test_types.py +16 -17
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/conftest.py +5 -5
- dfm_python-0.5.54/src/test/datamodule/test_base.py +109 -0
- dfm_python-0.5.54/src/test/datamodule/test_ddfm_dm.py +27 -0
- dfm_python-0.5.54/src/test/datamodule/test_dfm_dm.py +26 -0
- dfm_python-0.5.54/src/test/datamodule/test_kdfm_dm.py +27 -0
- dfm_python-0.5.54/src/test/dataset/test_dataloader.py +20 -0
- dfm_python-0.5.54/src/test/dataset/test_dataset.py +53 -0
- dfm_python-0.5.54/src/test/dataset/test_process.py +112 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/decoder/test_linear.py +13 -5
- dfm_python-0.5.54/src/test/encoder/test_base.py +44 -0
- dfm_python-0.5.54/src/test/encoder/test_pca.py +100 -0
- dfm_python-0.5.54/src/test/encoder/test_simple_encoder.py +207 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/encoder/test_variational_encoder.py +6 -4
- dfm_python-0.5.54/src/test/functional/test_dfm_block.py +222 -0
- dfm_python-0.5.54/src/test/functional/test_em.py +57 -0
- dfm_python-0.5.54/src/test/functional/test_irf.py +132 -0
- dfm_python-0.5.54/src/test/functional/test_krylov.py +39 -0
- dfm_python-0.5.54/src/test/logger/test_inference_logger.py +18 -0
- dfm_python-0.5.54/src/test/logger/test_logger.py +28 -0
- dfm_python-0.5.54/src/test/logger/test_train_logger.py +18 -0
- dfm_python-0.5.54/src/test/models/test_base.py +384 -0
- dfm_python-0.5.54/src/test/models/test_ddfm.py +232 -0
- dfm_python-0.5.54/src/test/models/test_dfm.py +147 -0
- dfm_python-0.5.54/src/test/models/test_kdfm.py +411 -0
- dfm_python-0.5.54/src/test/numeric/test_builder.py +26 -0
- dfm_python-0.5.54/src/test/numeric/test_estimator.py +65 -0
- dfm_python-0.5.54/src/test/numeric/test_stability.py +392 -0
- dfm_python-0.5.54/src/test/numeric/test_tent.py +69 -0
- dfm_python-0.5.54/src/test/numeric/test_validator.py +279 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/ssm/test_arma.py +5 -3
- dfm_python-0.5.54/src/test/ssm/test_companion.py +103 -0
- dfm_python-0.5.54/src/test/ssm/test_kalman.py +116 -0
- dfm_python-0.5.54/src/test/ssm/test_structural.py +67 -0
- dfm_python-0.5.54/src/test/trainer/test_ddfm.py +34 -0
- dfm_python-0.5.54/src/test/trainer/test_dfm.py +39 -0
- dfm_python-0.5.54/src/test/trainer/test_kdfm.py +39 -0
- dfm_python-0.5.54/src/test/utils/test_common.py +321 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/utils/test_errors.py +7 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/utils/test_helper.py +80 -5
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/utils/test_metric.py +6 -5
- dfm_python-0.5.54/src/test/utils/test_misc.py +74 -0
- dfm_python-0.5.54/src/test/utils/test_tensor_utils.py +175 -0
- dfm_python-0.5.54/src/test/utils/test_validation.py +137 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/tutorial/tutorial_finance_ddfm.py +59 -72
- {dfm_python-0.5.53 → dfm_python-0.5.54}/tutorial/tutorial_finance_dfm.py +74 -79
- {dfm_python-0.5.53 → dfm_python-0.5.54}/tutorial/tutorial_finance_kdfm.py +62 -64
- {dfm_python-0.5.53 → dfm_python-0.5.54}/tutorial/tutorial_macro_ddfm.py +58 -82
- dfm_python-0.5.54/tutorial/tutorial_macro_dfm.py +306 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/tutorial/tutorial_macro_kdfm.py +59 -85
- dfm_python-0.5.53/config/ddfm_macro.yaml +0 -0
- dfm_python-0.5.53/config/dfm_macro.yaml +0 -80
- dfm_python-0.5.53/src/dfm_python/models/base.py +0 -835
- dfm_python-0.5.53/src/test/config/schema/test_block.py +0 -13
- dfm_python-0.5.53/src/test/config/schema/test_model.py +0 -13
- dfm_python-0.5.53/src/test/config/schema/test_results.py +0 -38
- dfm_python-0.5.53/src/test/config/test_adapter.py +0 -42
- dfm_python-0.5.53/src/test/config/test_constants.py +0 -30
- dfm_python-0.5.53/src/test/datamodule/test_base.py +0 -30
- dfm_python-0.5.53/src/test/datamodule/test_ddfm_dm.py +0 -19
- dfm_python-0.5.53/src/test/datamodule/test_dfm_dm.py +0 -19
- dfm_python-0.5.53/src/test/datamodule/test_kdfm_dm.py +0 -19
- dfm_python-0.5.53/src/test/dataset/test_dataloader.py +0 -13
- dfm_python-0.5.53/src/test/dataset/test_dataset.py +0 -33
- dfm_python-0.5.53/src/test/dataset/test_process.py +0 -35
- dfm_python-0.5.53/src/test/encoder/test_base.py +0 -15
- dfm_python-0.5.53/src/test/encoder/test_pca.py +0 -25
- dfm_python-0.5.53/src/test/encoder/test_simple_encoder.py +0 -38
- dfm_python-0.5.53/src/test/functional/test_dfm_block.py +0 -19
- dfm_python-0.5.53/src/test/functional/test_em.py +0 -30
- dfm_python-0.5.53/src/test/functional/test_irf.py +0 -25
- dfm_python-0.5.53/src/test/functional/test_krylov.py +0 -15
- dfm_python-0.5.53/src/test/logger/test_inference_logger.py +0 -13
- dfm_python-0.5.53/src/test/logger/test_logger.py +0 -19
- dfm_python-0.5.53/src/test/logger/test_train_logger.py +0 -13
- dfm_python-0.5.53/src/test/models/test_base.py +0 -20
- dfm_python-0.5.53/src/test/models/test_ddfm.py +0 -25
- dfm_python-0.5.53/src/test/models/test_dfm.py +0 -36
- dfm_python-0.5.53/src/test/models/test_kdfm.py +0 -24
- dfm_python-0.5.53/src/test/numeric/test_builder.py +0 -14
- dfm_python-0.5.53/src/test/numeric/test_estimator.py +0 -14
- dfm_python-0.5.53/src/test/numeric/test_stability.py +0 -20
- dfm_python-0.5.53/src/test/numeric/test_tent.py +0 -20
- dfm_python-0.5.53/src/test/numeric/test_validator.py +0 -20
- dfm_python-0.5.53/src/test/ssm/test_companion.py +0 -20
- dfm_python-0.5.53/src/test/ssm/test_kalman.py +0 -39
- dfm_python-0.5.53/src/test/ssm/test_structural.py +0 -20
- dfm_python-0.5.53/src/test/trainer/test_ddfm.py +0 -23
- dfm_python-0.5.53/src/test/trainer/test_dfm.py +0 -19
- dfm_python-0.5.53/src/test/trainer/test_kdfm.py +0 -19
- dfm_python-0.5.53/src/test/utils/test_common.py +0 -13
- dfm_python-0.5.53/src/test/utils/test_misc.py +0 -29
- dfm_python-0.5.53/src/test/utils/test_tensor_utils.py +0 -20
- dfm_python-0.5.53/src/test/utils/test_validation.py +0 -19
- dfm_python-0.5.53/trash/analytic.py +0 -506
- dfm_python-0.5.53/trash/data_utils.py +0 -81
- dfm_python-0.5.53/trash/missing.py +0 -150
- dfm_python-0.5.53/tutorial/tutorial_macro_dfm.py +0 -323
- {dfm_python-0.5.53 → dfm_python-0.5.54}/.git +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/.gitignore +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/.python-version +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/LICENSE +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/MANIFEST.in +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/README.md +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/config/ddfm_finance.yaml +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/config/dfm_finance.yaml +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/data/finance.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/data/macro.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_10/checkpoints/ddfm-epoch=00-train_loss=0.6495.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_10/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_11/checkpoints/ddfm-epoch=00-train_loss=0.8428.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_11/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_12/checkpoints/ddfm-epoch=00-train_loss=0.8959.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_12/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_13/checkpoints/ddfm-epoch=00-train_loss=0.7644.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_13/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_14/checkpoints/ddfm-epoch=00-train_loss=0.7935.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_14/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_15/checkpoints/ddfm-epoch=00-train_loss=0.6240.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_15/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_16/checkpoints/ddfm-epoch=00-train_loss=0.9689.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_16/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_17/checkpoints/ddfm-epoch=00-train_loss=0.9336.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_17/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_18/checkpoints/ddfm-epoch=00-train_loss=0.8481.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_18/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_19/checkpoints/ddfm-epoch=00-train_loss=0.6991.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_19/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_20/checkpoints/ddfm-epoch=00-train_loss=0.9289.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_20/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_21/checkpoints/ddfm-epoch=00-train_loss=0.8253.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_21/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_22/checkpoints/ddfm-epoch=00-train_loss=0.8933.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_22/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_5/checkpoints/ddfm-epoch=00-train_loss=0.8292.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_5/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_7/checkpoints/ddfm-epoch=00-train_loss=0.8216.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_7/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_8/checkpoints/ddfm-epoch=00-train_loss=0.6088.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_8/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_9/checkpoints/ddfm-epoch=00-train_loss=0.6595.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/ddfm/version_9/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_0/checkpoints/kdfm-epoch=01-train_loss=9750156656246784.0000.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_0/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_1/checkpoints/kdfm-epoch=00-train_loss=inf.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_1/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_10/checkpoints/kdfm-epoch=01-train_loss=0.2948.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_10/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_11/checkpoints/kdfm-epoch=01-train_loss=0.2337.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_11/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_12/checkpoints/kdfm-epoch=01-train_loss=0.2372.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_12/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_13/checkpoints/kdfm-epoch=01-train_loss=0.3323.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_13/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_14/checkpoints/kdfm-epoch=01-train_loss=0.0895.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_14/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_2/checkpoints/kdfm-epoch=00-train_loss=11076925440424673280.0000.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_2/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_3/checkpoints/kdfm-epoch=01-train_loss=3466010845203398656.0000.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_3/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_4/checkpoints/kdfm-epoch=01-train_loss=89213903044608.0000.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_4/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_5/checkpoints/kdfm-epoch=01-train_loss=1842788085222342656.0000.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_5/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_6/checkpoints/kdfm-epoch=00-train_loss=28594968117244854272.0000.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_6/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_7/checkpoints/kdfm-epoch=00-train_loss=inf.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_7/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_8/checkpoints/kdfm-epoch=01-train_loss=457264.4062.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_8/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_9/checkpoints/kdfm-epoch=01-train_loss=0.3095.ckpt +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/lightning_logs/trainer/version_9/metrics.csv +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/config/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/config/schema/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/config/schema/block.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/datamodule/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/dataset/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/dataset/dataloader.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/dataset/dataset.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/decoder/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/decoder/linear.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/encoder/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/encoder/base.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/encoder/variational_encoder.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/functional/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/functional/krylov.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/logger/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/logger/inference_logger.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/logger/logger.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/logger/train_logger.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/models/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/ssm/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/ssm/arma.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/dfm_python/utils/errors.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/config/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/config/schema/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/datamodule/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/dataset/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/decoder/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/decoder/test_mlp.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/encoder/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/functional/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/logger/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/models/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/numeric/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/ssm/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/trainer/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/src/test/utils/__init__.py +0 -0
- {dfm_python-0.5.53 → dfm_python-0.5.54}/uv.lock +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dfm-python
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.54
|
|
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
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# DDFM 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
|
+
# Neural Network Architecture
|
|
8
|
+
encoder_layers:
|
|
9
|
+
- 64
|
|
10
|
+
- 32
|
|
11
|
+
num_factors: 2 # Number of factors (DDFM does not use block structure)
|
|
12
|
+
activation: relu # Activation function: 'tanh', 'relu', 'sigmoid'
|
|
13
|
+
use_batch_norm: true
|
|
14
|
+
|
|
15
|
+
# Training Parameters
|
|
16
|
+
learning_rate: 0.001
|
|
17
|
+
epochs: 100
|
|
18
|
+
batch_size: 100 # DDFM-specific default batch size
|
|
19
|
+
factor_order: 1 # VAR lag order for factor dynamics (1 or 2)
|
|
20
|
+
|
|
21
|
+
# Idiosyncratic Components
|
|
22
|
+
use_idiosyncratic: true
|
|
23
|
+
min_obs_idio: 5 # Minimum observations for idio AR(1) estimation
|
|
24
|
+
|
|
25
|
+
# MCMC/Iterative Parameters
|
|
26
|
+
max_iter: 200 # Maximum MCMC iterations for iterative factor extraction
|
|
27
|
+
tolerance: 0.0005 # Convergence tolerance for MCMC iterations
|
|
28
|
+
disp: 10 # Display frequency for training progress
|
|
29
|
+
|
|
30
|
+
# Data Handling
|
|
31
|
+
clock: w # Weekly clock frequency (base frequency for latent factors)
|
|
32
|
+
target_scaler: standard # Scaler for target series only: 'standard', 'robust', 'minmax', 'maxabs', 'quantile', or null (no scaling)
|
|
33
|
+
# Note: nan_method and nan_k are internal constants (not user-configurable)
|
|
34
|
+
|
|
35
|
+
# Frequency mapping for mixed-frequency macro data
|
|
36
|
+
# Clock is weekly (w), so monthly series are slower frequency
|
|
37
|
+
# All frequencies must be explicitly specified
|
|
38
|
+
# Reduced set for faster testing (~50% reduction: 12 monthly series kept from original ~24)
|
|
39
|
+
frequency:
|
|
40
|
+
# Monthly series (slower than weekly clock) - typically end-of-month observations
|
|
41
|
+
# Essential series for testing
|
|
42
|
+
KOEMPTOTO: m # Total employment (monthly)
|
|
43
|
+
KOHWRWEMP: m # Hours worked (monthly)
|
|
44
|
+
KOIMPCONA: m # Investment, Construction (monthly)
|
|
45
|
+
KOWRCCNSE: m # Consumption (monthly)
|
|
46
|
+
KOCONPRCF: m # Production (monthly)
|
|
47
|
+
KOCPCOREF: m # Consumer prices (monthly)
|
|
48
|
+
KOCPEXFEF: m # Export prices (monthly)
|
|
49
|
+
KOCREU..A: m # Credit (monthly)
|
|
50
|
+
KOLRLTHH: m # Interest rates (monthly)
|
|
51
|
+
KOBSIHAPR: m # Business survey (monthly)
|
|
52
|
+
KOCNFCONR: m # Confidence (monthly)
|
|
53
|
+
# Target series
|
|
54
|
+
KOEQUIPTE: m # Investment, Equipment (monthly, target series)
|
|
55
|
+
# Weekly series (same as clock frequency)
|
|
56
|
+
KORFBEV: w # Retail, Food & Beverages (weekly)
|
|
57
|
+
KORWHLS: w # Retail, Wholesale (weekly)
|
|
58
|
+
KORMCMP: w # Retail, Miscellaneous & Comparison (weekly)
|
|
59
|
+
KORELEC: w # Retail, Electronics (weekly)
|
|
60
|
+
KORCNST: w # Retail, Construction (weekly)
|
|
61
|
+
KORMACH: w # Retail, Machinery (weekly)
|
|
62
|
+
KOROCOINF: w # Retail, Other Consumer & Information (weekly)
|
|
63
|
+
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# DFM 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
|
+
# EM Algorithm Parameters
|
|
8
|
+
ar_lag: 1 # Global AR lag order (applies to all blocks)
|
|
9
|
+
threshold: 1.0e-05 # EM convergence threshold
|
|
10
|
+
max_iter: 5000 # Maximum EM iterations
|
|
11
|
+
|
|
12
|
+
# Numerical Stability Parameters
|
|
13
|
+
clip_ar_coefficients: true
|
|
14
|
+
ar_clip_min: -0.99
|
|
15
|
+
ar_clip_max: 0.99
|
|
16
|
+
use_regularization: true
|
|
17
|
+
regularization_scale: 1.0e-05
|
|
18
|
+
|
|
19
|
+
# Idiosyncratic Component Parameters
|
|
20
|
+
augment_idio: true
|
|
21
|
+
augment_idio_slow: true # Important for mixed-frequency macro data (weekly clock, monthly indicators)
|
|
22
|
+
idio_rho0: 0.1
|
|
23
|
+
idio_min_var: 1.0e-08
|
|
24
|
+
|
|
25
|
+
# Data Handling
|
|
26
|
+
clock: w # Weekly clock frequency (base frequency for latent factors)
|
|
27
|
+
# target_scaler: Pass sklearn scaler object directly (e.g., StandardScaler(), RobustScaler())
|
|
28
|
+
# Example in Python:
|
|
29
|
+
# from sklearn.preprocessing import StandardScaler
|
|
30
|
+
# config.target_scaler = StandardScaler()
|
|
31
|
+
# Note: nan_method and nan_k are internal constants (not user-configurable)
|
|
32
|
+
|
|
33
|
+
# Block Structure for Macroeconomic Data
|
|
34
|
+
# Simplified for faster testing - reduced to 2 blocks with essential series
|
|
35
|
+
# Series can appear in multiple blocks to capture different factor structures
|
|
36
|
+
blocks:
|
|
37
|
+
Block_Real:
|
|
38
|
+
num_factors: 2 # Real economy factors (production, employment, consumption, investment)
|
|
39
|
+
series:
|
|
40
|
+
- KOCONPRCF # Production
|
|
41
|
+
- KOEMPTOTO # Total employment
|
|
42
|
+
- KOHWRWEMP # Hours worked
|
|
43
|
+
- KOWRCCNSE # Consumption
|
|
44
|
+
- KOIMPCONA # Investment
|
|
45
|
+
Block_Prices_Financial:
|
|
46
|
+
num_factors: 2 # Price, financial, and survey factors (combined for testing)
|
|
47
|
+
series:
|
|
48
|
+
- KOCPCOREF # Consumer prices
|
|
49
|
+
- KOCPEXFEF # Export prices
|
|
50
|
+
- KOWRCCNSE # Consumption (overlap with Block_Real)
|
|
51
|
+
- KOCREU..A # Credit
|
|
52
|
+
- KOLRLTHH # Interest rates
|
|
53
|
+
- KOBSIHAPR # Business survey
|
|
54
|
+
- KOCNFCONR # Confidence
|
|
55
|
+
|
|
56
|
+
# Frequency mapping for mixed-frequency macro data
|
|
57
|
+
# Clock is weekly (w), so monthly series are slower frequency
|
|
58
|
+
# All frequencies must be explicitly specified
|
|
59
|
+
# Reduced set for faster testing (~50% reduction: 18 monthly series kept from original ~36)
|
|
60
|
+
frequency:
|
|
61
|
+
# Monthly series (slower than weekly clock) - typically end-of-month observations
|
|
62
|
+
# Block_Real series
|
|
63
|
+
KOEMPTOTO: m # Total employment (monthly)
|
|
64
|
+
KOHWRWEMP: m # Hours worked (monthly)
|
|
65
|
+
KOIMPCONA: m # Investment, Construction (monthly)
|
|
66
|
+
KOWRCCNSE: m # Consumption (monthly)
|
|
67
|
+
KOCONPRCF: m # Production (monthly)
|
|
68
|
+
# Block_Prices_Financial series
|
|
69
|
+
KOCPCOREF: m # Consumer prices (monthly)
|
|
70
|
+
KOCPEXFEF: m # Export prices (monthly)
|
|
71
|
+
KOCREU..A: m # Credit (monthly)
|
|
72
|
+
KOLRLTHH: m # Interest rates (monthly)
|
|
73
|
+
KOBSIHAPR: m # Business survey (monthly)
|
|
74
|
+
KOCNFCONR: m # Confidence (monthly)
|
|
75
|
+
# Target series
|
|
76
|
+
KOEQUIPTE: m # Investment, Equipment (monthly, target series)
|
|
77
|
+
# Weekly series (same as clock frequency)
|
|
78
|
+
KORFBEV: w # Retail, Food & Beverages (weekly)
|
|
79
|
+
KORWHLS: w # Retail, Wholesale (weekly)
|
|
80
|
+
KORMCMP: w # Retail, Miscellaneous & Comparison (weekly)
|
|
81
|
+
KORELEC: w # Retail, Electronics (weekly)
|
|
82
|
+
KORCNST: w # Retail, Construction (weekly)
|
|
83
|
+
KORMACH: w # Retail, Machinery (weekly)
|
|
84
|
+
KOROCOINF: w # Retail, Other Consumer & Information (weekly)
|
|
@@ -40,7 +40,7 @@ Example (Standard Lightning Pattern):
|
|
|
40
40
|
>>> model.load_config('config/default.yaml')
|
|
41
41
|
>>>
|
|
42
42
|
>>> # Step 4: Create trainer and fit (standard Lightning pattern)
|
|
43
|
-
>>> trainer = DFMTrainer(max_epochs=100)
|
|
43
|
+
>>> trainer = DFMTrainer(max_epochs=100) # DEFAULT_MAX_EPOCHS
|
|
44
44
|
>>> trainer.fit(model, dm)
|
|
45
45
|
>>>
|
|
46
46
|
>>> # Step 5: Predict
|
|
@@ -55,7 +55,7 @@ Example (Standard Lightning Pattern):
|
|
|
55
55
|
>>> ddfm_model = DDFM(encoder_layers=[64, 32], num_factors=2)
|
|
56
56
|
>>> ddfm_model.load_config('config/default.yaml')
|
|
57
57
|
>>>
|
|
58
|
-
>>> trainer_ddfm = DDFMTrainer(max_epochs=100)
|
|
58
|
+
>>> trainer_ddfm = DDFMTrainer(max_epochs=100) # DEFAULT_MAX_EPOCHS
|
|
59
59
|
>>> trainer_ddfm.fit(ddfm_model, dm_ddfm)
|
|
60
60
|
>>> Xf, Zf = ddfm_model.predict(horizon=6)
|
|
61
61
|
|
|
@@ -65,7 +65,7 @@ Note: DFMConfig uses frequency dict to specify series (column names -> frequenci
|
|
|
65
65
|
For detailed documentation, see the README.md file and the tutorial notebooks/scripts.
|
|
66
66
|
"""
|
|
67
67
|
|
|
68
|
-
__version__ = "0.5.
|
|
68
|
+
__version__ = "0.5.54"
|
|
69
69
|
|
|
70
70
|
# ============================================================================
|
|
71
71
|
# PUBLIC API DEFINITION
|
|
@@ -28,7 +28,7 @@ from .constants import DEFAULT_CLOCK_FREQUENCY
|
|
|
28
28
|
# Error helper to reduce repetitive imports
|
|
29
29
|
def _get_config_error():
|
|
30
30
|
"""Get ConfigurationError (lazy import to avoid circular dependencies)."""
|
|
31
|
-
from
|
|
31
|
+
from dfm_python.utils.errors import ConfigurationError
|
|
32
32
|
return ConfigurationError
|
|
33
33
|
|
|
34
34
|
|
|
@@ -58,6 +58,22 @@ def _raise_config_error(message: str, details: Optional[str] = None) -> NoReturn
|
|
|
58
58
|
# Helper Functions for Config Parsing
|
|
59
59
|
# ============================================================================
|
|
60
60
|
|
|
61
|
+
def _is_dict_like(obj: Any) -> bool:
|
|
62
|
+
"""Check if object is dict-like (dict, OrderedDict, etc.).
|
|
63
|
+
|
|
64
|
+
Parameters
|
|
65
|
+
----------
|
|
66
|
+
obj : Any
|
|
67
|
+
Object to check
|
|
68
|
+
|
|
69
|
+
Returns
|
|
70
|
+
-------
|
|
71
|
+
bool
|
|
72
|
+
True if object is dict-like, False otherwise
|
|
73
|
+
"""
|
|
74
|
+
return isinstance(obj, dict) or hasattr(obj, 'keys') and hasattr(obj, '__getitem__')
|
|
75
|
+
|
|
76
|
+
|
|
61
77
|
def _convert_series_to_frequency_dict(
|
|
62
78
|
series_data: Any,
|
|
63
79
|
default_clock: str = DEFAULT_CLOCK_FREQUENCY
|
|
@@ -28,10 +28,15 @@ MIN_DIAGONAL_VARIANCE = 1e-8 # Minimum variance for diagonal elements
|
|
|
28
28
|
MIN_OBSERVATION_NOISE = 1e-4 # Minimum observation noise for measurement error (used in EM updates)
|
|
29
29
|
MIN_FACTOR_VARIANCE = 1e-10 # Minimum variance for factors
|
|
30
30
|
MIN_STD = 1e-8 # Minimum standard deviation
|
|
31
|
+
DEFAULT_VARIANCE_FALLBACK = 1.0 # Default variance fallback value for numerical stability
|
|
31
32
|
|
|
32
33
|
# Maximum eigenvalues
|
|
33
34
|
MAX_EIGENVALUE = 1e6 # Maximum eigenvalue cap
|
|
34
35
|
|
|
36
|
+
# Eigenvalue stability thresholds
|
|
37
|
+
DEFAULT_EIGENVALUE_MAX_MAGNITUDE = 1.0 # Default maximum eigenvalue magnitude for stability checks
|
|
38
|
+
DEFAULT_EIGENVALUE_WARN_THRESHOLD = 0.99 # Default warning threshold for near-unstable eigenvalues
|
|
39
|
+
|
|
35
40
|
# Matrix cleaning defaults
|
|
36
41
|
DEFAULT_CLEAN_NAN = 0.0 # Default value for NaN replacement in clean_matrix
|
|
37
42
|
DEFAULT_CLEAN_INF = MAX_EIGENVALUE # Default value for Inf replacement in clean_matrix (uses MAX_EIGENVALUE)
|
|
@@ -39,6 +44,12 @@ DEFAULT_CLEAN_INF = MAX_EIGENVALUE # Default value for Inf replacement in clean
|
|
|
39
44
|
# Identity matrix defaults
|
|
40
45
|
DEFAULT_IDENTITY_SCALE = 1.0 # Default scale for create_scaled_identity(n, 1.0)
|
|
41
46
|
DEFAULT_ZERO_VALUE = 0.0 # Default zero value for explicit zero assignments
|
|
47
|
+
DEFAULT_XAVIER_GAIN = 1.0 # Default gain for Xavier initialization
|
|
48
|
+
DEFAULT_OUTPUT_LAYER_GAIN = 0.1 # Default gain for output layer Xavier initialization (smaller for stability)
|
|
49
|
+
|
|
50
|
+
# Companion matrix initialization defaults
|
|
51
|
+
DEFAULT_INIT_SCALE = 0.01 # Default initialization scale for companion matrix B and C matrices
|
|
52
|
+
DEFAULT_KERNEL_INIT_SCALE = 0.1 # Default initialization scale for companion matrix coefficient matrices
|
|
42
53
|
|
|
43
54
|
# Regularization scales
|
|
44
55
|
DEFAULT_REGULARIZATION_SCALE = 1e-5 # Default ridge regularization scale
|
|
@@ -57,7 +68,6 @@ DEFAULT_MAX_ITER = 100 # Default maximum EM iterations (general)
|
|
|
57
68
|
DEFAULT_EM_MAX_ITER = 5000 # Default maximum EM iterations (DFM-specific)
|
|
58
69
|
DEFAULT_MAX_EPOCHS = 100 # Default maximum training epochs
|
|
59
70
|
DEFAULT_MAX_MCMC_ITER = 200 # Default maximum MCMC iterations
|
|
60
|
-
DEFAULT_EPOCHS_PER_ITER = 10 # Default epochs per MCMC iteration
|
|
61
71
|
|
|
62
72
|
# Batch size defaults
|
|
63
73
|
DEFAULT_BATCH_SIZE = 32 # Default batch size for neural networks
|
|
@@ -78,6 +88,10 @@ DEFAULT_LR_DECAY_RATE = 0.96 # Default exponential decay rate for learning rate
|
|
|
78
88
|
|
|
79
89
|
# Loss function defaults
|
|
80
90
|
DEFAULT_HUBER_DELTA = 1.0 # Default delta parameter for Huber loss
|
|
91
|
+
HUBER_QUADRATIC_COEFF = 0.5 # Quadratic coefficient for Huber loss (0.5 * a^2 term)
|
|
92
|
+
|
|
93
|
+
# Matrix computation defaults
|
|
94
|
+
SYMMETRY_AVERAGE_FACTOR = 0.5 # Averaging factor for symmetric matrix computation (0.5 * (M + M.T))
|
|
81
95
|
|
|
82
96
|
# Data clipping defaults
|
|
83
97
|
DEFAULT_DDFM_CLIP_RANGE_DEEP = 8.0 # Clipping range for deep networks (>2 layers)
|
|
@@ -86,11 +100,15 @@ DEFAULT_DDFM_CLIP_RANGE_SHALLOW = 10.0 # Clipping range for shallow networks (<
|
|
|
86
100
|
# Numerical stability for division
|
|
87
101
|
DEFAULT_EPSILON = 1e-8 # Default epsilon for division operations to prevent division by zero
|
|
88
102
|
|
|
103
|
+
# Random seed defaults
|
|
104
|
+
DEFAULT_SEED = 3 # Default random seed for reproducibility
|
|
105
|
+
|
|
89
106
|
# Structural identification defaults
|
|
90
107
|
DEFAULT_STRUCTURAL_REG_WEIGHT = 0.1 # Default weight for structural regularization loss
|
|
91
108
|
DEFAULT_STRUCTURAL_INIT_SCALE = 0.1 # Default initialization scale for structural matrices
|
|
92
109
|
DEFAULT_STRUCTURAL_DIAG_SCALE = 1.0 # Default diagonal scale for structural matrices (FIXED Iteration 7: was 0.1, caused near-singular S)
|
|
93
110
|
DEFAULT_CHOLESKY_EPS = 1e-6 # Default epsilon for Cholesky decomposition stability
|
|
111
|
+
CHOLESKY_LOG_DET_FACTOR = 2.0 # Factor for log determinant computation from Cholesky decomposition (log det = 2.0 * sum(log(diag(L))))
|
|
94
112
|
|
|
95
113
|
# ============================================================================
|
|
96
114
|
# Network Architecture Defaults
|
|
@@ -112,17 +130,27 @@ DEFAULT_START_DATE = datetime(2000, 1, 1)
|
|
|
112
130
|
|
|
113
131
|
# Default window size for DDFM
|
|
114
132
|
DEFAULT_WINDOW_SIZE = 100
|
|
133
|
+
DEFAULT_TENT_KERNEL_SIZE = 5 # Default tent kernel size for slower-frequency series aggregation
|
|
115
134
|
# Note: DEFAULT_BATCH_SIZE is defined above (line 52) as 32 for general neural networks
|
|
116
135
|
# Use DEFAULT_DDFM_BATCH_SIZE (100) for DDFM-specific batch size
|
|
117
136
|
|
|
118
137
|
# Warning/display limits
|
|
119
138
|
MAX_WARNING_ITEMS = 5 # Maximum number of items to show in warning messages
|
|
139
|
+
MAX_ERROR_ITEMS = 20 # Maximum number of items to show in error message details
|
|
120
140
|
|
|
121
141
|
# Minimum observations
|
|
122
142
|
DEFAULT_MIN_OBS = 5 # Default minimum observations for estimation
|
|
123
143
|
DEFAULT_MIN_OBS_IDIO = 5 # Default minimum observations for idio estimation
|
|
124
144
|
DEFAULT_MIN_OBS_VAR = 7 # Minimum observations for VAR estimation (order + 5)
|
|
125
145
|
|
|
146
|
+
# Dimension validation bounds
|
|
147
|
+
MIN_TIME_STEPS = 1 # Minimum number of time steps (T) required for data
|
|
148
|
+
MIN_VARIABLES = 1 # Minimum number of variables (N) required for data
|
|
149
|
+
MIN_DDFM_TIME_STEPS = 2 # Minimum number of time steps (T) required for DDFM training (DDFM-specific, different from general MIN_TIME_STEPS=1)
|
|
150
|
+
MIN_DDFM_DATASET_SIZE_WARNING = 10 # Minimum dataset size (T) below which DDFM denoising training warns about potential instability
|
|
151
|
+
MIN_ITER_FOR_DELTA_COMPUTATION = 1 # Minimum iteration count required before computing delta (MSE change) in DDFM denoising training
|
|
152
|
+
MIN_EPS_SHAPE_FOR_IDIO = 1 # Minimum eps shape dimension required for idiosyncratic component processing in DDFM
|
|
153
|
+
|
|
126
154
|
# Idiosyncratic component defaults
|
|
127
155
|
DEFAULT_IDIO_STD = 0.1 # Default idiosyncratic standard deviation (when estimation fails)
|
|
128
156
|
DEFAULT_IDIO_RHO0 = 0.1 # Default initial AR coefficient for idiosyncratic components
|
|
@@ -130,9 +158,7 @@ DEFAULT_AR_COEF = 0.5 # Default AR coefficient for initialization (conservative
|
|
|
130
158
|
DEFAULT_PROCESS_NOISE = 0.1 # Default process noise for initialization
|
|
131
159
|
DEFAULT_TRANSITION_COEF = 0.9 # Default transition coefficient for DFM initialization
|
|
132
160
|
|
|
133
|
-
# Standardization defaults
|
|
134
|
-
DEFAULT_WX_VALUE = 1.0 # Default standard deviation when Wx is missing (unit scale)
|
|
135
|
-
DEFAULT_MX_VALUE = 0.0 # Default mean when Mx is missing (zero-centered)
|
|
161
|
+
# Standardization defaults removed - now using sklearn scalers directly
|
|
136
162
|
|
|
137
163
|
# VAR stability and clipping
|
|
138
164
|
VAR_STABILITY_THRESHOLD = 0.99 # Maximum eigenvalue for VAR stability
|
|
@@ -153,18 +179,20 @@ DEFAULT_DAMPING_FACTOR = 0.5 # Default damping factor for parameter updates (us
|
|
|
153
179
|
|
|
154
180
|
# Numerical thresholds
|
|
155
181
|
MIN_CONDITION_NUMBER = 1e-12 # Minimum value for condition number calculations
|
|
182
|
+
MAX_CONDITION_NUMBER = 1e8 # Maximum condition number threshold for regularization (ill-conditioned matrix threshold)
|
|
156
183
|
|
|
157
184
|
# ============================================================================
|
|
158
185
|
# Display and Logging Defaults
|
|
159
186
|
# ============================================================================
|
|
160
187
|
|
|
161
188
|
DEFAULT_DISP = 10 # Default display interval for progress
|
|
189
|
+
DEFAULT_LOG_INTERVAL = 10 # Default logging interval divisor (log every num_epochs // DEFAULT_LOG_INTERVAL epochs)
|
|
190
|
+
DEFAULT_PROGRESS_LOG_INTERVAL = 5 # Default progress logging interval for EM algorithm
|
|
162
191
|
|
|
163
192
|
# ============================================================================
|
|
164
193
|
# Precision Defaults
|
|
165
194
|
# ============================================================================
|
|
166
195
|
|
|
167
|
-
DEFAULT_PRECISION = 32 # Default training precision
|
|
168
196
|
DEFAULT_DTYPE = np.float32 # Default numpy dtype for arrays
|
|
169
197
|
|
|
170
198
|
# PyTorch dtype (matches DEFAULT_DTYPE)
|
|
@@ -180,6 +208,34 @@ except ImportError:
|
|
|
180
208
|
|
|
181
209
|
DEFAULT_IRF_HORIZON = 20 # Default horizon for IRF computation
|
|
182
210
|
|
|
211
|
+
# ============================================================================
|
|
212
|
+
# Forecast Defaults
|
|
213
|
+
# ============================================================================
|
|
214
|
+
|
|
215
|
+
DEFAULT_FORECAST_HORIZON = 6 # Default horizon for forecast computation
|
|
216
|
+
|
|
217
|
+
# ============================================================================
|
|
218
|
+
# Error Handling Constants
|
|
219
|
+
# ============================================================================
|
|
220
|
+
|
|
221
|
+
# Common exception types for computation error handling
|
|
222
|
+
# Used to consolidate duplicate exception handling patterns across models
|
|
223
|
+
COMPUTATION_ERROR_TYPES = (RuntimeError, ValueError, TypeError, AttributeError, KeyError)
|
|
224
|
+
|
|
225
|
+
# ============================================================================
|
|
226
|
+
# KDFM Defaults
|
|
227
|
+
# ============================================================================
|
|
228
|
+
|
|
229
|
+
DEFAULT_KDFM_AR_ORDER = 1 # Default AR order (VAR lag order p) for KDFM
|
|
230
|
+
DEFAULT_KDFM_MA_ORDER = 0 # Default MA order (MA lag order q) for KDFM (0 = pure VAR)
|
|
231
|
+
|
|
232
|
+
# ============================================================================
|
|
233
|
+
# Tutorial Defaults
|
|
234
|
+
# ============================================================================
|
|
235
|
+
|
|
236
|
+
TUTORIAL_MAX_PERIODS = 100 # Default maximum periods for tutorial data (reduced for faster execution)
|
|
237
|
+
TUTORIAL_MAX_EPOCHS = 10 # Default maximum epochs for tutorial training (reduced for faster execution)
|
|
238
|
+
|
|
183
239
|
# ============================================================================
|
|
184
240
|
# Matrix Type Constants
|
|
185
241
|
# ============================================================================
|
|
@@ -248,6 +304,8 @@ TENT_WEIGHTS_LOOKUP: Dict[Tuple[str, str], np.ndarray] = {
|
|
|
248
304
|
('a', 'm'): np.array([1, 2, 3, 4, 5, 4, 3, 2, 1]), # 9 periods: annual -> monthly
|
|
249
305
|
('m', 'w'): np.array([1, 2, 3, 2, 1]), # 5 periods: monthly -> weekly
|
|
250
306
|
('q', 'w'): np.array([1, 2, 3, 4, 5, 4, 3, 2, 1]), # 9 periods: quarterly -> weekly
|
|
307
|
+
('sa', 'w'): np.array([1, 2, 3, 4, 3, 2, 1]), # 7 periods: semi-annual -> weekly
|
|
308
|
+
('a', 'w'): np.array([1, 2, 3, 4, 5, 4, 3, 2, 1]), # 9 periods: annual -> weekly
|
|
251
309
|
('sa', 'q'): np.array([1, 2, 1]), # 3 periods: semi-annual -> quarterly
|
|
252
310
|
('a', 'q'): np.array([1, 2, 3, 2, 1]), # 5 periods: annual -> quarterly
|
|
253
311
|
('a', 'sa'): np.array([1, 2, 1]), # 3 periods: annual -> semi-annual
|
|
@@ -271,19 +329,26 @@ __all__ = [
|
|
|
271
329
|
'MIN_FACTOR_VARIANCE',
|
|
272
330
|
'MIN_STD',
|
|
273
331
|
'MAX_EIGENVALUE',
|
|
332
|
+
'DEFAULT_EIGENVALUE_MAX_MAGNITUDE',
|
|
333
|
+
'DEFAULT_EIGENVALUE_WARN_THRESHOLD',
|
|
274
334
|
'DEFAULT_CLEAN_NAN',
|
|
275
335
|
'DEFAULT_CLEAN_INF',
|
|
276
336
|
'DEFAULT_IDENTITY_SCALE',
|
|
277
337
|
'DEFAULT_ZERO_VALUE',
|
|
338
|
+
'DEFAULT_XAVIER_GAIN',
|
|
339
|
+
'DEFAULT_OUTPUT_LAYER_GAIN',
|
|
340
|
+
'DEFAULT_INIT_SCALE',
|
|
341
|
+
'DEFAULT_KERNEL_INIT_SCALE',
|
|
278
342
|
'DEFAULT_REGULARIZATION_SCALE',
|
|
279
343
|
'DEFAULT_REGULARIZATION',
|
|
280
344
|
'DEFAULT_CLIP_THRESHOLD',
|
|
281
345
|
'DEFAULT_DATA_CLIP_THRESHOLD',
|
|
346
|
+
'MIN_CONDITION_NUMBER',
|
|
347
|
+
'MAX_CONDITION_NUMBER',
|
|
282
348
|
# Training
|
|
283
349
|
'DEFAULT_MAX_ITER',
|
|
284
350
|
'DEFAULT_MAX_EPOCHS',
|
|
285
351
|
'DEFAULT_MAX_MCMC_ITER',
|
|
286
|
-
'DEFAULT_EPOCHS_PER_ITER',
|
|
287
352
|
'DEFAULT_BATCH_SIZE', # General neural network default (32)
|
|
288
353
|
'DEFAULT_DDFM_BATCH_SIZE', # DDFM-specific default (100)
|
|
289
354
|
'DEFAULT_LEARNING_RATE',
|
|
@@ -292,9 +357,11 @@ __all__ = [
|
|
|
292
357
|
'DEFAULT_WEIGHT_DECAY',
|
|
293
358
|
'DEFAULT_LR_DECAY_RATE',
|
|
294
359
|
'DEFAULT_HUBER_DELTA',
|
|
360
|
+
'HUBER_QUADRATIC_COEFF',
|
|
295
361
|
'DEFAULT_DDFM_CLIP_RANGE_DEEP',
|
|
296
362
|
'DEFAULT_DDFM_CLIP_RANGE_SHALLOW',
|
|
297
363
|
'DEFAULT_EPSILON',
|
|
364
|
+
'DEFAULT_SEED',
|
|
298
365
|
# Structural identification
|
|
299
366
|
'DEFAULT_STRUCTURAL_REG_WEIGHT',
|
|
300
367
|
'DEFAULT_STRUCTURAL_INIT_SCALE',
|
|
@@ -311,6 +378,13 @@ __all__ = [
|
|
|
311
378
|
'DEFAULT_MIN_OBS',
|
|
312
379
|
'DEFAULT_MIN_OBS_IDIO',
|
|
313
380
|
'DEFAULT_MIN_OBS_VAR',
|
|
381
|
+
# Dimension validation
|
|
382
|
+
'MIN_TIME_STEPS',
|
|
383
|
+
'MIN_VARIABLES',
|
|
384
|
+
'MIN_DDFM_TIME_STEPS',
|
|
385
|
+
'MIN_DDFM_DATASET_SIZE_WARNING',
|
|
386
|
+
'MIN_ITER_FOR_DELTA_COMPUTATION',
|
|
387
|
+
'MIN_EPS_SHAPE_FOR_IDIO',
|
|
314
388
|
'DEFAULT_IDIO_STD',
|
|
315
389
|
'DEFAULT_IDIO_RHO0',
|
|
316
390
|
'DEFAULT_AR_COEF',
|
|
@@ -325,19 +399,28 @@ __all__ = [
|
|
|
325
399
|
'DEFAULT_SLOWER_FREQ_VARIANCE_DENOMINATOR',
|
|
326
400
|
'DEFAULT_EXTREME_FORECAST_THRESHOLD',
|
|
327
401
|
'DEFAULT_MAX_VARIANCE',
|
|
328
|
-
# Standardization
|
|
329
|
-
'DEFAULT_WX_VALUE',
|
|
330
|
-
'DEFAULT_MX_VALUE',
|
|
331
402
|
# Correlation and validation
|
|
332
403
|
'PERFECT_CORR_THRESHOLD',
|
|
333
404
|
'HIGH_CORR_THRESHOLD',
|
|
334
405
|
'DEFAULT_DAMPING_FACTOR',
|
|
335
406
|
# Display
|
|
336
407
|
'DEFAULT_DISP',
|
|
337
|
-
|
|
338
|
-
'
|
|
408
|
+
'DEFAULT_LOG_INTERVAL',
|
|
409
|
+
'DEFAULT_PROGRESS_LOG_INTERVAL',
|
|
410
|
+
'DEFAULT_TENT_KERNEL_SIZE',
|
|
411
|
+
'MAX_ERROR_ITEMS',
|
|
339
412
|
# IRF
|
|
340
413
|
'DEFAULT_IRF_HORIZON',
|
|
414
|
+
# Forecast
|
|
415
|
+
'DEFAULT_FORECAST_HORIZON',
|
|
416
|
+
# Error handling
|
|
417
|
+
'COMPUTATION_ERROR_TYPES',
|
|
418
|
+
# KDFM defaults
|
|
419
|
+
'DEFAULT_KDFM_AR_ORDER',
|
|
420
|
+
'DEFAULT_KDFM_MA_ORDER',
|
|
421
|
+
# Tutorial defaults
|
|
422
|
+
'TUTORIAL_MAX_PERIODS',
|
|
423
|
+
'TUTORIAL_MAX_EPOCHS',
|
|
341
424
|
# Matrix types
|
|
342
425
|
'MATRIX_TYPE_GENERAL',
|
|
343
426
|
'MATRIX_TYPE_COVARIANCE',
|
|
@@ -345,6 +428,9 @@ __all__ = [
|
|
|
345
428
|
'MATRIX_TYPE_LOADING',
|
|
346
429
|
# Log-determinant
|
|
347
430
|
'MAX_LOG_DETERMINANT',
|
|
431
|
+
'CHOLESKY_LOG_DET_FACTOR',
|
|
432
|
+
# Matrix computation
|
|
433
|
+
'SYMMETRY_AVERAGE_FACTOR',
|
|
348
434
|
# Default frequency
|
|
349
435
|
'DEFAULT_CLOCK_FREQUENCY',
|
|
350
436
|
'DEFAULT_HIERARCHY_VALUE',
|