PV-Forecasting Toolkit
Project description
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.
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 phorecast_ml-0.2.1.tar.gz.
File metadata
- Download URL: phorecast_ml-0.2.1.tar.gz
- Upload date:
- Size: 17.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e46ba686bb47b8317d55d86e6cbdc2c39d31a7d5d6559acd7c9a9e9f7f6e94b
|
|
| MD5 |
6476eb321433a781cc4d8567e70fe390
|
|
| BLAKE2b-256 |
eae5eb19d8db7ba96f77c50a8d4229f4661e5194f900727eed3c06936a695396
|
File details
Details for the file phorecast_ml-0.2.1-py3-none-any.whl.
File metadata
- Download URL: phorecast_ml-0.2.1-py3-none-any.whl
- Upload date:
- Size: 16.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b3fc04b2b22d1eb6754d2021e72dcab907c8b00737ac0f966102c32ca2fdef4
|
|
| MD5 |
2fd30ebacc84fb83d13e28e886e1577a
|
|
| BLAKE2b-256 |
3f6f6f2511d3490a390844fa74821f38af3b162fbd02656131eb5327721a8c75
|