tempdisagg 0.2.7__tar.gz → 0.2.9__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.
- {tempdisagg-0.2.7/tempdisagg.egg-info → tempdisagg-0.2.9}/PKG-INFO +2 -2
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/README.md +1 -1
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/pyproject.toml +1 -1
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/model/tempdisagg_core.py +1 -1
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/model/tempdisagg_ensemble.py +1 -1
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/model/tempdisagg_fitter.py +1 -1
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/model/tempdisagg_model.py +3 -1
- {tempdisagg-0.2.7 → tempdisagg-0.2.9/tempdisagg.egg-info}/PKG-INFO +2 -2
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tests/test_prediction.py +37 -6
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/LICENSE +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/setup.cfg +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/__init__.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/core/__init__.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/core/numeric_utils.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/core/rho_optimizer.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/core/temporal_aggregator.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/model/__init__.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/model/models_handler.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/model/tempdisagg_adjuster.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/model/tempdisagg_base.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/model/tempdisagg_summary.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/model/tempdisagg_visualizer.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/postprocessing/__init__.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/postprocessing/ensemble_prediction.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/postprocessing/post_estimation.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/preprocessing/__init__.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/preprocessing/conversion_matrix_builder.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/preprocessing/disagg_input_preparer.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/preprocessing/input_preprocessor.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/preprocessing/timeseries_completer.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/utils/__init__.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/utils/logging_utils.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg/utils/retropolarizer.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg.egg-info/SOURCES.txt +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg.egg-info/dependency_links.txt +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg.egg-info/requires.txt +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tempdisagg.egg-info/top_level.txt +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tests/test_numeric_utils.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tests/test_rho_optimizer.py +0 -0
- {tempdisagg-0.2.7 → tempdisagg-0.2.9}/tests/test_summary_visualize.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tempdisagg
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.9
|
|
4
4
|
Summary: Temporal disaggregation models in Python
|
|
5
5
|
Author-email: Jaime Vera-Jaramillo <jaimevera1107@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -59,7 +59,7 @@ Official indicators often come in low frequency (e.g. yearly GDP), while economi
|
|
|
59
59
|
| Method(s) | Description |
|
|
60
60
|
|-------------------------------------------------------------------------|---------------------------------------------------------------|
|
|
61
61
|
| `ols` | Ordinary Least Squares (baseline) |
|
|
62
|
-
| `denton
|
|
62
|
+
| `denton` | Denton interpolation with differencing |
|
|
63
63
|
| `denton-colette` | Cholette smoother variant from Dagum & Cholette |
|
|
64
64
|
| `chow-lin`, `chow-lin-opt`, `chow-lin-ecotrim`, `chow-lin-quilis` | Regression + AR(1) residual modeling |
|
|
65
65
|
| `litterman`, `litterman-opt` | Random walk / AR(1) prior models |
|
|
@@ -36,7 +36,7 @@ Official indicators often come in low frequency (e.g. yearly GDP), while economi
|
|
|
36
36
|
| Method(s) | Description |
|
|
37
37
|
|-------------------------------------------------------------------------|---------------------------------------------------------------|
|
|
38
38
|
| `ols` | Ordinary Least Squares (baseline) |
|
|
39
|
-
| `denton
|
|
39
|
+
| `denton` | Denton interpolation with differencing |
|
|
40
40
|
| `denton-colette` | Cholette smoother variant from Dagum & Cholette |
|
|
41
41
|
| `chow-lin`, `chow-lin-opt`, `chow-lin-ecotrim`, `chow-lin-quilis` | Regression + AR(1) residual modeling |
|
|
42
42
|
| `litterman`, `litterman-opt` | Random walk / AR(1) prior models |
|
|
@@ -130,7 +130,7 @@ class TempDisaggModelCore:
|
|
|
130
130
|
"litterman-opt": self.models.litterman_opt_estimation,
|
|
131
131
|
"chow-lin-ecotrim": self.models.chow_lin_minrss_ecotrim,
|
|
132
132
|
"chow-lin-quilis": self.models.chow_lin_minrss_quilis,
|
|
133
|
-
"denton-
|
|
133
|
+
"denton-cholette": self.models.denton_cholette_estimation,
|
|
134
134
|
"uniform": self.models.uniform_estimation
|
|
135
135
|
}
|
|
136
136
|
|
|
@@ -99,7 +99,7 @@ class EnsemblePredictor:
|
|
|
99
99
|
methods = [
|
|
100
100
|
"ols", "denton", "chow-lin", "litterman", "fernandez", "fast",
|
|
101
101
|
"chow-lin-opt", "litterman-opt", "chow-lin-ecotrim", "chow-lin-quilis",
|
|
102
|
-
"denton-opt", "denton-
|
|
102
|
+
"denton-opt", "denton-cholette", "uniform"
|
|
103
103
|
]
|
|
104
104
|
self.logger.info(f"No methods specified. Using all available: {methods}")
|
|
105
105
|
|
|
@@ -110,7 +110,7 @@ class ModelFitter:
|
|
|
110
110
|
"litterman-opt": self.models.litterman_opt_estimation,
|
|
111
111
|
"chow-lin-ecotrim": self.models.chow_lin_minrss_ecotrim,
|
|
112
112
|
"chow-lin-quilis": self.models.chow_lin_minrss_quilis,
|
|
113
|
-
"denton-
|
|
113
|
+
"denton-cholette": self.models.denton_cholette_estimation,
|
|
114
114
|
"uniform": self.models.uniform_estimation,
|
|
115
115
|
}
|
|
116
116
|
|
|
@@ -112,7 +112,9 @@ class TempDisaggModel:
|
|
|
112
112
|
retro_aux_col=retro_aux_col
|
|
113
113
|
) if self.is_ensemble else None
|
|
114
114
|
|
|
115
|
-
self.adjuster = PostEstimation(conversion=conversion
|
|
115
|
+
self.adjuster = PostEstimation(conversion=conversion,
|
|
116
|
+
index_col=index_col,
|
|
117
|
+
verbose=verbose)
|
|
116
118
|
|
|
117
119
|
def fit(self, df, methods=None):
|
|
118
120
|
if self.is_ensemble:
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: tempdisagg
|
|
3
|
-
Version: 0.2.
|
|
3
|
+
Version: 0.2.9
|
|
4
4
|
Summary: Temporal disaggregation models in Python
|
|
5
5
|
Author-email: Jaime Vera-Jaramillo <jaimevera1107@gmail.com>
|
|
6
6
|
License-Expression: MIT
|
|
@@ -59,7 +59,7 @@ Official indicators often come in low frequency (e.g. yearly GDP), while economi
|
|
|
59
59
|
| Method(s) | Description |
|
|
60
60
|
|-------------------------------------------------------------------------|---------------------------------------------------------------|
|
|
61
61
|
| `ols` | Ordinary Least Squares (baseline) |
|
|
62
|
-
| `denton
|
|
62
|
+
| `denton` | Denton interpolation with differencing |
|
|
63
63
|
| `denton-colette` | Cholette smoother variant from Dagum & Cholette |
|
|
64
64
|
| `chow-lin`, `chow-lin-opt`, `chow-lin-ecotrim`, `chow-lin-quilis` | Regression + AR(1) residual modeling |
|
|
65
65
|
| `litterman`, `litterman-opt` | Random walk / AR(1) prior models |
|
|
@@ -4,20 +4,32 @@ import statsmodels.api as sm
|
|
|
4
4
|
import pytest
|
|
5
5
|
from tempdisagg import TempDisaggModel
|
|
6
6
|
|
|
7
|
+
# ---- Fixtures ----
|
|
8
|
+
|
|
7
9
|
@pytest.fixture(scope="module")
|
|
8
10
|
def disagg_data():
|
|
9
11
|
macro = sm.datasets.macrodata.load_pandas().data
|
|
10
12
|
macro["Index"] = macro["year"].astype(int)
|
|
11
13
|
macro["Grain"] = macro["quarter"].astype(int)
|
|
12
14
|
macro["X"] = macro["realcons"]
|
|
13
|
-
|
|
14
15
|
col_name = "realgdp"
|
|
15
16
|
gdp_annual = macro.groupby("Index")[col_name].mean().reset_index()
|
|
16
17
|
gdp_annual.columns = ["Index", "y"]
|
|
17
|
-
|
|
18
18
|
df = macro.merge(gdp_annual, on="Index", how="left")[["Index", "Grain", "y", "X"]].copy()
|
|
19
19
|
return df
|
|
20
20
|
|
|
21
|
+
@pytest.fixture(scope="module")
|
|
22
|
+
def disagg_data_othername():
|
|
23
|
+
macro = sm.datasets.macrodata.load_pandas().data
|
|
24
|
+
macro["index"] = macro["year"].astype(int)
|
|
25
|
+
macro["grain"] = macro["quarter"].astype(int)
|
|
26
|
+
macro["x"] = macro["realcons"]
|
|
27
|
+
col_name = "realgdp"
|
|
28
|
+
gdp_annual = macro.groupby("index")[col_name].mean().reset_index()
|
|
29
|
+
gdp_annual.columns = ["index", "y"]
|
|
30
|
+
df = macro.merge(gdp_annual, on="index", how="left")[["index", "grain", "y", "x"]].copy()
|
|
31
|
+
return df
|
|
32
|
+
|
|
21
33
|
# ---- Individual Model Tests ----
|
|
22
34
|
|
|
23
35
|
def test_individual_predict_truncated(disagg_data):
|
|
@@ -29,19 +41,19 @@ def test_individual_predict_truncated(disagg_data):
|
|
|
29
41
|
assert y_hat.shape[1] == 1
|
|
30
42
|
|
|
31
43
|
def test_individual_predict_padded(disagg_data):
|
|
32
|
-
model = TempDisaggModel(method="
|
|
44
|
+
model = TempDisaggModel(method="denton-cholette", conversion="average")
|
|
33
45
|
model.fit(disagg_data)
|
|
34
46
|
y_hat = model.predict(full=True)
|
|
35
47
|
assert y_hat.shape == (model._df.shape[0], 1)
|
|
36
48
|
|
|
37
49
|
def test_individual_adjust_padded(disagg_data):
|
|
38
|
-
model = TempDisaggModel(method="chow-lin
|
|
50
|
+
model = TempDisaggModel(method="chow-lin", conversion="average")
|
|
39
51
|
model.fit(disagg_data)
|
|
40
52
|
adjusted = model.adjust_output(full=True)
|
|
41
53
|
assert adjusted.shape == (model._df.shape[0], 1)
|
|
42
54
|
|
|
43
55
|
def test_individual_adjust_truncated(disagg_data):
|
|
44
|
-
model = TempDisaggModel(method="
|
|
56
|
+
model = TempDisaggModel(method="litterman", conversion="average")
|
|
45
57
|
model.fit(disagg_data)
|
|
46
58
|
adjusted = model.adjust_output(full=False)
|
|
47
59
|
assert adjusted.shape[0] < model._df.shape[0]
|
|
@@ -77,9 +89,28 @@ def test_ensemble_adjust_truncated(disagg_data):
|
|
|
77
89
|
|
|
78
90
|
def test_ensemble_adjust_truncated_no_methods(disagg_data):
|
|
79
91
|
model = TempDisaggModel(method="ensemble", conversion="average")
|
|
80
|
-
model.fit(disagg_data)
|
|
92
|
+
model.fit(disagg_data) # Usa todos los métodos por defecto
|
|
81
93
|
adjusted = model.adjust_output(full=False)
|
|
82
94
|
model.summary()
|
|
83
95
|
model.plot()
|
|
84
96
|
assert adjusted.shape[0] < model._df.shape[0]
|
|
85
97
|
assert adjusted.shape[1] == 1
|
|
98
|
+
|
|
99
|
+
# ---- Alternative names ----
|
|
100
|
+
|
|
101
|
+
def test_individual_othername_predict_truncated(disagg_data_othername):
|
|
102
|
+
model = TempDisaggModel(method="chow-lin-opt", conversion="average",
|
|
103
|
+
index_col="index", grain_col="grain", y_col="y", X_col="x")
|
|
104
|
+
model.fit(disagg_data_othername)
|
|
105
|
+
y_hat = model.predict(full=True)
|
|
106
|
+
assert model._df.shape[0] > disagg_data_othername.shape[0]
|
|
107
|
+
assert y_hat.shape[0] == model._df.shape[0]
|
|
108
|
+
assert y_hat.shape[1] == 1
|
|
109
|
+
|
|
110
|
+
def test_individual_othername_predict_padded(disagg_data_othername):
|
|
111
|
+
model = TempDisaggModel(method="chow-lin-opt", conversion="average",
|
|
112
|
+
index_col="index", grain_col="grain", y_col="y", X_col="x")
|
|
113
|
+
model.fit(disagg_data_othername)
|
|
114
|
+
y_hat = model.predict()
|
|
115
|
+
assert y_hat.shape == (model._df.shape[0], 1)
|
|
116
|
+
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|