echoss-timeseries 1.0.0__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.
- echoss_timeseries/__init__.py +110 -0
- echoss_timeseries/autoregressive_features.py +677 -0
- echoss_timeseries/cache_manager.py +117 -0
- echoss_timeseries/decomposition.py +521 -0
- echoss_timeseries/echoss_plot_bokeh.py +713 -0
- echoss_timeseries/echoss_plot_matplot.py +263 -0
- echoss_timeseries/echoss_tsdata.py +1249 -0
- echoss_timeseries/echoss_tsmodel.py +581 -0
- echoss_timeseries/engines/__init__.py +8 -0
- echoss_timeseries/engines/darts_series.py +148 -0
- echoss_timeseries/engines/ensemble_base.py +131 -0
- echoss_timeseries/engines/holdout_comparison.py +168 -0
- echoss_timeseries/engines/model_base.py +89 -0
- echoss_timeseries/engines/registry.py +98 -0
- echoss_timeseries/engines/screener_base.py +74 -0
- echoss_timeseries/engines/sklearn_tabular.py +123 -0
- echoss_timeseries/engines/statsmodels_arima.py +85 -0
- echoss_timeseries/event_day_features.py +111 -0
- echoss_timeseries/outlier.py +173 -0
- echoss_timeseries/temporal_features.py +284 -0
- echoss_timeseries/tsdiag.py +457 -0
- echoss_timeseries-1.0.0.dist-info/METADATA +263 -0
- echoss_timeseries-1.0.0.dist-info/RECORD +26 -0
- echoss_timeseries-1.0.0.dist-info/WHEEL +5 -0
- echoss_timeseries-1.0.0.dist-info/licenses/LICENSE +204 -0
- echoss_timeseries-1.0.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"""
|
|
2
|
+
12cm. inc timeseries package for data analysis and modeling on time-base values
|
|
3
|
+
- TSData class
|
|
4
|
+
- TSModel class
|
|
5
|
+
|
|
6
|
+
이름을 실제로 쓸 때 해당 모듈을 적재한다 (PEP 562 module __getattr__).
|
|
7
|
+
전량 eager re-export 는 쓰지 않는다 — `import echoss_timeseries` 만으로 bokeh,
|
|
8
|
+
matplotlib, statsmodels, holidays 가 전부 올라오면 진단 함수 하나 쓰는 비용이 과하고,
|
|
9
|
+
엔진별 optional extras 가 성립하지 않는다 (docs/design/engine-abstraction.md 4절).
|
|
10
|
+
"""
|
|
11
|
+
from importlib import import_module
|
|
12
|
+
|
|
13
|
+
# Package-level variables
|
|
14
|
+
__version__ = '1.0.0'
|
|
15
|
+
__author__ = 'ckkim@12cm.co.kr'
|
|
16
|
+
|
|
17
|
+
from echoss_fileformat import get_logger, use_logger
|
|
18
|
+
|
|
19
|
+
# Use package module level variable to store the singleton logger instance.
|
|
20
|
+
# This check ensures the logger is created only once.
|
|
21
|
+
try:
|
|
22
|
+
# Attempt to use an existing logger.
|
|
23
|
+
_logger = use_logger('echoss_timeseries')
|
|
24
|
+
except RuntimeError:
|
|
25
|
+
# If it doesn't exist, create it.
|
|
26
|
+
_logger = get_logger('echoss_timeseries', backup_count=7)
|
|
27
|
+
|
|
28
|
+
# Expose the logger to other modules in the package.
|
|
29
|
+
# This makes it easily accessible via 'from . import logger'.
|
|
30
|
+
# 지연 적재 대상이 아니다 — 하위 모듈이 import 시점에 `from . import logger` 로 가져간다.
|
|
31
|
+
logger = _logger
|
|
32
|
+
|
|
33
|
+
# export 이름 -> 이를 정의한 모듈. 지연 적재의 유일한 근거 자료다.
|
|
34
|
+
_EXPORTS = {
|
|
35
|
+
"TSData": "echoss_tsdata",
|
|
36
|
+
"TSModel": "echoss_tsmodel",
|
|
37
|
+
"EventDayFeatures": "event_day_features",
|
|
38
|
+
**{name: "autoregressive_features" for name in (
|
|
39
|
+
"add_lag_features", "add_rolling_features",
|
|
40
|
+
"add_seasonal_rolling_features", "add_ewma_features",
|
|
41
|
+
)},
|
|
42
|
+
**{name: "decomposition" for name in (
|
|
43
|
+
"BaseDecomposition", "MultiSeasonalDecomposition",
|
|
44
|
+
"FourierDecomposition", "DecomposeResult",
|
|
45
|
+
)},
|
|
46
|
+
**{name: "temporal_features" for name in (
|
|
47
|
+
"add_temporal_features", "add_fourier_features", "bulk_add_fourier_features",
|
|
48
|
+
)},
|
|
49
|
+
**{name: "outlier" for name in (
|
|
50
|
+
"detect_outlier_sd", "detect_outlier_iqr", "detect_outlier_isolation_forest",
|
|
51
|
+
)},
|
|
52
|
+
**{name: "echoss_plot_bokeh" for name in (
|
|
53
|
+
"plot_lines", "plot_lines_grid", "plot_datetime", "plot_interactive_datetime",
|
|
54
|
+
"format_plot", "plot_forecast", "plot_train_test_forecast",
|
|
55
|
+
)},
|
|
56
|
+
"plot_sales_intensity_heatmap": "echoss_plot_matplot",
|
|
57
|
+
**{name: "engines.model_base" for name in ("ModelEngine", "DataShape")},
|
|
58
|
+
"StatsmodelsArimaEngine": "engines.statsmodels_arima",
|
|
59
|
+
"SklearnTabularEngine": "engines.sklearn_tabular",
|
|
60
|
+
"DartsSeriesEngine": "engines.darts_series",
|
|
61
|
+
"HoldoutComparison": "engines.holdout_comparison",
|
|
62
|
+
"EngineRegistry": "engines.registry",
|
|
63
|
+
**{name: "engines.ensemble_base" for name in ("Ensemble", "WeightedEnsemble")},
|
|
64
|
+
**{name: "engines.screener_base" for name in ("Screener", "Candidate")},
|
|
65
|
+
**{name: "tsdiag" for name in (
|
|
66
|
+
"ensure_month_start_col", "validate_month_ms", "ensure_datetime_freq",
|
|
67
|
+
"seasonal_strength", "is_constant_series", "stationarity_tests",
|
|
68
|
+
"lag_diagnostics", "try_autoreg", "naive_cv_scores", "analyze_series",
|
|
69
|
+
)},
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
# 기본 설치에 포함되지 않는 모듈 -> 필요한 extras 이름.
|
|
73
|
+
# 여기 없는 모듈은 기본 의존성만으로 적재된다.
|
|
74
|
+
_EXTRAS = {
|
|
75
|
+
"echoss_plot_bokeh": "plot",
|
|
76
|
+
"echoss_plot_matplot": "plot",
|
|
77
|
+
"engines.darts_series": "forecast",
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
__all__ = ["logger", *sorted(_EXPORTS)]
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
def __getattr__(name: str):
|
|
84
|
+
"""이름을 처음 쓸 때 해당 모듈을 적재한다 (PEP 562)."""
|
|
85
|
+
module_name = _EXPORTS.get(name)
|
|
86
|
+
if module_name is None:
|
|
87
|
+
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
|
|
88
|
+
|
|
89
|
+
try:
|
|
90
|
+
module = import_module(f".{module_name}", __name__)
|
|
91
|
+
except ModuleNotFoundError as e:
|
|
92
|
+
# 무엇을 설치해야 하는지 알려준다. 맨 ModuleNotFoundError 로 끝내면
|
|
93
|
+
# 사용자가 extras 의 존재를 알 방법이 없다.
|
|
94
|
+
extras = _EXTRAS.get(module_name)
|
|
95
|
+
if extras is None:
|
|
96
|
+
raise
|
|
97
|
+
raise ModuleNotFoundError(
|
|
98
|
+
f"{name!r} 을 쓰려면 '{extras}' extras 가 필요하다 "
|
|
99
|
+
f"(빠진 의존성: {e.name}). "
|
|
100
|
+
f"설치: pip install 'echoss-timeseries[{extras}]'"
|
|
101
|
+
) from e
|
|
102
|
+
|
|
103
|
+
value = getattr(module, name)
|
|
104
|
+
# 전역에 넣어두면 다음 접근부터는 __getattr__ 를 타지 않는다.
|
|
105
|
+
globals()[name] = value
|
|
106
|
+
return value
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def __dir__():
|
|
110
|
+
return sorted([*globals(), *_EXPORTS])
|