spotopt: A Python library for converting deterministic forecasts into probabilistic ones.
Project description
spotopt
With spotopt, you can turn your determinstic day-ahead forecasts into probabilistic forecasts. spotopt builds on pandas and scikit-learn's quantile regression models (Lasso and Gradient Boosting).
Features
- Automized feature engineering: lagged observations, lagged daily min/max observations, and weekday dummies.
- Flexible input handling: Additional explanatory variables are allowed.
- Day light saving time (DST) handling for seamless time-index conversions.
- Configurable cross-validation (
cv) and hyperparameter search. - Configuration loaders (
SpotOptConfig.from_dict/.from_json) with strict typing.
Installation
pip install spotopt
Usage Example
Lasso quantile regression for hourly data with defined model hyperparameters
from spotopt import Frequency, SpotOptConfig, ModelName, SpotOptModel
config = SpotOptConfig(
model_name=ModelName.LASSO,
frequency=Frequency.H,
mdl_kwargs={"alpha": 0.1},
)
model = SpotOptModel(config)
model.fit(df_fit)
predictions = model.predict(df_predict)
Gradient boosting model for quarter-hourly data with hyperparameter search
from spotopt import Frequency, SpotOptConfig, ModelName, SpotOptModel
config = SpotOptConfig(
model_name=ModelName.GBR,
frequency=Frequency.QH,
run_hyperparam_search=True,
)
model = SpotOptModel(config)
model.fit(df_fit)
predictions = model.predict(df_predict)
Hyperparameter search
Hyperparameters currently implemented in the hyperparamter search:
- Lasso:
alpha - Gradient Boosting:
learning_rate,n_estimators
Current limitations
- Only CE(S)T supported.
- Only one day-ahead supported, not several days aheads.
- Fixed quantiles: 1, 5, 10, 25, 50, 75, 90, 95, 99 %.
Data Requirements
- Index name must be
delivery, timezoneCET, and composed of contiguous steps at the configured frequency (Frequency.H= 60 min,Frequency.QH= 15 min). - Required columns:
obs(historical outcomes) andfcast(determinstic forecast). Additional columns are allowed and will be cast tofloat.
Contributing
Contributions are welcome!
Developer tooling reference:
pytestfor testing.pytest-covfor analyzing test coverage.rufffor linting & formatting.tyfor type checking.uvfor project and dependency management.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spotopt-0.1.0.tar.gz.
File metadata
- Download URL: spotopt-0.1.0.tar.gz
- Upload date:
- Size: 11.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
441da2ba59282821ecc092229a9016df6db7785209f4aaf555f805d1fafb8b60
|
|
| MD5 |
1beb70e8ce3644b086837d8331275ee2
|
|
| BLAKE2b-256 |
38a58ccb103823f46f19fc84da9235d0f9f7d40502559aaca2528b1d8f3096f0
|
File details
Details for the file spotopt-0.1.0-py3-none-any.whl.
File metadata
- Download URL: spotopt-0.1.0-py3-none-any.whl
- Upload date:
- Size: 12.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67643ebc4a8492a9ab8a436ae94cdbd9fc78893a86ba6109d73f5183894807a9
|
|
| MD5 |
701e4d22d9f62c9a362d8d7acc3f875b
|
|
| BLAKE2b-256 |
e6b1a5eb922a6f3d43ca760988c397da62049544d6b32073e029823de4af82ac
|