Phorecast ML
A Python library for photovoltaic (PV) power forecasting using deep learning models and specialized time-series preprocessing tools.
The library provides modular building blocks for:
- preprocessing PV time-series data
- generating training datasets
- training deep learning forecasting models
- generating PV power forecasts
The current implementation includes an LSTM-based forecasting model built on TensorFlow / Keras.
Table of Contents
- Overview
- Features
- Architecture Overview
- Project Structure
- Installation
- Usage
- Example Workflow
- Dependencies
- Current Scope
- Running Tests
- Contributing
- License
Overview
phorecast_ml is designed as a machine learning foundation layer for photovoltaic forecasting.
It focuses on:
- preparing PV time-series datasets
- creating structured training data
- training deep learning forecasting models
The design follows a simple API pattern similar to scikit-learn, with methods such as fit() and predict().
This makes the models easy to integrate into forecasting pipelines.
Features
Forecasting Models
- LSTM-based neural network model
- configurable architecture
- training via TensorFlow/Keras
Data Processing
Tools for preparing time-series data:
- window generation
- dataset creation
- train/test splitting
- TensorFlow dataset generation
Solar Data Utilities
- solar position calculation using pvlib
- solar-based data filtering
- preprocessing utilities for photovoltaic datasets
Custom Evaluation
Includes custom metrics and loss functions:
wmapesum_difference
Architecture Overview
The library is structured into four main components:
Data Input
│
▼
Preprocessing
(windowing, filtering, solar features)
│
▼
Dataset Generation
(X / y creation)
│
▼
Deep Learning Model
(LSTM)
│
▼
Predictions
The architecture separates data preparation, model training, and forecast generation.
Project Structure
phorecast_ml/
__init__.py
model/
BaseModel.py
LSTM.py
__init__.py
preprocessing/
dataset.py
dataset_splitting.py
filtering.py
solar.py
windowing.py
metrics/
sum_difference.py
weighted_mean_absolute_percentage_error.py
losses/
sum_difference_loss.py
tests/
static.py
test_dataset.py
test_dataset.csv
pyproject.toml
requirements.txt
README.md
LICENSE
Installation
Requirements
- Python >= 3.12
Install from repository
git clone https://github.com/<organization>/phorecast-ml.git
cd phorecast-ml
pip install .
Install from PyPI (if published)
pip install phorecast-ml
Usage
Basic Model Training
import phorecast_ml
model = phorecast_ml.model.LSTM(
units=128,
depth=4,
learning_rate=1e-3,
epochs=100,
patience=10,
metrics=["mae", "wmape"],
)
model.fit(X_train, y_train)
predictions = model.predict(X_test)
Example Workflow
Typical forecasting pipeline:
- Prepare PV time-series data
- Attach solar position features
- Filter invalid or noisy data
- Generate time windows
- Convert windows into training datasets
- Train the forecasting model
- Generate predictions
Create Time Windows
from phorecast_ml.preprocessing.windowing import windowing, get_dataset_from_windows
windows = windowing(dataframe, window_size=24, stride=6, max_missing=6)
(X, y), indices = get_dataset_from_windows(
windows,
target="Target"
)
Attach Solar Features
from phorecast_ml.preprocessing.solar import attach_solar_positions
dataframe = attach_solar_positions(
data=dataframe,
latitude=0.0,
longitude=0.0,
height=0.0
)
Filter Dataset
from phorecast_ml.preprocessing.filtering import solar_position_filter
filtered = solar_position_filter(
data=dataframe,
independent_variables=["feature_1", "feature_2", "elevation"],
target="Target"
)
Train/Test Split
from phorecast_ml.preprocessing.dataset_splitting import split_windows
train_windows, test_windows = split_windows(
windows,
test_ratio=0.25,
weeks_in_test=1,
factor=7,
distinct=False
)
Dependencies
Primary dependencies:
- numpy
- pandas
- tensorflow
- keras
- pvlib
Additional libraries used in the code:
- scikit-learn (
sklearn.linear_model.LinearRegression)
Current Scope
The current implementation focuses on an LSTM-based forecasting model for photovoltaic power prediction.
The repository currently provides tools for:
- preprocessing photovoltaic time-series data
- generating training datasets
- training deep learning forecasting models
- generating predictions
Future improvements may include:
- additional forecasting model architectures
- expanded preprocessing utilities
- improved documentation
- additional unit tests
Running Tests
Tests can be executed using:
pytest
Contributing
Contributions are welcome.
Typical improvements include:
- improving documentation
- adding new forecasting models
- improving preprocessing pipelines
- adding unit tests
Suggested workflow:
fork repository
create feature branch
commit changes
submit pull request
License
This project is licensed under the terms specified in the LICENSE file.
Metadata
Release files for phorecast-ml 0.2.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| phorecast_ml-0.2.2.tar.gz | 17.2 kB | Without provenance | Details for phorecast_ml-0.2.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| phorecast_ml-0.2.2-py3-none-any.whl | Python 3 | none | any | Details for phorecast_ml-0.2.2-py3-none-any.whl |
Total release size: 33.6 kB
Release files / phorecast_ml-0.2.2.tar.gz
| Download URL | phorecast_ml-0.2.2.tar.gz |
|---|---|
| Size | 17.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
5583c3d47a184454275dbafa5779a8ca43cb4fbe28117072ed5a332bf1e75b40
|
|
BLAKE2b-256 checksum How to use checksums |
785c867122fda924c55f4ada94f1a73d15f0e53a41868ac64610a614883b4b92
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Release files / phorecast_ml-0.2.2-py3-none-any.whl
| Download URL | phorecast_ml-0.2.2-py3-none-any.whl |
|---|---|
| Size | 16.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e2cc2063a6e9117eda104fb8036046d72fa69f93fd8de32e1ab31163d339d263
|
|
BLAKE2b-256 checksum How to use checksums |
0c07a70cbb5c0a06babe96cb3a16524d36a8beb444d2da8fd8a4dc4de4823474
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.12.13
|
Security for phorecast-ml 0.2.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.