dfm-python 0.4.2__tar.gz → 0.4.3__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.4.2 → dfm_python-0.4.3}/PKG-INFO +24 -64
- {dfm_python-0.4.2 → dfm_python-0.4.3}/README.md +20 -62
- {dfm_python-0.4.2 → dfm_python-0.4.3}/pyproject.toml +5 -2
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/__init__.py +9 -11
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/config/__init__.py +8 -13
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/config/adapter.py +12 -210
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/config/results.py +18 -10
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/config/schema.py +31 -66
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/config/utils.py +13 -13
- dfm_python-0.4.3/src/dfm_python/data/__init__.py +28 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/data/dataloader.py +51 -8
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/data/utils.py +28 -30
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/encoder/vae.py +3 -2
- dfm_python-0.4.3/src/dfm_python/lightning/__init__.py +63 -0
- dfm_python-0.4.3/src/dfm_python/lightning/data_module.py +686 -0
- dfm_python-0.4.3/src/dfm_python/lightning/scaling.py +432 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/models/__init__.py +3 -3
- dfm_python-0.4.3/src/dfm_python/models/base.py +564 -0
- dfm_python-0.4.3/src/dfm_python/models/ddfm.py +2410 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/models/dfm.py +125 -586
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/models/estimation.py +13 -14
- dfm_python-0.4.3/src/dfm_python/nowcast/__init__.py +37 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/nowcast/dataview.py +7 -7
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/nowcast/helpers.py +6 -6
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/nowcast/nowcast.py +274 -26
- dfm_python-0.4.3/src/dfm_python/nowcast/splitters.py +431 -0
- dfm_python-0.4.3/src/dfm_python/nowcast/transformers.py +330 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/nowcast/utils.py +11 -11
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/ssm/kalman.py +13 -27
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/ssm/utils.py +3 -1
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/trainer/__init__.py +22 -22
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/trainer/ddfm.py +7 -7
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/trainer/dfm.py +7 -7
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/utils/__init__.py +15 -15
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/utils/data.py +17 -20
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/utils/diagnostics.py +28 -23
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/utils/helpers.py +7 -7
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/utils/statespace.py +41 -71
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/utils/time.py +148 -249
- dfm_python-0.4.3/src/test/test_helpers.py +427 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/test/test_models.py +14 -84
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/test/test_nowcast.py +4 -4
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/test/test_pipeline_ddfm.py +363 -78
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/test/test_pipeline_dfm.py +108 -303
- dfm_python-0.4.3/src/test/test_sktime_integration.py +447 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/test/test_trainer.py +7 -87
- {dfm_python-0.4.2 → dfm_python-0.4.3}/uv.lock +656 -121
- dfm_python-0.4.2/data/metadata.csv +0 -102
- dfm_python-0.4.2/src/dfm_python/data/__init__.py +0 -52
- dfm_python-0.4.2/src/dfm_python/data/transformation.py +0 -313
- dfm_python-0.4.2/src/dfm_python/lightning/__init__.py +0 -50
- dfm_python-0.4.2/src/dfm_python/lightning/data_module.py +0 -558
- dfm_python-0.4.2/src/dfm_python/lightning/ddfm_module.py +0 -580
- dfm_python-0.4.2/src/dfm_python/lightning/dfm_module.py +0 -466
- dfm_python-0.4.2/src/dfm_python/models/base.py +0 -235
- dfm_python-0.4.2/src/dfm_python/models/ddfm.py +0 -1594
- dfm_python-0.4.2/src/dfm_python/nowcast/__init__.py +0 -28
- {dfm_python-0.4.2 → dfm_python-0.4.3}/.gitignore +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/.python-version +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/LICENSE +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/MANIFEST.in +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/experiment/base.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/experiment/investment_ddfm.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/experiment/production_dfm.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/experiment/production_dfm_high_factors.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/experiment/test_ddfm.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/experiment/test_dfm.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/model/ddfm.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/model/dfm.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KO3YEARC.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOBFDSAAF.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOBFINAAF.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOBFXSAAF.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOBSESI_R.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOBSIBCEQ.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOBSIBCOQ.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOBSIBNER.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOBSIBNMR.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOBSIEMAR.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOBSIHAPR.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOBSIIMER.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOBSIIMPR.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOBSIXMER.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOBUSINVR.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCALL_.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCNFBUSR.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCNFCONR.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCNGOV_D.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCNPER_D.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCOBUSIR.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCONPMTH.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCONPRCF.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCONSTRP.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCPCOREF.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCPEXFEF.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCREU__A.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCSECDMR.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCSECEMR.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCSEMEMR.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCSEOHDR.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCSEOHSR.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCSHHEMR.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCSHHLMR.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCSMTTOA.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCSPHIMR.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCSPSPMR.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOCYLEADR.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KODBLNEQA.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KODBLNHSA.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOEMPCONF.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOEMPMANF.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOEMPTOTO.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOEMPWREP.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOEQUIMAE.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOEQUIPTE.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOEQUITTE.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOEXCHINA.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOEXNGS_D.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOEXPGDSA.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOEXPPRCF.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOGCFCNSD.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOGCFFNVD.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOGDP___D.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOGFCF__D.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOHWRWEMP.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOIMNGS_D.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOIMPCONA.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOIMPGDDA.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOIMPGDSA.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOIMPPRCF.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOIPALL_G.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOIPMIMAG.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOLRLTCO.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOLRLTHH.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOMPCAPGG.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOMPCONDG.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOMPCONGG.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOMPCONNG.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOMPRI30G.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOMSCAPGG.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOMSCONGG.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KONETTRDF.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KONEWCONA.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOPICAPGG.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOPICONGG.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOPIMANUG.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOPOPACTE.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOPPSRM_F.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOPROPRCF.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOPSMANUG.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KORCNST.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KORELEC.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KORFBEV.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KORMACH.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KORMCMP.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOROCOINF.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KORWHLS.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOSHRPRCF.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOSIAHOTE.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOSIAI__E.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOSIARRLE.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOSIAWRTE.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOSSBFMBE.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOUN_TOTQ.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOUS____.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOVALCONA.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOWRCCNSE.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOWRCDURE.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOWRCNODE.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/config/series/KOWRCSEME.yaml +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/data/sample_data.csv +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/data/dataset.py +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/encoder/__init__.py +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/encoder/base.py +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/encoder/pca.py +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/lightning/callbacks.py +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/lightning/utils.py +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/logger/__init__.py +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/logger/inference_logger.py +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/logger/logger.py +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/logger/train_logger.py +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/ssm/__init__.py +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/dfm_python/ssm/em.py +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/test/test_config.py +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/test/test_logger.py +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/test/test_ssm.py +0 -0
- {dfm_python-0.4.2 → dfm_python-0.4.3}/src/test/test_utils.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: dfm-python
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.3
|
|
4
4
|
Summary: Dynamic Factor Model (DFM) estimation and nowcasting 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
|
|
@@ -22,7 +22,7 @@ Requires-Python: >=3.10
|
|
|
22
22
|
Requires-Dist: hydra-core>=1.3.2
|
|
23
23
|
Requires-Dist: matplotlib>=3.5.0
|
|
24
24
|
Requires-Dist: numpy>=1.24.0
|
|
25
|
-
Requires-Dist:
|
|
25
|
+
Requires-Dist: pandas>=2.0.0
|
|
26
26
|
Requires-Dist: pyarrow>=22.0.0
|
|
27
27
|
Requires-Dist: pytorch-lightning>=2.0.0
|
|
28
28
|
Requires-Dist: scikit-learn>=1.7.2
|
|
@@ -45,6 +45,8 @@ Provides-Extra: dev
|
|
|
45
45
|
Requires-Dist: pytest-cov>=4.0.0; extra == 'dev'
|
|
46
46
|
Requires-Dist: pytest>=7.0.0; extra == 'dev'
|
|
47
47
|
Requires-Dist: scikit-learn>=1.0.0; extra == 'dev'
|
|
48
|
+
Provides-Extra: forecasting
|
|
49
|
+
Requires-Dist: sktime[forecasting]>=0.40.1; extra == 'forecasting'
|
|
48
50
|
Provides-Extra: hydra
|
|
49
51
|
Requires-Dist: hydra-core>=1.3.0; extra == 'hydra'
|
|
50
52
|
Requires-Dist: omegaconf>=2.3.0; extra == 'hydra'
|
|
@@ -78,7 +80,7 @@ A Dynamic Factor Model is a powerful statistical framework that:
|
|
|
78
80
|
- ✅ **Clock-based framework**: All factors evolve at a common clock frequency (configurable: daily, weekly, monthly, quarterly, semi-annual, annual)
|
|
79
81
|
- ✅ **Block structure**: Flexible factor organization (global common factor + sector-specific factors)
|
|
80
82
|
- ✅ **Idiosyncratic components**: Per-series state augmentation for better fit (AR(1) for clock-frequency, tent-length chains for slower frequencies)
|
|
81
|
-
- ✅ **
|
|
83
|
+
- ✅ **Preprocessed data**: Package expects preprocessed data from users - users handle all preprocessing (imputation, scaling, feature engineering) using sktime or other tools
|
|
82
84
|
- ✅ **News decomposition**: Attribute forecast changes to specific data releases
|
|
83
85
|
- ✅ **Nowcasting & Forecasting**: Generate predictions for any horizon
|
|
84
86
|
- ✅ **Deep Dynamic Factor Models (DDFM)**: Nonlinear encoder with PyTorch for capturing complex factor structures (optional, requires `dfm-python[deep]`)
|
|
@@ -103,7 +105,7 @@ pip install dfm-python
|
|
|
103
105
|
**Requirements**:
|
|
104
106
|
- Python >= 3.10
|
|
105
107
|
- numpy >= 1.24.0
|
|
106
|
-
-
|
|
108
|
+
- pandas >= 2.0.0
|
|
107
109
|
- scipy >= 1.10.0
|
|
108
110
|
|
|
109
111
|
Optional dependencies:
|
|
@@ -119,7 +121,7 @@ Optional dependencies:
|
|
|
119
121
|
import dfm_python as dfm
|
|
120
122
|
import numpy as np
|
|
121
123
|
from datetime import datetime
|
|
122
|
-
import
|
|
124
|
+
import pandas as pd
|
|
123
125
|
|
|
124
126
|
# Generate or load your data (T × N: time periods × series)
|
|
125
127
|
# Data should be standardized or will be standardized automatically
|
|
@@ -215,36 +217,25 @@ dfm.train(max_iter=5000, threshold=1e-5)
|
|
|
215
217
|
X_forecast, Z_forecast = dfm.predict(horizon=None) # Or specify: horizon=12
|
|
216
218
|
```
|
|
217
219
|
|
|
218
|
-
### Example 3: Using
|
|
220
|
+
### Example 3: Using YAML Configuration (Recommended)
|
|
219
221
|
|
|
220
222
|
```python
|
|
221
223
|
import dfm_python as dfm
|
|
222
|
-
from dfm_python.config import Params
|
|
223
|
-
import polars as pl
|
|
224
|
-
|
|
225
|
-
# 1. Create spec CSV (see Data Format section)
|
|
226
|
-
# 2. Load configuration
|
|
227
|
-
params = Params(
|
|
228
|
-
max_iter=5000,
|
|
229
|
-
threshold=1e-5,
|
|
230
|
-
clock='m',
|
|
231
|
-
augment_idio=True, # Enable idio components
|
|
232
|
-
idio_rho0=0.1 # Initial AR coefficient for idio
|
|
233
|
-
)
|
|
234
|
-
spec_df = pl.read_csv('data/spec.csv')
|
|
235
|
-
dfm.from_spec_df(spec_df, params=params)
|
|
236
224
|
|
|
237
|
-
#
|
|
225
|
+
# 1. Load configuration from YAML file
|
|
226
|
+
dfm.from_yaml('config/default.yaml')
|
|
227
|
+
|
|
228
|
+
# 2. Load data
|
|
238
229
|
dfm.load_data('data/data.csv', sample_start='2020-01-01', sample_end='2023-12-31')
|
|
239
230
|
|
|
240
|
-
#
|
|
231
|
+
# 3. Train
|
|
241
232
|
dfm.train()
|
|
242
233
|
|
|
243
|
-
#
|
|
234
|
+
# 4. Forecast and visualize (horizon=None defaults to 1 year of periods)
|
|
244
235
|
X_forecast, Z_forecast = dfm.predict(horizon=None) # Or specify: horizon=12
|
|
245
236
|
dfm.plot(kind='factor', factor_index=0, forecast_horizon=None, save_path='factor_forecast.png')
|
|
246
237
|
|
|
247
|
-
#
|
|
238
|
+
# 5. Access results
|
|
248
239
|
result = dfm.get_result()
|
|
249
240
|
print(f"Converged: {result.converged}, Iterations: {result.num_iter}")
|
|
250
241
|
print(f"Log-likelihood: {result.loglik:.2f}")
|
|
@@ -297,28 +288,7 @@ decomposition abilities (which require the data view).
|
|
|
297
288
|
|
|
298
289
|
The package supports multiple ways to configure your model:
|
|
299
290
|
|
|
300
|
-
#### 1.
|
|
301
|
-
|
|
302
|
-
**Best for**: Users with existing CSV files and Excel-based workflows
|
|
303
|
-
|
|
304
|
-
```python
|
|
305
|
-
from dfm_python.config import Params
|
|
306
|
-
import polars as pl
|
|
307
|
-
|
|
308
|
-
params = Params(
|
|
309
|
-
max_iter=5000,
|
|
310
|
-
threshold=1e-5,
|
|
311
|
-
clock='m',
|
|
312
|
-
augment_idio=True,
|
|
313
|
-
augment_idio_slow=True,
|
|
314
|
-
idio_rho0=0.1,
|
|
315
|
-
idio_min_var=1e-8
|
|
316
|
-
)
|
|
317
|
-
spec_df = pl.read_csv('data/spec.csv')
|
|
318
|
-
dfm.from_spec_df(spec_df, params=params)
|
|
319
|
-
```
|
|
320
|
-
|
|
321
|
-
#### 2. YAML Configuration
|
|
291
|
+
#### 1. YAML Configuration
|
|
322
292
|
|
|
323
293
|
**Best for**: Users who prefer declarative configuration files
|
|
324
294
|
|
|
@@ -331,7 +301,7 @@ dfm.load_data('data/sample_data.csv')
|
|
|
331
301
|
dfm.train()
|
|
332
302
|
```
|
|
333
303
|
|
|
334
|
-
####
|
|
304
|
+
#### 2. Hydra Decorator (Advanced)
|
|
335
305
|
|
|
336
306
|
**Best for**: Users already using Hydra for configuration management
|
|
337
307
|
|
|
@@ -356,7 +326,7 @@ if __name__ == "__main__":
|
|
|
356
326
|
|
|
357
327
|
**CLI Overrides**: `python script.py max_iter=10 threshold=1e-4 blocks.Block_Global.factors=2`
|
|
358
328
|
|
|
359
|
-
####
|
|
329
|
+
#### 3. Direct Python Objects
|
|
360
330
|
|
|
361
331
|
**Best for**: Programmatic configuration and integration with other Python code
|
|
362
332
|
|
|
@@ -459,7 +429,7 @@ Date,gdp_real,consumption,investment,employment,retail_sales
|
|
|
459
429
|
**Notes**:
|
|
460
430
|
- Quarterly series (e.g., `gdp_real`) only have values at quarter-end months
|
|
461
431
|
- Monthly series (e.g., `employment`, `retail_sales`) have values every month
|
|
462
|
-
-
|
|
432
|
+
- **Data must be preprocessed**: Users must handle missing values, scaling, and feature engineering before passing data to the package. Use sktime or other tools for preprocessing.
|
|
463
433
|
|
|
464
434
|
### Supported Frequencies
|
|
465
435
|
|
|
@@ -856,11 +826,9 @@ config = DFMConfig(series=series, blocks=blocks)
|
|
|
856
826
|
|
|
857
827
|
```python
|
|
858
828
|
import dfm_python as dfm
|
|
859
|
-
import
|
|
829
|
+
import pandas as pd
|
|
860
830
|
|
|
861
831
|
# Configuration
|
|
862
|
-
spec_df = pl.read_csv(spec_path)
|
|
863
|
-
dfm.from_spec_df(spec_df, params=None) # Convert spec DataFrame to YAML + load
|
|
864
832
|
dfm.from_yaml(yaml_path) # Load from YAML file
|
|
865
833
|
dfm.from_dict(config_dict) # Load from dictionary
|
|
866
834
|
dfm.load_config(hydra=cfg) # Load from Hydra DictConfig
|
|
@@ -1141,13 +1109,6 @@ python tutorial/basic_tutorial.py \
|
|
|
1141
1109
|
--config-name default \
|
|
1142
1110
|
data_path=data/sample_data.csv
|
|
1143
1111
|
|
|
1144
|
-
# Convert spec CSV to YAML first, then use
|
|
1145
|
-
python -c "import dfm_python as dfm; dfm.from_spec('data/sample_spec.csv')"
|
|
1146
|
-
python tutorial/basic_tutorial.py \
|
|
1147
|
-
--config-path config \
|
|
1148
|
-
--config-name sample_spec \
|
|
1149
|
-
data_path=data/sample_data.csv
|
|
1150
|
-
|
|
1151
1112
|
# With CLI overrides
|
|
1152
1113
|
python tutorial/basic_tutorial.py \
|
|
1153
1114
|
--config-path config \
|
|
@@ -1160,7 +1121,6 @@ python tutorial/basic_tutorial.py \
|
|
|
1160
1121
|
|
|
1161
1122
|
Comprehensive tutorial covering:
|
|
1162
1123
|
- **Hydra-based configuration**: All configs managed through YAML files
|
|
1163
|
-
- **Spec CSV conversion**: Convert CSV to YAML using `dfm.from_spec()`, then load via Hydra
|
|
1164
1124
|
- **CLI parameter overrides**: Override any parameter via command line
|
|
1165
1125
|
- **Data preparation and transformation**
|
|
1166
1126
|
- **Model training and convergence**
|
|
@@ -1223,14 +1183,14 @@ DATA_VIEW_SOURCE=file # or database
|
|
|
1223
1183
|
|
|
1224
1184
|
### Recent Improvements (v0.3.1)
|
|
1225
1185
|
|
|
1226
|
-
- ✅ **
|
|
1227
|
-
`create_data_view()` now applies release-date masks via
|
|
1186
|
+
- ✅ **Pandas-backed Data Views + Kalman Cache**
|
|
1187
|
+
`create_data_view()` now applies release-date masks via pandas, avoiding per-view NumPy copies. `Nowcast.backtest()` reuses cached Kalman filter/smoother states across successive data views, giving large speed-ups for 12-step pseudo real-time tests.
|
|
1228
1188
|
- ✅ **Backtest Trajectory Plot**
|
|
1229
1189
|
`BacktestResult.plot_trajectory()` draws 이전 vs. 업데이트 nowcast curves plus monthly actuals along a relative week axis (`-12주 … 현재`). The tutorial simply calls this helper—no more hand-built plotting code.
|
|
1230
1190
|
- ✅ **Higher-Frequency Backsteps**
|
|
1231
1191
|
`Nowcast.backtest(..., backward_steps=12, higher_freq=True)` now emits weekly snapshots even when the model clock is monthly, so you can inspect 12주 worth of “pseudo releases” immediately.
|
|
1232
1192
|
- ✅ **Reload & Reuse**
|
|
1233
|
-
`DFM.load_pickle()` restores config, time index, and cached
|
|
1193
|
+
`DFM.load_pickle()` restores config, time index, and cached pandas data views so you can call `predict()`/`nowcast()` right after loading without re-reading CSVs.
|
|
1234
1194
|
- ✅ **API + Docs Refresh**
|
|
1235
1195
|
README/tutorial sections now highlight the faster backtests, new trajectory plots, and guidelines for interpreting flattened Q-matrix values or “strange” news decomposition outputs.
|
|
1236
1196
|
|
|
@@ -1244,7 +1204,7 @@ DATA_VIEW_SOURCE=file # or database
|
|
|
1244
1204
|
- ✅ **Model Result Storage**: File-based and SQLite adapters for saving/loading model results
|
|
1245
1205
|
- ✅ **Data View Management**: Time-point specific data views for pseudo real-time evaluation
|
|
1246
1206
|
- ✅ **Helper Function Consolidation**: Reduced code duplication with consolidated helper functions
|
|
1247
|
-
- `to_python_datetime()`: Generic datetime conversion (handles
|
|
1207
|
+
- `to_python_datetime()`: Generic datetime conversion (handles pandas Timestamp, strings, etc.)
|
|
1248
1208
|
- `extract_last_date()`: Generic time index extraction
|
|
1249
1209
|
- `clock_to_datetime_freq()`: Shared clock-to-datetime frequency mapping
|
|
1250
1210
|
- `get_periods_per_year()`: Generic periods-per-year calculation
|
|
@@ -24,7 +24,7 @@ A Dynamic Factor Model is a powerful statistical framework that:
|
|
|
24
24
|
- ✅ **Clock-based framework**: All factors evolve at a common clock frequency (configurable: daily, weekly, monthly, quarterly, semi-annual, annual)
|
|
25
25
|
- ✅ **Block structure**: Flexible factor organization (global common factor + sector-specific factors)
|
|
26
26
|
- ✅ **Idiosyncratic components**: Per-series state augmentation for better fit (AR(1) for clock-frequency, tent-length chains for slower frequencies)
|
|
27
|
-
- ✅ **
|
|
27
|
+
- ✅ **Preprocessed data**: Package expects preprocessed data from users - users handle all preprocessing (imputation, scaling, feature engineering) using sktime or other tools
|
|
28
28
|
- ✅ **News decomposition**: Attribute forecast changes to specific data releases
|
|
29
29
|
- ✅ **Nowcasting & Forecasting**: Generate predictions for any horizon
|
|
30
30
|
- ✅ **Deep Dynamic Factor Models (DDFM)**: Nonlinear encoder with PyTorch for capturing complex factor structures (optional, requires `dfm-python[deep]`)
|
|
@@ -49,7 +49,7 @@ pip install dfm-python
|
|
|
49
49
|
**Requirements**:
|
|
50
50
|
- Python >= 3.10
|
|
51
51
|
- numpy >= 1.24.0
|
|
52
|
-
-
|
|
52
|
+
- pandas >= 2.0.0
|
|
53
53
|
- scipy >= 1.10.0
|
|
54
54
|
|
|
55
55
|
Optional dependencies:
|
|
@@ -65,7 +65,7 @@ Optional dependencies:
|
|
|
65
65
|
import dfm_python as dfm
|
|
66
66
|
import numpy as np
|
|
67
67
|
from datetime import datetime
|
|
68
|
-
import
|
|
68
|
+
import pandas as pd
|
|
69
69
|
|
|
70
70
|
# Generate or load your data (T × N: time periods × series)
|
|
71
71
|
# Data should be standardized or will be standardized automatically
|
|
@@ -161,36 +161,25 @@ dfm.train(max_iter=5000, threshold=1e-5)
|
|
|
161
161
|
X_forecast, Z_forecast = dfm.predict(horizon=None) # Or specify: horizon=12
|
|
162
162
|
```
|
|
163
163
|
|
|
164
|
-
### Example 3: Using
|
|
164
|
+
### Example 3: Using YAML Configuration (Recommended)
|
|
165
165
|
|
|
166
166
|
```python
|
|
167
167
|
import dfm_python as dfm
|
|
168
|
-
from dfm_python.config import Params
|
|
169
|
-
import polars as pl
|
|
170
|
-
|
|
171
|
-
# 1. Create spec CSV (see Data Format section)
|
|
172
|
-
# 2. Load configuration
|
|
173
|
-
params = Params(
|
|
174
|
-
max_iter=5000,
|
|
175
|
-
threshold=1e-5,
|
|
176
|
-
clock='m',
|
|
177
|
-
augment_idio=True, # Enable idio components
|
|
178
|
-
idio_rho0=0.1 # Initial AR coefficient for idio
|
|
179
|
-
)
|
|
180
|
-
spec_df = pl.read_csv('data/spec.csv')
|
|
181
|
-
dfm.from_spec_df(spec_df, params=params)
|
|
182
168
|
|
|
183
|
-
#
|
|
169
|
+
# 1. Load configuration from YAML file
|
|
170
|
+
dfm.from_yaml('config/default.yaml')
|
|
171
|
+
|
|
172
|
+
# 2. Load data
|
|
184
173
|
dfm.load_data('data/data.csv', sample_start='2020-01-01', sample_end='2023-12-31')
|
|
185
174
|
|
|
186
|
-
#
|
|
175
|
+
# 3. Train
|
|
187
176
|
dfm.train()
|
|
188
177
|
|
|
189
|
-
#
|
|
178
|
+
# 4. Forecast and visualize (horizon=None defaults to 1 year of periods)
|
|
190
179
|
X_forecast, Z_forecast = dfm.predict(horizon=None) # Or specify: horizon=12
|
|
191
180
|
dfm.plot(kind='factor', factor_index=0, forecast_horizon=None, save_path='factor_forecast.png')
|
|
192
181
|
|
|
193
|
-
#
|
|
182
|
+
# 5. Access results
|
|
194
183
|
result = dfm.get_result()
|
|
195
184
|
print(f"Converged: {result.converged}, Iterations: {result.num_iter}")
|
|
196
185
|
print(f"Log-likelihood: {result.loglik:.2f}")
|
|
@@ -243,28 +232,7 @@ decomposition abilities (which require the data view).
|
|
|
243
232
|
|
|
244
233
|
The package supports multiple ways to configure your model:
|
|
245
234
|
|
|
246
|
-
#### 1.
|
|
247
|
-
|
|
248
|
-
**Best for**: Users with existing CSV files and Excel-based workflows
|
|
249
|
-
|
|
250
|
-
```python
|
|
251
|
-
from dfm_python.config import Params
|
|
252
|
-
import polars as pl
|
|
253
|
-
|
|
254
|
-
params = Params(
|
|
255
|
-
max_iter=5000,
|
|
256
|
-
threshold=1e-5,
|
|
257
|
-
clock='m',
|
|
258
|
-
augment_idio=True,
|
|
259
|
-
augment_idio_slow=True,
|
|
260
|
-
idio_rho0=0.1,
|
|
261
|
-
idio_min_var=1e-8
|
|
262
|
-
)
|
|
263
|
-
spec_df = pl.read_csv('data/spec.csv')
|
|
264
|
-
dfm.from_spec_df(spec_df, params=params)
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
#### 2. YAML Configuration
|
|
235
|
+
#### 1. YAML Configuration
|
|
268
236
|
|
|
269
237
|
**Best for**: Users who prefer declarative configuration files
|
|
270
238
|
|
|
@@ -277,7 +245,7 @@ dfm.load_data('data/sample_data.csv')
|
|
|
277
245
|
dfm.train()
|
|
278
246
|
```
|
|
279
247
|
|
|
280
|
-
####
|
|
248
|
+
#### 2. Hydra Decorator (Advanced)
|
|
281
249
|
|
|
282
250
|
**Best for**: Users already using Hydra for configuration management
|
|
283
251
|
|
|
@@ -302,7 +270,7 @@ if __name__ == "__main__":
|
|
|
302
270
|
|
|
303
271
|
**CLI Overrides**: `python script.py max_iter=10 threshold=1e-4 blocks.Block_Global.factors=2`
|
|
304
272
|
|
|
305
|
-
####
|
|
273
|
+
#### 3. Direct Python Objects
|
|
306
274
|
|
|
307
275
|
**Best for**: Programmatic configuration and integration with other Python code
|
|
308
276
|
|
|
@@ -405,7 +373,7 @@ Date,gdp_real,consumption,investment,employment,retail_sales
|
|
|
405
373
|
**Notes**:
|
|
406
374
|
- Quarterly series (e.g., `gdp_real`) only have values at quarter-end months
|
|
407
375
|
- Monthly series (e.g., `employment`, `retail_sales`) have values every month
|
|
408
|
-
-
|
|
376
|
+
- **Data must be preprocessed**: Users must handle missing values, scaling, and feature engineering before passing data to the package. Use sktime or other tools for preprocessing.
|
|
409
377
|
|
|
410
378
|
### Supported Frequencies
|
|
411
379
|
|
|
@@ -802,11 +770,9 @@ config = DFMConfig(series=series, blocks=blocks)
|
|
|
802
770
|
|
|
803
771
|
```python
|
|
804
772
|
import dfm_python as dfm
|
|
805
|
-
import
|
|
773
|
+
import pandas as pd
|
|
806
774
|
|
|
807
775
|
# Configuration
|
|
808
|
-
spec_df = pl.read_csv(spec_path)
|
|
809
|
-
dfm.from_spec_df(spec_df, params=None) # Convert spec DataFrame to YAML + load
|
|
810
776
|
dfm.from_yaml(yaml_path) # Load from YAML file
|
|
811
777
|
dfm.from_dict(config_dict) # Load from dictionary
|
|
812
778
|
dfm.load_config(hydra=cfg) # Load from Hydra DictConfig
|
|
@@ -1087,13 +1053,6 @@ python tutorial/basic_tutorial.py \
|
|
|
1087
1053
|
--config-name default \
|
|
1088
1054
|
data_path=data/sample_data.csv
|
|
1089
1055
|
|
|
1090
|
-
# Convert spec CSV to YAML first, then use
|
|
1091
|
-
python -c "import dfm_python as dfm; dfm.from_spec('data/sample_spec.csv')"
|
|
1092
|
-
python tutorial/basic_tutorial.py \
|
|
1093
|
-
--config-path config \
|
|
1094
|
-
--config-name sample_spec \
|
|
1095
|
-
data_path=data/sample_data.csv
|
|
1096
|
-
|
|
1097
1056
|
# With CLI overrides
|
|
1098
1057
|
python tutorial/basic_tutorial.py \
|
|
1099
1058
|
--config-path config \
|
|
@@ -1106,7 +1065,6 @@ python tutorial/basic_tutorial.py \
|
|
|
1106
1065
|
|
|
1107
1066
|
Comprehensive tutorial covering:
|
|
1108
1067
|
- **Hydra-based configuration**: All configs managed through YAML files
|
|
1109
|
-
- **Spec CSV conversion**: Convert CSV to YAML using `dfm.from_spec()`, then load via Hydra
|
|
1110
1068
|
- **CLI parameter overrides**: Override any parameter via command line
|
|
1111
1069
|
- **Data preparation and transformation**
|
|
1112
1070
|
- **Model training and convergence**
|
|
@@ -1169,14 +1127,14 @@ DATA_VIEW_SOURCE=file # or database
|
|
|
1169
1127
|
|
|
1170
1128
|
### Recent Improvements (v0.3.1)
|
|
1171
1129
|
|
|
1172
|
-
- ✅ **
|
|
1173
|
-
`create_data_view()` now applies release-date masks via
|
|
1130
|
+
- ✅ **Pandas-backed Data Views + Kalman Cache**
|
|
1131
|
+
`create_data_view()` now applies release-date masks via pandas, avoiding per-view NumPy copies. `Nowcast.backtest()` reuses cached Kalman filter/smoother states across successive data views, giving large speed-ups for 12-step pseudo real-time tests.
|
|
1174
1132
|
- ✅ **Backtest Trajectory Plot**
|
|
1175
1133
|
`BacktestResult.plot_trajectory()` draws 이전 vs. 업데이트 nowcast curves plus monthly actuals along a relative week axis (`-12주 … 현재`). The tutorial simply calls this helper—no more hand-built plotting code.
|
|
1176
1134
|
- ✅ **Higher-Frequency Backsteps**
|
|
1177
1135
|
`Nowcast.backtest(..., backward_steps=12, higher_freq=True)` now emits weekly snapshots even when the model clock is monthly, so you can inspect 12주 worth of “pseudo releases” immediately.
|
|
1178
1136
|
- ✅ **Reload & Reuse**
|
|
1179
|
-
`DFM.load_pickle()` restores config, time index, and cached
|
|
1137
|
+
`DFM.load_pickle()` restores config, time index, and cached pandas data views so you can call `predict()`/`nowcast()` right after loading without re-reading CSVs.
|
|
1180
1138
|
- ✅ **API + Docs Refresh**
|
|
1181
1139
|
README/tutorial sections now highlight the faster backtests, new trajectory plots, and guidelines for interpreting flattened Q-matrix values or “strange” news decomposition outputs.
|
|
1182
1140
|
|
|
@@ -1190,7 +1148,7 @@ DATA_VIEW_SOURCE=file # or database
|
|
|
1190
1148
|
- ✅ **Model Result Storage**: File-based and SQLite adapters for saving/loading model results
|
|
1191
1149
|
- ✅ **Data View Management**: Time-point specific data views for pseudo real-time evaluation
|
|
1192
1150
|
- ✅ **Helper Function Consolidation**: Reduced code duplication with consolidated helper functions
|
|
1193
|
-
- `to_python_datetime()`: Generic datetime conversion (handles
|
|
1151
|
+
- `to_python_datetime()`: Generic datetime conversion (handles pandas Timestamp, strings, etc.)
|
|
1194
1152
|
- `extract_last_date()`: Generic time index extraction
|
|
1195
1153
|
- `clock_to_datetime_freq()`: Shared clock-to-datetime frequency mapping
|
|
1196
1154
|
- `get_periods_per_year()`: Generic periods-per-year calculation
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "dfm-python"
|
|
3
|
-
version = "0.4.
|
|
3
|
+
version = "0.4.3"
|
|
4
4
|
description = "Dynamic Factor Model (DFM) estimation and nowcasting in Python"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
requires-python = ">=3.10"
|
|
@@ -23,7 +23,7 @@ dependencies = [
|
|
|
23
23
|
"hydra-core>=1.3.2",
|
|
24
24
|
"matplotlib>=3.5.0",
|
|
25
25
|
"numpy>=1.24.0",
|
|
26
|
-
"
|
|
26
|
+
"pandas>=2.0.0",
|
|
27
27
|
"pyarrow>=22.0.0",
|
|
28
28
|
"pytorch-lightning>=2.0.0",
|
|
29
29
|
"scikit-learn>=1.7.2",
|
|
@@ -49,6 +49,9 @@ deep = [
|
|
|
49
49
|
transform = [
|
|
50
50
|
"sktime>=0.27.0",
|
|
51
51
|
]
|
|
52
|
+
forecasting = [
|
|
53
|
+
"sktime[forecasting]>=0.40.1",
|
|
54
|
+
]
|
|
52
55
|
dev = [
|
|
53
56
|
"pytest>=7.0.0",
|
|
54
57
|
"pytest-cov>=4.0.0",
|
|
@@ -19,7 +19,7 @@ has a frequency faster than the clock, a ValueError will be raised.
|
|
|
19
19
|
|
|
20
20
|
Key Features:
|
|
21
21
|
- Hydra-based configuration (YAML files) - primary configuration method
|
|
22
|
-
- Expects preprocessed data from users - package
|
|
22
|
+
- Expects preprocessed data from users - users handle all preprocessing, package extracts statistics from pipeline
|
|
23
23
|
- Flexible block structure for factor modeling
|
|
24
24
|
- Robust handling of missing data (internal spline interpolation)
|
|
25
25
|
- Automatic standardization and data clipping
|
|
@@ -27,11 +27,11 @@ Key Features:
|
|
|
27
27
|
|
|
28
28
|
Example (Standard Lightning Pattern):
|
|
29
29
|
>>> from dfm_python import DFM, DFMDataModule, DFMTrainer
|
|
30
|
-
>>> import
|
|
30
|
+
>>> import pandas as pd
|
|
31
31
|
>>>
|
|
32
32
|
>>> # Step 1: Load and preprocess data
|
|
33
|
-
>>> df =
|
|
34
|
-
>>> df_processed = df
|
|
33
|
+
>>> df = pd.read_csv('data/sample_data.csv')
|
|
34
|
+
>>> df_processed = df[[col for col in df.columns if col != 'date']]
|
|
35
35
|
>>>
|
|
36
36
|
>>> # Step 2: Create DataModule
|
|
37
37
|
>>> dm = DFMDataModule(config_path='config/default.yaml', data=df_processed)
|
|
@@ -67,7 +67,7 @@ Note: DFMConfig and SeriesConfig are internal implementation details.
|
|
|
67
67
|
For detailed documentation, see the README.md file and the tutorial notebooks/scripts.
|
|
68
68
|
"""
|
|
69
69
|
|
|
70
|
-
__version__ = "0.4.
|
|
70
|
+
__version__ = "0.4.3"
|
|
71
71
|
|
|
72
72
|
# ============================================================================
|
|
73
73
|
# PUBLIC API DEFINITION
|
|
@@ -79,8 +79,8 @@ __version__ = "0.4.2"
|
|
|
79
79
|
# Public API categories:
|
|
80
80
|
# 1. Configuration: DFMConfig, SeriesConfig, config sources
|
|
81
81
|
# 2. High-level API: DFM, DDFM, module-level convenience functions
|
|
82
|
-
# 3. Core utilities:
|
|
83
|
-
# 4. Models: BaseFactorModel,
|
|
82
|
+
# 3. Core utilities: TimeIndex, diagnostics
|
|
83
|
+
# 4. Models: BaseFactorModel, DDFM (low-level)
|
|
84
84
|
# 5. Nowcasting: Nowcast, result classes, para_const
|
|
85
85
|
# 6. Data & Results: DFMResult
|
|
86
86
|
# ============================================================================
|
|
@@ -94,8 +94,6 @@ from .config import (
|
|
|
94
94
|
# Internal imports (for backward compatibility, but not recommended)
|
|
95
95
|
from .config import DFMConfig, SeriesConfig # Internal use only
|
|
96
96
|
|
|
97
|
-
# Data utilities
|
|
98
|
-
|
|
99
97
|
# Results
|
|
100
98
|
from .config.results import DFMResult, DDFMResult, BaseResult
|
|
101
99
|
|
|
@@ -125,14 +123,14 @@ from .nowcast.helpers import (
|
|
|
125
123
|
|
|
126
124
|
# Model implementations
|
|
127
125
|
from .models.base import BaseFactorModel
|
|
128
|
-
from .models.dfm import
|
|
126
|
+
from .models.dfm import DFM
|
|
129
127
|
|
|
130
128
|
# DDFM high-level API and low-level model (PyTorch is mandatory)
|
|
131
129
|
from .models.ddfm import DDFM, DDFMModel
|
|
132
130
|
|
|
133
131
|
__all__ = [
|
|
134
132
|
# Core classes
|
|
135
|
-
'DFM', '
|
|
133
|
+
'DFM', 'Nowcast',
|
|
136
134
|
# Model base and implementations
|
|
137
135
|
'BaseFactorModel',
|
|
138
136
|
# Nowcast result classes
|
|
@@ -18,21 +18,18 @@ from .adapter import (
|
|
|
18
18
|
HydraSource,
|
|
19
19
|
MergedConfigSource,
|
|
20
20
|
make_config_source,
|
|
21
|
-
# Note: from_spec is in models/dfm.py, not in adapter
|
|
22
|
-
# Note: Private functions (_load_config_from_dataframe, _write_series_blocks_yaml)
|
|
23
|
-
# are available from adapter module but not exported as public API
|
|
24
21
|
)
|
|
25
22
|
from .utils import (
|
|
26
23
|
FREQUENCY_HIERARCHY,
|
|
27
24
|
PERIODS_PER_YEAR,
|
|
28
25
|
get_periods_per_year,
|
|
29
26
|
get_annual_factor,
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
compute_idio_lengths,
|
|
28
|
+
get_tent_weights,
|
|
32
29
|
generate_tent_weights,
|
|
33
30
|
generate_R_mat,
|
|
34
|
-
|
|
35
|
-
|
|
31
|
+
get_agg_structure,
|
|
32
|
+
group_by_freq,
|
|
36
33
|
)
|
|
37
34
|
|
|
38
35
|
__all__ = [
|
|
@@ -53,13 +50,11 @@ __all__ = [
|
|
|
53
50
|
'PERIODS_PER_YEAR',
|
|
54
51
|
'get_periods_per_year',
|
|
55
52
|
'get_annual_factor',
|
|
56
|
-
'
|
|
57
|
-
'
|
|
53
|
+
'compute_idio_lengths',
|
|
54
|
+
'get_tent_weights',
|
|
58
55
|
'generate_tent_weights',
|
|
59
56
|
'generate_R_mat',
|
|
60
|
-
'
|
|
61
|
-
'
|
|
62
|
-
# Note: Private functions (_load_config_from_dataframe, _write_series_blocks_yaml)
|
|
63
|
-
# are available from adapter module but not exported as public API
|
|
57
|
+
'get_agg_structure',
|
|
58
|
+
'group_by_freq',
|
|
64
59
|
]
|
|
65
60
|
|