spotforecast2 0.2.0__tar.gz → 0.2.2__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.2.0 → spotforecast2-0.2.2}/PKG-INFO +1 -1
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/pyproject.toml +1 -1
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/data/fetch_data.py +57 -24
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/processing/n2n_predict.py +6 -4
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/processing/n2n_predict_with_covariates.py +9 -1
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/README.md +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/__init__.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/data/__init__.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/data/data.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/exceptions.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/forecaster/__init__.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/forecaster/base.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/forecaster/metrics.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/forecaster/recursive/__init__.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/forecaster/recursive/_forecaster_equivalent_date.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/forecaster/recursive/_forecaster_recursive.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/forecaster/recursive/_warnings.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/forecaster/utils.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/model_selection/__init__.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/model_selection/bayesian_search.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/model_selection/grid_search.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/model_selection/random_search.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/model_selection/split_base.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/model_selection/split_one_step.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/model_selection/split_ts_cv.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/model_selection/utils_common.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/model_selection/utils_metrics.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/model_selection/validation.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/preprocessing/__init__.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/preprocessing/_binner.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/preprocessing/_common.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/preprocessing/_differentiator.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/preprocessing/_rolling.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/preprocessing/curate_data.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/preprocessing/imputation.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/preprocessing/outlier.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/preprocessing/split.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/processing/agg_predict.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/py.typed +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/utils/__init__.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/utils/convert_to_utc.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/utils/data_transform.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/utils/forecaster_config.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/utils/generate_holiday.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/utils/validation.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/weather/__init__.py +0 -0
- {spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/weather/weather_client.py +0 -0
|
@@ -44,57 +44,90 @@ def get_data_home(data_home: Optional[Union[str, Path]] = None) -> Path:
|
|
|
44
44
|
|
|
45
45
|
|
|
46
46
|
def fetch_data(
|
|
47
|
-
filename: str =
|
|
47
|
+
filename: Optional[str] = None,
|
|
48
|
+
dataframe: Optional[pd.DataFrame] = None,
|
|
48
49
|
columns: Optional[list] = None,
|
|
49
50
|
index_col: int = 0,
|
|
50
51
|
parse_dates: bool = True,
|
|
51
52
|
dayfirst: bool = False,
|
|
52
53
|
timezone: str = "UTC",
|
|
53
54
|
) -> pd.DataFrame:
|
|
54
|
-
"""Fetches the integrated raw dataset from a CSV file.
|
|
55
|
+
"""Fetches the integrated raw dataset from a CSV file or processes a DataFrame.
|
|
55
56
|
|
|
56
57
|
Args:
|
|
57
|
-
filename (str):
|
|
58
|
-
Filename of the CSV file containing the dataset.
|
|
58
|
+
filename (str, optional):
|
|
59
|
+
Filename of the CSV file containing the dataset. Must be located in the
|
|
60
|
+
data home directory. If both filename and dataframe are None, defaults to "data_in.csv".
|
|
61
|
+
dataframe (pd.DataFrame, optional):
|
|
62
|
+
A pandas DataFrame to process. If provided, it will be processed with
|
|
63
|
+
proper timezone handling. Mutually exclusive with filename.
|
|
59
64
|
columns (list, optional):
|
|
60
65
|
List of columns to be included in the dataset. If None, all columns are included.
|
|
61
|
-
If an empty list is provided, a ValueError is
|
|
66
|
+
If an empty list is provided, a ValueError is raised.
|
|
62
67
|
index_col (int):
|
|
63
|
-
Column index to be used as the index.
|
|
68
|
+
Column index to be used as the index (only used when loading from CSV).
|
|
64
69
|
parse_dates (bool):
|
|
65
|
-
Whether to parse dates in the index column.
|
|
70
|
+
Whether to parse dates in the index column (only used when loading from CSV).
|
|
66
71
|
dayfirst (bool):
|
|
67
|
-
Whether the day comes first in date parsing.
|
|
72
|
+
Whether the day comes first in date parsing (only used when loading from CSV).
|
|
68
73
|
timezone (str):
|
|
69
|
-
Timezone to set for the datetime index.
|
|
74
|
+
Timezone to set for the datetime index. If a DataFrame with naive index is provided,
|
|
75
|
+
it will be localized to this timezone then converted to UTC. Default: "UTC".
|
|
70
76
|
|
|
71
77
|
Returns:
|
|
72
|
-
pd.DataFrame: The integrated raw dataset.
|
|
78
|
+
pd.DataFrame: The integrated raw dataset with UTC timezone.
|
|
73
79
|
|
|
74
80
|
Raises:
|
|
75
|
-
ValueError: If columns is an empty list.
|
|
81
|
+
ValueError: If columns is an empty list or if both filename and dataframe are provided.
|
|
82
|
+
FileNotFoundError: If CSV file does not exist.
|
|
76
83
|
|
|
77
84
|
Examples:
|
|
85
|
+
Load from CSV (default):
|
|
78
86
|
>>> from spotforecast2.data.fetch_data import fetch_data
|
|
79
87
|
>>> data = fetch_data(columns=["col1", "col2"])
|
|
80
88
|
>>> data.head()
|
|
81
89
|
Header1 Header2 Header3
|
|
90
|
+
|
|
91
|
+
Load from specific CSV:
|
|
92
|
+
>>> data = fetch_data(filename="custom_data.csv")
|
|
93
|
+
|
|
94
|
+
Process a DataFrame:
|
|
95
|
+
>>> import pandas as pd
|
|
96
|
+
>>> df = pd.DataFrame({"value": [1, 2, 3]},
|
|
97
|
+
... index=pd.date_range("2024-01-01", periods=3, freq="h"))
|
|
98
|
+
>>> data = fetch_data(dataframe=df, timezone="Europe/Berlin")
|
|
99
|
+
>>> data.index.tz
|
|
100
|
+
<UTC>
|
|
82
101
|
"""
|
|
83
102
|
if columns is not None and len(columns) == 0:
|
|
84
103
|
raise ValueError("columns must be specified and cannot be empty.")
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
104
|
+
|
|
105
|
+
if filename is not None and dataframe is not None:
|
|
106
|
+
raise ValueError("Cannot specify both filename and dataframe. Please provide only one.")
|
|
107
|
+
|
|
108
|
+
# Process DataFrame if provided
|
|
109
|
+
if dataframe is not None:
|
|
110
|
+
dataset = Data.from_dataframe(
|
|
111
|
+
df=dataframe,
|
|
112
|
+
timezone=timezone,
|
|
113
|
+
columns=columns,
|
|
114
|
+
)
|
|
115
|
+
else:
|
|
116
|
+
# Load from CSV file
|
|
117
|
+
if filename is None:
|
|
118
|
+
filename = "data_in.csv"
|
|
119
|
+
csv_path = get_data_home() / filename
|
|
120
|
+
if not Path(csv_path).is_file():
|
|
121
|
+
raise FileNotFoundError(f"The file {csv_path} does not exist.")
|
|
122
|
+
|
|
123
|
+
dataset = Data.from_csv(
|
|
124
|
+
csv_path=csv_path,
|
|
125
|
+
index_col=index_col,
|
|
126
|
+
parse_dates=parse_dates,
|
|
127
|
+
dayfirst=dayfirst,
|
|
128
|
+
timezone=timezone,
|
|
129
|
+
columns=columns,
|
|
130
|
+
)
|
|
98
131
|
|
|
99
132
|
return dataset.data
|
|
100
133
|
|
|
@@ -314,13 +314,15 @@ def n2n_predict(
|
|
|
314
314
|
|
|
315
315
|
if verbose:
|
|
316
316
|
print("--- Starting n2n_predict ---")
|
|
317
|
-
print("Fetching data...")
|
|
318
317
|
|
|
319
|
-
#
|
|
318
|
+
# Handle data input - fetch_data handles both CSV and DataFrame
|
|
320
319
|
if data is not None:
|
|
321
|
-
if
|
|
322
|
-
|
|
320
|
+
if verbose:
|
|
321
|
+
print("Using provided dataframe...")
|
|
322
|
+
data = fetch_data(dataframe=data, columns=TARGET)
|
|
323
323
|
else:
|
|
324
|
+
if verbose:
|
|
325
|
+
print("Fetching data from CSV...")
|
|
324
326
|
data = fetch_data(columns=TARGET)
|
|
325
327
|
|
|
326
328
|
START, END, COV_START, COV_END = get_start_end(
|
|
@@ -868,8 +868,16 @@ def n2n_predict_with_covariates(
|
|
|
868
868
|
if verbose:
|
|
869
869
|
print("\n[1/9] Loading and preparing target data...")
|
|
870
870
|
|
|
871
|
+
# Handle data input - fetch_data handles both CSV and DataFrame
|
|
871
872
|
if data is None:
|
|
872
|
-
|
|
873
|
+
if verbose:
|
|
874
|
+
print(" Fetching data from CSV...")
|
|
875
|
+
data = fetch_data(timezone=timezone)
|
|
876
|
+
else:
|
|
877
|
+
if verbose:
|
|
878
|
+
print(" Using provided dataframe...")
|
|
879
|
+
data = fetch_data(dataframe=data, timezone=timezone)
|
|
880
|
+
|
|
873
881
|
target_columns = data.columns.tolist()
|
|
874
882
|
|
|
875
883
|
if verbose:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/forecaster/recursive/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/forecaster/recursive/_warnings.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/model_selection/bayesian_search.py
RENAMED
|
File without changes
|
{spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/model_selection/grid_search.py
RENAMED
|
File without changes
|
{spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/model_selection/random_search.py
RENAMED
|
File without changes
|
|
File without changes
|
{spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/model_selection/split_one_step.py
RENAMED
|
File without changes
|
{spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/model_selection/split_ts_cv.py
RENAMED
|
File without changes
|
{spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/model_selection/utils_common.py
RENAMED
|
File without changes
|
{spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/model_selection/utils_metrics.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{spotforecast2-0.2.0 → spotforecast2-0.2.2}/src/spotforecast2/preprocessing/_differentiator.py
RENAMED
|
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
|