spotforecast2 0.0.2__tar.gz → 0.0.4__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.
- spotforecast2-0.0.4/PKG-INFO +77 -0
- spotforecast2-0.0.4/README.md +40 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/pyproject.toml +9 -3
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/forecaster/utils.py +17 -1
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/processing/n2n_predict.py +19 -10
- spotforecast2-0.0.4/src/spotforecast2/processing/n2n_predict_with_covariates.py +937 -0
- spotforecast2-0.0.4/src/spotforecast2/weather/__init__.py +5 -0
- spotforecast2-0.0.2/PKG-INFO +0 -47
- spotforecast2-0.0.2/README.md +0 -22
- spotforecast2-0.0.2/src/spotforecast2/weather/__init__.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/__init__.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/data/__init__.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/data/data.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/data/fetch_data.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/exceptions.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/forecaster/__init__.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/forecaster/base.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/forecaster/metrics.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/forecaster/recursive/__init__.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/forecaster/recursive/_forecaster_equivalent_date.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/forecaster/recursive/_forecaster_recursive.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/forecaster/recursive/_warnings.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/model_selection/__init__.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/model_selection/bayesian_search.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/model_selection/grid_search.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/model_selection/random_search.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/model_selection/split_base.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/model_selection/split_one_step.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/model_selection/split_ts_cv.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/model_selection/utils_common.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/model_selection/utils_metrics.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/model_selection/validation.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/preprocessing/__init__.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/preprocessing/_binner.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/preprocessing/_common.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/preprocessing/_differentiator.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/preprocessing/_rolling.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/preprocessing/curate_data.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/preprocessing/imputation.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/preprocessing/outlier.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/preprocessing/split.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/processing/agg_predict.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/py.typed +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/utils/__init__.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/utils/convert_to_utc.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/utils/data_transform.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/utils/forecaster_config.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/utils/generate_holiday.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/utils/validation.py +0 -0
- {spotforecast2-0.0.2 → spotforecast2-0.0.4}/src/spotforecast2/weather/weather_client.py +0 -0
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: spotforecast2
|
|
3
|
+
Version: 0.0.4
|
|
4
|
+
Summary: Forecasting with spot
|
|
5
|
+
Author: bartzbeielstein
|
|
6
|
+
Author-email: bartzbeielstein <32470350+bartzbeielstein@users.noreply.github.com>
|
|
7
|
+
Requires-Dist: astral>=3.2
|
|
8
|
+
Requires-Dist: feature-engine>=1.9.3
|
|
9
|
+
Requires-Dist: flake8>=7.3.0
|
|
10
|
+
Requires-Dist: holidays>=0.90
|
|
11
|
+
Requires-Dist: ipykernel>=7.1.0
|
|
12
|
+
Requires-Dist: jupyter>=1.1.1
|
|
13
|
+
Requires-Dist: lightgbm>=4.6.0
|
|
14
|
+
Requires-Dist: matplotlib>=3.10.8
|
|
15
|
+
Requires-Dist: numba>=0.63.1
|
|
16
|
+
Requires-Dist: optuna>=4.7.0
|
|
17
|
+
Requires-Dist: pandas>=3.0.0
|
|
18
|
+
Requires-Dist: plotly>=6.5.2
|
|
19
|
+
Requires-Dist: pyarrow>=23.0.0
|
|
20
|
+
Requires-Dist: scikit-learn>=1.8.0
|
|
21
|
+
Requires-Dist: spotoptim>=0.0.160
|
|
22
|
+
Requires-Dist: tqdm>=4.67.2
|
|
23
|
+
Requires-Dist: pytest>=9.0.2 ; extra == 'dev'
|
|
24
|
+
Requires-Dist: pytest-cov>=6.0.0 ; extra == 'dev'
|
|
25
|
+
Requires-Dist: black>=24.1.0 ; extra == 'dev'
|
|
26
|
+
Requires-Dist: isort>=5.13.0 ; extra == 'dev'
|
|
27
|
+
Requires-Dist: ruff>=0.3.0 ; extra == 'dev'
|
|
28
|
+
Requires-Dist: mkdocs>=1.6.1 ; extra == 'dev'
|
|
29
|
+
Requires-Dist: mkdocs-material>=9.7.1 ; extra == 'dev'
|
|
30
|
+
Requires-Dist: mkdocstrings>=1.0.2 ; extra == 'dev'
|
|
31
|
+
Requires-Dist: mkdocstrings-python>=2.0.1 ; extra == 'dev'
|
|
32
|
+
Requires-Dist: safety>=3.0.0 ; extra == 'dev'
|
|
33
|
+
Requires-Dist: bandit>=1.8.0 ; extra == 'dev'
|
|
34
|
+
Requires-Python: >=3.13
|
|
35
|
+
Provides-Extra: dev
|
|
36
|
+
Description-Content-Type: text/markdown
|
|
37
|
+
|
|
38
|
+
# spotforecast2
|
|
39
|
+
|
|
40
|
+
[](https://www.python.org/downloads/)
|
|
41
|
+
[](https://pypi.org/project/spotforecast2/)
|
|
42
|
+
[](https://pypi.org/project/spotforecast2/)
|
|
43
|
+
[](https://github.com/sequential-parameter-optimization/spotforecast2/blob/main/LICENSE)
|
|
44
|
+
|
|
45
|
+
**Testing & Quality**
|
|
46
|
+
|
|
47
|
+
[](https://github.com/sequential-parameter-optimization/spotforecast2/actions/workflows/ci.yml)
|
|
48
|
+
[](https://sequential-parameter-optimization.github.io/spotforecast2/)
|
|
49
|
+
[](https://github.com/sequential-parameter-optimization/spotforecast2/releases)
|
|
50
|
+
|
|
51
|
+
**Status**
|
|
52
|
+
|
|
53
|
+
[](https://github.com/sequential-parameter-optimization/spotforecast2)
|
|
54
|
+
[](https://github.com/psf/black)
|
|
55
|
+
|
|
56
|
+
## About spotforecast2
|
|
57
|
+
|
|
58
|
+
`spotforecast2` is a Python library for time series forecasting.
|
|
59
|
+
|
|
60
|
+
Parts of the code are ported from `skforecast` to reduce external dependencies.
|
|
61
|
+
Many thanks to the [skforecast team](https://skforecast.org/0.20.0/more/about-skforecast.html) for their great work!
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
# License
|
|
65
|
+
|
|
66
|
+
`spotforecast2` software: [BSD-3-Clause License](https://github.com/sequential-parameter-optimization/spotforecast2?tab=BSD-3-Clause-1-ov-file)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
# References
|
|
70
|
+
|
|
71
|
+
## skforecast:
|
|
72
|
+
|
|
73
|
+
* Amat Rodrigo, J., & Escobar Ortiz, J. (2026). skforecast (Version 0.20.0) [Computer software]. https://doi.org/10.5281/zenodo.8382788
|
|
74
|
+
|
|
75
|
+
## spotoptim:
|
|
76
|
+
|
|
77
|
+
* [spotoptim documentation](https://sequential-parameter-optimization.github.io/spotoptim/)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# spotforecast2
|
|
2
|
+
|
|
3
|
+
[](https://www.python.org/downloads/)
|
|
4
|
+
[](https://pypi.org/project/spotforecast2/)
|
|
5
|
+
[](https://pypi.org/project/spotforecast2/)
|
|
6
|
+
[](https://github.com/sequential-parameter-optimization/spotforecast2/blob/main/LICENSE)
|
|
7
|
+
|
|
8
|
+
**Testing & Quality**
|
|
9
|
+
|
|
10
|
+
[](https://github.com/sequential-parameter-optimization/spotforecast2/actions/workflows/ci.yml)
|
|
11
|
+
[](https://sequential-parameter-optimization.github.io/spotforecast2/)
|
|
12
|
+
[](https://github.com/sequential-parameter-optimization/spotforecast2/releases)
|
|
13
|
+
|
|
14
|
+
**Status**
|
|
15
|
+
|
|
16
|
+
[](https://github.com/sequential-parameter-optimization/spotforecast2)
|
|
17
|
+
[](https://github.com/psf/black)
|
|
18
|
+
|
|
19
|
+
## About spotforecast2
|
|
20
|
+
|
|
21
|
+
`spotforecast2` is a Python library for time series forecasting.
|
|
22
|
+
|
|
23
|
+
Parts of the code are ported from `skforecast` to reduce external dependencies.
|
|
24
|
+
Many thanks to the [skforecast team](https://skforecast.org/0.20.0/more/about-skforecast.html) for their great work!
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
# License
|
|
28
|
+
|
|
29
|
+
`spotforecast2` software: [BSD-3-Clause License](https://github.com/sequential-parameter-optimization/spotforecast2?tab=BSD-3-Clause-1-ov-file)
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
# References
|
|
33
|
+
|
|
34
|
+
## skforecast:
|
|
35
|
+
|
|
36
|
+
* Amat Rodrigo, J., & Escobar Ortiz, J. (2026). skforecast (Version 0.20.0) [Computer software]. https://doi.org/10.5281/zenodo.8382788
|
|
37
|
+
|
|
38
|
+
## spotoptim:
|
|
39
|
+
|
|
40
|
+
* [spotoptim documentation](https://sequential-parameter-optimization.github.io/spotoptim/)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "spotforecast2"
|
|
3
|
-
version = "0.0.
|
|
3
|
+
version = "0.0.4"
|
|
4
4
|
description = "Forecasting with spot"
|
|
5
5
|
readme = "README.md"
|
|
6
6
|
authors = [
|
|
@@ -30,11 +30,17 @@ dependencies = [
|
|
|
30
30
|
requires = ["uv_build>=0.9.18,<0.10.0"]
|
|
31
31
|
build-backend = "uv_build"
|
|
32
32
|
|
|
33
|
-
[
|
|
33
|
+
[project.optional-dependencies]
|
|
34
34
|
dev = [
|
|
35
|
+
"pytest>=9.0.2",
|
|
36
|
+
"pytest-cov>=6.0.0",
|
|
37
|
+
"black>=24.1.0",
|
|
38
|
+
"isort>=5.13.0",
|
|
39
|
+
"ruff>=0.3.0",
|
|
35
40
|
"mkdocs>=1.6.1",
|
|
36
41
|
"mkdocs-material>=9.7.1",
|
|
37
42
|
"mkdocstrings>=1.0.2",
|
|
38
43
|
"mkdocstrings-python>=2.0.1",
|
|
39
|
-
"
|
|
44
|
+
"safety>=3.0.0",
|
|
45
|
+
"bandit>=1.8.0",
|
|
40
46
|
]
|
|
@@ -20,6 +20,11 @@ from spotforecast2.utils import (
|
|
|
20
20
|
)
|
|
21
21
|
from spotforecast2.exceptions import set_skforecast_warnings, UnknownLevelWarning
|
|
22
22
|
|
|
23
|
+
try:
|
|
24
|
+
from tqdm.auto import tqdm
|
|
25
|
+
except ImportError: # pragma: no cover - fallback when tqdm is not installed
|
|
26
|
+
tqdm = None
|
|
27
|
+
|
|
23
28
|
|
|
24
29
|
def check_preprocess_series(series):
|
|
25
30
|
pass
|
|
@@ -785,6 +790,7 @@ def predict_multivariate(
|
|
|
785
790
|
forecasters: dict[str, Any],
|
|
786
791
|
steps_ahead: int,
|
|
787
792
|
exog: pd.DataFrame | None = None,
|
|
793
|
+
show_progress: bool = False,
|
|
788
794
|
) -> pd.DataFrame:
|
|
789
795
|
"""
|
|
790
796
|
Generate multi-output predictions using multiple baseline forecasters.
|
|
@@ -796,6 +802,8 @@ def predict_multivariate(
|
|
|
796
802
|
steps_ahead (int): Number of steps to forecast.
|
|
797
803
|
exog (pd.DataFrame, optional): Exogenous variables for prediction.
|
|
798
804
|
If provided, will be passed to each forecaster's predict method.
|
|
805
|
+
show_progress (bool, optional): Show progress bar while predicting
|
|
806
|
+
per target forecaster. Default: False.
|
|
799
807
|
|
|
800
808
|
Returns:
|
|
801
809
|
pd.DataFrame: DataFrame with predictions for all targets.
|
|
@@ -824,7 +832,15 @@ def predict_multivariate(
|
|
|
824
832
|
|
|
825
833
|
predictions = {}
|
|
826
834
|
|
|
827
|
-
|
|
835
|
+
target_iter = forecasters.items()
|
|
836
|
+
if show_progress and tqdm is not None:
|
|
837
|
+
target_iter = tqdm(
|
|
838
|
+
forecasters.items(),
|
|
839
|
+
desc="Predicting targets",
|
|
840
|
+
unit="model",
|
|
841
|
+
)
|
|
842
|
+
|
|
843
|
+
for target, forecaster in target_iter:
|
|
828
844
|
# Generate predictions for this target
|
|
829
845
|
if exog is not None:
|
|
830
846
|
pred = forecaster.predict(steps=steps_ahead, exog=exog)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import pandas as pd
|
|
2
|
-
from typing import List, Optional
|
|
2
|
+
from typing import List, Optional
|
|
3
3
|
from spotforecast2.forecaster.recursive import ForecasterEquivalentDate
|
|
4
4
|
from spotforecast2.data.fetch_data import fetch_data
|
|
5
5
|
from spotforecast2.preprocessing.curate_data import basic_ts_checks
|
|
@@ -8,9 +8,13 @@ from spotforecast2.preprocessing.outlier import mark_outliers
|
|
|
8
8
|
|
|
9
9
|
from spotforecast2.preprocessing.split import split_rel_train_val_test
|
|
10
10
|
from spotforecast2.forecaster.utils import predict_multivariate
|
|
11
|
-
from spotforecast2.model_selection import TimeSeriesFold, backtesting_forecaster
|
|
12
11
|
from spotforecast2.preprocessing.curate_data import get_start_end
|
|
13
12
|
|
|
13
|
+
try:
|
|
14
|
+
from tqdm.auto import tqdm
|
|
15
|
+
except ImportError: # pragma: no cover - fallback when tqdm is not installed
|
|
16
|
+
tqdm = None
|
|
17
|
+
|
|
14
18
|
|
|
15
19
|
def n2n_predict(
|
|
16
20
|
columns: Optional[List[str]] = None,
|
|
@@ -18,22 +22,22 @@ def n2n_predict(
|
|
|
18
22
|
contamination: float = 0.01,
|
|
19
23
|
window_size: int = 72,
|
|
20
24
|
verbose: bool = True,
|
|
21
|
-
|
|
25
|
+
show_progress: bool = True,
|
|
26
|
+
) -> pd.DataFrame:
|
|
22
27
|
"""
|
|
23
28
|
End-to-end prediction function replicating the workflow from 01_base_predictor combined with fetch_data.
|
|
24
29
|
|
|
25
30
|
Args:
|
|
26
31
|
columns: List of target columns to forecast. If None, uses a default set (defined internally or from data).
|
|
27
|
-
Note: fetch_data
|
|
32
|
+
Note: fetch_data supports None to return all columns.
|
|
28
33
|
forecast_horizon: Number of steps to forecast.
|
|
29
34
|
contamination: Contamination factor for outlier detection.
|
|
30
35
|
window_size: Window size for weighting (not fully utilized in main flow but kept for consistency).
|
|
31
36
|
verbose: Whether to print progress logs.
|
|
37
|
+
show_progress: Show progress bar during training and prediction.
|
|
32
38
|
|
|
33
39
|
Returns:
|
|
34
|
-
|
|
35
|
-
- predictions (pd.DataFrame): The multi-output predictions.
|
|
36
|
-
- metrics (Optional[Dict]): Dictionary containing backtesting metrics if performed.
|
|
40
|
+
pd.DataFrame: The multi-output predictions.
|
|
37
41
|
"""
|
|
38
42
|
if columns is not None:
|
|
39
43
|
TARGET = columns
|
|
@@ -95,7 +99,11 @@ def n2n_predict(
|
|
|
95
99
|
|
|
96
100
|
baseline_forecasters = {}
|
|
97
101
|
|
|
98
|
-
|
|
102
|
+
target_iter = data.columns
|
|
103
|
+
if show_progress and tqdm is not None:
|
|
104
|
+
target_iter = tqdm(data.columns, desc="Training forecasters", unit="model")
|
|
105
|
+
|
|
106
|
+
for target in target_iter:
|
|
99
107
|
forecaster = ForecasterEquivalentDate(offset=pd.DateOffset(days=1), n_offsets=1)
|
|
100
108
|
|
|
101
109
|
forecaster.fit(y=data.loc[:end_validation, target])
|
|
@@ -105,13 +113,14 @@ def n2n_predict(
|
|
|
105
113
|
if verbose:
|
|
106
114
|
print("✓ Multi-output baseline system trained")
|
|
107
115
|
|
|
108
|
-
|
|
109
116
|
# --- Predict ---
|
|
110
117
|
if verbose:
|
|
111
118
|
print("Generating predictions...")
|
|
112
119
|
|
|
113
120
|
predictions = predict_multivariate(
|
|
114
|
-
baseline_forecasters,
|
|
121
|
+
baseline_forecasters,
|
|
122
|
+
steps_ahead=forecast_horizon,
|
|
123
|
+
show_progress=show_progress,
|
|
115
124
|
)
|
|
116
125
|
|
|
117
126
|
return predictions
|