dfm-python 0.2.4__py3-none-any.whl → 0.2.6__py3-none-any.whl
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/__init__.py +10 -53
- dfm_python/api.py +4 -4
- dfm_python/config.py +228 -554
- dfm_python/config_sources.py +558 -0
- dfm_python/core/__init__.py +2 -57
- dfm_python/core/diagnostics.py +162 -5
- dfm_python/core/em.py +1053 -875
- dfm_python/core/helpers.py +977 -35
- dfm_python/core/numeric.py +392 -407
- dfm_python/data.py +609 -0
- dfm_python/dfm.py +285 -246
- dfm_python/kalman.py +29 -26
- dfm_python/news.py +1 -1
- dfm_python/{utils/aggregation.py → utils.py} +148 -2
- dfm_python-0.2.6.dist-info/METADATA +792 -0
- dfm_python-0.2.6.dist-info/RECORD +18 -0
- dfm_python/core/grouping.py +0 -54
- dfm_python/core/results.py +0 -70
- dfm_python/data_loader.py +0 -798
- dfm_python/utils/__init__.py +0 -25
- dfm_python/utils/data_utils.py +0 -231
- dfm_python-0.2.4.dist-info/METADATA +0 -355
- dfm_python-0.2.4.dist-info/RECORD +0 -21
- {dfm_python-0.2.4.dist-info → dfm_python-0.2.6.dist-info}/WHEEL +0 -0
- {dfm_python-0.2.4.dist-info → dfm_python-0.2.6.dist-info}/licenses/LICENSE +0 -0
dfm_python/__init__.py
CHANGED
|
@@ -34,7 +34,7 @@ Example (High-level API - Recommended):
|
|
|
34
34
|
|
|
35
35
|
Example (Low-level API - For advanced usage):
|
|
36
36
|
>>> from dfm_python import DFM, DFMConfig, SeriesConfig
|
|
37
|
-
>>> from dfm_python.
|
|
37
|
+
>>> from dfm_python.data import load_data # Preferred import
|
|
38
38
|
>>> # Option 1: Load from YAML
|
|
39
39
|
>>> config = load_config('config.yaml')
|
|
40
40
|
>>> # Option 2: Create directly
|
|
@@ -50,7 +50,7 @@ Example (Low-level API - For advanced usage):
|
|
|
50
50
|
For detailed documentation, see the README.md file and the tutorial notebooks/scripts.
|
|
51
51
|
"""
|
|
52
52
|
|
|
53
|
-
__version__ = "0.2.
|
|
53
|
+
__version__ = "0.2.6"
|
|
54
54
|
|
|
55
55
|
from .config import DFMConfig, SeriesConfig, BlockConfig, Params, DEFAULT_GLOBAL_BLOCK_NAME
|
|
56
56
|
from .config import (
|
|
@@ -62,62 +62,19 @@ from .config import (
|
|
|
62
62
|
MergedConfigSource,
|
|
63
63
|
make_config_source,
|
|
64
64
|
)
|
|
65
|
-
from .
|
|
66
|
-
from .dfm import DFMResult
|
|
65
|
+
from .data import transform_data
|
|
66
|
+
from .dfm import DFMResult
|
|
67
|
+
from .core import calculate_rmse, diagnose_series, print_series_diagnosis
|
|
67
68
|
from .dfm import DFM as _DFMCore # Core DFM class from dfm.py
|
|
68
69
|
from .kalman import run_kf, skf, fis, miss_data
|
|
69
70
|
from .news import update_nowcast, news_dfm, para_const
|
|
70
71
|
|
|
71
72
|
# Import high-level API (extends core DFM with convenience methods)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
source=None,
|
|
78
|
-
*,
|
|
79
|
-
yaml=None,
|
|
80
|
-
mapping=None,
|
|
81
|
-
spec=None,
|
|
82
|
-
hydra=None,
|
|
83
|
-
base=None,
|
|
84
|
-
override=None,
|
|
85
|
-
config=None,
|
|
86
|
-
):
|
|
87
|
-
"""Load configuration (module-level convenience function).
|
|
88
|
-
|
|
89
|
-
See DFM.load_config() for parameter documentation.
|
|
90
|
-
"""
|
|
91
|
-
return _dfm_instance.load_config(
|
|
92
|
-
source=source,
|
|
93
|
-
yaml=yaml,
|
|
94
|
-
mapping=mapping,
|
|
95
|
-
spec=spec,
|
|
96
|
-
hydra=hydra,
|
|
97
|
-
base=base,
|
|
98
|
-
override=override,
|
|
99
|
-
config=config,
|
|
100
|
-
)
|
|
101
|
-
|
|
102
|
-
def load_data(data_path=None, data=None, **kwargs):
|
|
103
|
-
"""Load data (module-level convenience function)."""
|
|
104
|
-
return _dfm_instance.load_data(data_path=data_path, data=data, **kwargs)
|
|
105
|
-
|
|
106
|
-
def train(threshold=None, max_iter=None, **kwargs):
|
|
107
|
-
"""Train the model (module-level convenience function)."""
|
|
108
|
-
return _dfm_instance.train(threshold=threshold, max_iter=max_iter, **kwargs)
|
|
109
|
-
|
|
110
|
-
def predict(horizon=12, **kwargs):
|
|
111
|
-
"""Forecast using the trained model (module-level convenience function)."""
|
|
112
|
-
return _dfm_instance.predict(horizon=horizon, **kwargs)
|
|
113
|
-
|
|
114
|
-
def plot(**kwargs):
|
|
115
|
-
"""Plot common visualizations (module-level convenience function)."""
|
|
116
|
-
return _dfm_instance.plot(**kwargs)
|
|
117
|
-
|
|
118
|
-
def reset():
|
|
119
|
-
"""Reset state (module-level convenience function)."""
|
|
120
|
-
return _dfm_instance.reset()
|
|
73
|
+
# Import module-level convenience functions directly from api.py to avoid duplication
|
|
74
|
+
from .api import (
|
|
75
|
+
DFM, _dfm_instance, from_yaml, from_spec, from_spec_df, from_dict,
|
|
76
|
+
load_config, load_data, train, predict, plot, reset
|
|
77
|
+
)
|
|
121
78
|
|
|
122
79
|
# Expose properties as module-level attributes
|
|
123
80
|
# Use property-like access via functions or direct attribute access
|
dfm_python/api.py
CHANGED
|
@@ -23,7 +23,7 @@ import numpy as np
|
|
|
23
23
|
import pandas as pd
|
|
24
24
|
|
|
25
25
|
from .config import DFMConfig, Params
|
|
26
|
-
from .
|
|
26
|
+
from .data import load_data as _load_data
|
|
27
27
|
from .config import (
|
|
28
28
|
make_config_source,
|
|
29
29
|
ConfigSource,
|
|
@@ -272,7 +272,7 @@ class DFM(_DFMCore):
|
|
|
272
272
|
if forecast_horizon is not None and forecast_horizon > 0:
|
|
273
273
|
Z_fore = self.predict(forecast_horizon, return_series=False, return_factors=True)
|
|
274
274
|
# Build forecast dates
|
|
275
|
-
last_date = time_hist[-1]
|
|
275
|
+
last_date = time_hist.iloc[-1] if hasattr(time_hist, 'iloc') else time_hist[-1]
|
|
276
276
|
# Use same monthly-end spacing; if freq missing, fallback to monthly-end
|
|
277
277
|
try:
|
|
278
278
|
forecast_dates = pd.date_range(start=last_date + pd.tseries.frequencies.to_offset('ME'),
|
|
@@ -390,7 +390,7 @@ def from_spec(spec_path: Union[str, Path], params: Optional[Params] = None) -> D
|
|
|
390
390
|
|
|
391
391
|
def from_spec_df(spec_df: pd.DataFrame, params: Optional[Params] = None) -> DFM:
|
|
392
392
|
"""Load configuration from spec DataFrame (convenience constructor)."""
|
|
393
|
-
from .
|
|
393
|
+
from .data import _load_config_from_dataframe
|
|
394
394
|
|
|
395
395
|
if params is None:
|
|
396
396
|
params = Params()
|
|
@@ -414,7 +414,7 @@ def from_dict(mapping: Dict[str, Any]) -> DFM:
|
|
|
414
414
|
|
|
415
415
|
# Expose singleton instance for direct access
|
|
416
416
|
# Users can access: dfm.config, dfm.data, dfm.result, etc.
|
|
417
|
-
__all__ = ['DFM', 'load_config', 'load_data', 'train', 'reset',
|
|
417
|
+
__all__ = ['DFM', 'load_config', 'load_data', 'train', 'predict', 'plot', 'reset',
|
|
418
418
|
'from_yaml', 'from_spec', 'from_spec_df', 'from_dict']
|
|
419
419
|
|
|
420
420
|
|