felits 0.1.0__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.
- felits-0.1.0/.gitignore +60 -0
- felits-0.1.0/LICENSE +21 -0
- felits-0.1.0/PKG-INFO +161 -0
- felits-0.1.0/README.md +106 -0
- felits-0.1.0/examples/README.md +23 -0
- felits-0.1.0/felits/__init__.py +161 -0
- felits-0.1.0/felits/_compat.py +173 -0
- felits-0.1.0/felits/data.py +89 -0
- felits-0.1.0/felits/feature_extraction/__init__.py +21 -0
- felits-0.1.0/felits/feature_extraction/automated.py +142 -0
- felits-0.1.0/felits/feature_extraction/spectral.py +133 -0
- felits-0.1.0/felits/feature_extraction/temporal.py +177 -0
- felits-0.1.0/felits/feature_selection/__init__.py +59 -0
- felits-0.1.0/felits/feature_selection/causal.py +167 -0
- felits-0.1.0/felits/feature_selection/ensemble.py +105 -0
- felits-0.1.0/felits/feature_selection/information.py +195 -0
- felits-0.1.0/felits/feature_selection/pipeline.py +154 -0
- felits-0.1.0/felits/feature_selection/regularization.py +171 -0
- felits-0.1.0/felits/feature_selection/xai.py +225 -0
- felits-0.1.0/felits/models/__init__.py +28 -0
- felits-0.1.0/felits/models/base.py +97 -0
- felits-0.1.0/felits/models/dl.py +127 -0
- felits-0.1.0/felits/models/sklearn.py +76 -0
- felits-0.1.0/felits/optimization.py +92 -0
- felits-0.1.0/felits/preprocessing/__init__.py +35 -0
- felits-0.1.0/felits/preprocessing/decomposition.py +119 -0
- felits-0.1.0/felits/preprocessing/imputation.py +67 -0
- felits-0.1.0/felits/preprocessing/metrics.py +119 -0
- felits-0.1.0/felits/preprocessing/outliers.py +109 -0
- felits-0.1.0/felits/preprocessing/scaling.py +153 -0
- felits-0.1.0/felits/xai.py +138 -0
- felits-0.1.0/pyproject.toml +140 -0
felits-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# Byte-compiled & caches
|
|
2
|
+
__pycache__/
|
|
3
|
+
*.py[cod]
|
|
4
|
+
*$py.class
|
|
5
|
+
*.so
|
|
6
|
+
.pytest_cache/
|
|
7
|
+
.ruff_cache/
|
|
8
|
+
.mypy_cache/
|
|
9
|
+
.hypothesis/
|
|
10
|
+
.tox/
|
|
11
|
+
.nox/
|
|
12
|
+
.coverage
|
|
13
|
+
coverage.xml
|
|
14
|
+
htmlcov/
|
|
15
|
+
|
|
16
|
+
# Virtual environments
|
|
17
|
+
.venv/
|
|
18
|
+
.venv*/
|
|
19
|
+
env/
|
|
20
|
+
venv/
|
|
21
|
+
|
|
22
|
+
# Distribution
|
|
23
|
+
build/
|
|
24
|
+
dist/
|
|
25
|
+
*.egg-info/
|
|
26
|
+
*.egg
|
|
27
|
+
.eggs/
|
|
28
|
+
|
|
29
|
+
# Jupyter
|
|
30
|
+
.ipynb_checkpoints/
|
|
31
|
+
|
|
32
|
+
# IDE
|
|
33
|
+
.vscode/
|
|
34
|
+
.idea/
|
|
35
|
+
.kilo/
|
|
36
|
+
*.swp
|
|
37
|
+
*.swo
|
|
38
|
+
*~
|
|
39
|
+
|
|
40
|
+
# OS
|
|
41
|
+
.DS_Store
|
|
42
|
+
Thumbs.db
|
|
43
|
+
|
|
44
|
+
# Data files (user-local)
|
|
45
|
+
dataset/
|
|
46
|
+
*.csv
|
|
47
|
+
*.parquet
|
|
48
|
+
*.h5
|
|
49
|
+
*.hdf5
|
|
50
|
+
|
|
51
|
+
# Lockfiles (libraries don't commit lockfiles)
|
|
52
|
+
uv.lock
|
|
53
|
+
Pipfile.lock
|
|
54
|
+
poetry.lock
|
|
55
|
+
|
|
56
|
+
# Python version file (user-local)
|
|
57
|
+
.python-version
|
|
58
|
+
|
|
59
|
+
# docs
|
|
60
|
+
research-docs/
|
felits-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Félix Morales Mareco
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
felits-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: felits
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Feature Engineering and Large-scale Integration for Time Series
|
|
5
|
+
Project-URL: Homepage, https://github.com/felits/felits
|
|
6
|
+
Project-URL: Issues, https://github.com/felits/felits/issues
|
|
7
|
+
Author: Félix Morales Mareco
|
|
8
|
+
License: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Keywords: feature-engineering,forecasting,machine-learning,time-series
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Science/Research
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
18
|
+
Classifier: Topic :: Scientific/Engineering
|
|
19
|
+
Requires-Python: <3.14,>=3.11
|
|
20
|
+
Requires-Dist: lime>=0.2.0.1
|
|
21
|
+
Requires-Dist: numpy>=1.24
|
|
22
|
+
Requires-Dist: optuna>=3.5
|
|
23
|
+
Requires-Dist: pandas>=2.0
|
|
24
|
+
Requires-Dist: polars>=1.0
|
|
25
|
+
Requires-Dist: pyarrow>=15.0
|
|
26
|
+
Requires-Dist: scikit-learn>=1.3
|
|
27
|
+
Requires-Dist: scipy>=1.11
|
|
28
|
+
Requires-Dist: shap>=0.44
|
|
29
|
+
Requires-Dist: statsmodels>=0.14
|
|
30
|
+
Requires-Dist: tsfresh>=0.20
|
|
31
|
+
Provides-Extra: all
|
|
32
|
+
Requires-Dist: duckdb>=1.0; extra == 'all'
|
|
33
|
+
Requires-Dist: pywavelets>=1.5; extra == 'all'
|
|
34
|
+
Requires-Dist: tensorflow>=2.15; extra == 'all'
|
|
35
|
+
Requires-Dist: xgboost>=2.0; extra == 'all'
|
|
36
|
+
Provides-Extra: dev
|
|
37
|
+
Requires-Dist: duckdb>=1.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: mypy>=1.8; extra == 'dev'
|
|
39
|
+
Requires-Dist: pre-commit>=3.6; extra == 'dev'
|
|
40
|
+
Requires-Dist: pytest-cov>=4.1; extra == 'dev'
|
|
41
|
+
Requires-Dist: pytest>=7.4; extra == 'dev'
|
|
42
|
+
Requires-Dist: pywavelets>=1.5; extra == 'dev'
|
|
43
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
44
|
+
Requires-Dist: types-pyyaml; extra == 'dev'
|
|
45
|
+
Requires-Dist: xgboost>=2.0; extra == 'dev'
|
|
46
|
+
Provides-Extra: dl
|
|
47
|
+
Requires-Dist: tensorflow>=2.15; extra == 'dl'
|
|
48
|
+
Provides-Extra: duckdb
|
|
49
|
+
Requires-Dist: duckdb>=1.0; extra == 'duckdb'
|
|
50
|
+
Provides-Extra: wavelet
|
|
51
|
+
Requires-Dist: pywavelets>=1.5; extra == 'wavelet'
|
|
52
|
+
Provides-Extra: xgb
|
|
53
|
+
Requires-Dist: xgboost>=2.0; extra == 'xgb'
|
|
54
|
+
Description-Content-Type: text/markdown
|
|
55
|
+
|
|
56
|
+
# FELITS: Feature Engineering and Large-scale Integration for Time Series
|
|
57
|
+
|
|
58
|
+
[](https://opensource.org/licenses/MIT)
|
|
59
|
+
[](https://www.python.org/downloads/)
|
|
60
|
+
|
|
61
|
+
FELITS is an open-source Python library for end-to-end **time series analysis and forecasting**, with a focus on **Short-Term Load Forecasting (STLF)**. It provides a complete pipeline: signal cleaning, feature engineering, feature selection, predictive modelling, and explainable AI (XAI).
|
|
62
|
+
|
|
63
|
+
The library is the result of the INIC01-6 research project (CONACYT, Paraguay) and was used to produce the methodology for a published research article.
|
|
64
|
+
|
|
65
|
+
## Highlights
|
|
66
|
+
|
|
67
|
+
- **Preprocessing** — outlier detection (IQR, Hampel/MAD, 3-sigma), STL decomposition, dual-scaler pattern
|
|
68
|
+
- **Feature extraction** — cyclic encodings, lag/shift features, rolling statistics, FFT, wavelets, tsfresh, FATS-style
|
|
69
|
+
- **Feature selection** — Granger causality, KSG mutual information, mRMR, Adaptive LASSO, RF/XGB importance
|
|
70
|
+
- **Models** — XGBoost, RandomForest, LinearRegression, plus `tf.keras` RNN models (LSTM/GRU/BiLSTM/BiGRU) and Bahdanau attention variants
|
|
71
|
+
- **XAI** — LIME, SHAP, and **Deep SHAP as a closed-loop meta-optimizer** for feature elimination
|
|
72
|
+
- **Optuna** hyperparameter optimization with multi-objective TPE sampler
|
|
73
|
+
- **Dual API** — all modules accept both `pandas` and `polars` DataFrames; internal logic uses `polars` for performance
|
|
74
|
+
|
|
75
|
+
## Requirements
|
|
76
|
+
|
|
77
|
+
- Python ≥3.11, <3.14 (TensorFlow requires ≤3.13)
|
|
78
|
+
- [uv](https://docs.astral.sh/uv/) (recommended) or pip
|
|
79
|
+
|
|
80
|
+
## Installation
|
|
81
|
+
|
|
82
|
+
```bash
|
|
83
|
+
git clone https://github.com/felits/felits.git
|
|
84
|
+
cd felits
|
|
85
|
+
|
|
86
|
+
# Create venv and install with uv (recommended)
|
|
87
|
+
uv venv --python 3.13
|
|
88
|
+
uv pip install -e ".[all,dev]"
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
### Extra dependency groups
|
|
92
|
+
|
|
93
|
+
| Extra | Includes |
|
|
94
|
+
|---|---|
|
|
95
|
+
| `[dl]` | TensorFlow for RNN/Attention models |
|
|
96
|
+
| `[xgb]` | XGBoost |
|
|
97
|
+
| `[wavelet]` | PyWavelets |
|
|
98
|
+
| `[duckdb]` | DuckDB for SQL-style batch feature engineering |
|
|
99
|
+
| `[all]` | Everything above |
|
|
100
|
+
|
|
101
|
+
### Python version management
|
|
102
|
+
|
|
103
|
+
uv handles Python downloads automatically. To switch Python versions:
|
|
104
|
+
|
|
105
|
+
```bash
|
|
106
|
+
uv python install 3.13 # download Python 3.13
|
|
107
|
+
uv venv --python 3.13 .venv # create a venv with it
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## Quickstart
|
|
111
|
+
|
|
112
|
+
```python
|
|
113
|
+
import polars as pl
|
|
114
|
+
from felits.preprocessing import HampelFilter, TimeSeriesScaler
|
|
115
|
+
from felits.feature_extraction import cyclical_encode, rolling_statistics
|
|
116
|
+
from felits.feature_selection import FeatureSelector
|
|
117
|
+
from felits.models import XGBoostForecaster
|
|
118
|
+
from felits import Metrics
|
|
119
|
+
|
|
120
|
+
df = pl.read_csv("demand.csv", try_parse_dates=True)
|
|
121
|
+
df = df.with_columns(
|
|
122
|
+
pl.Series("value_clean", HampelFilter(window_size=24).transform(df["value"]))
|
|
123
|
+
)
|
|
124
|
+
df = cyclical_encode(df, datetime_col="timestamp")
|
|
125
|
+
df = rolling_statistics(df, columns=["value_clean"], windows=[24, 168], stats=["mean", "std"])
|
|
126
|
+
|
|
127
|
+
model = XGBoostForecaster(n_estimators=500, max_depth=6)
|
|
128
|
+
model.fit(X_train, y_train)
|
|
129
|
+
preds = model.predict(X_test)
|
|
130
|
+
|
|
131
|
+
m = Metrics(y_test, preds)
|
|
132
|
+
print(m.dict_metrics())
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Project layout
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
felits/
|
|
139
|
+
├── _compat.py # pandas/polars compatibility layer
|
|
140
|
+
├── preprocessing/ # outliers, decomposition, scaling, imputation, metrics
|
|
141
|
+
├── feature_extraction/ # temporal, spectral, automated
|
|
142
|
+
├── feature_selection/ # causal, information, regularization, ensemble, xai
|
|
143
|
+
├── models/ # base, sklearn, dl (separate modules)
|
|
144
|
+
│ ├── base.py # _SklearnForecaster, TF detection
|
|
145
|
+
│ ├── sklearn.py # XGBoost/RF/Linear wrappers
|
|
146
|
+
│ └── dl.py # RNN/Attention models (requires TF)
|
|
147
|
+
├── optimization.py # Optuna wrappers
|
|
148
|
+
├── xai.py # LIME, SHAP, deep SHAP closed-loop
|
|
149
|
+
└── data.py # loaders and synthetic data
|
|
150
|
+
examples/ # Runnable .py example scripts
|
|
151
|
+
notebooks/ # Jupyter notebooks for each example
|
|
152
|
+
tests/ # pytest suite (79+ tests)
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
## Citation
|
|
156
|
+
|
|
157
|
+
If you use FELITS in academic work, please cite the associated research article (see `research-docs/`).
|
|
158
|
+
|
|
159
|
+
## License
|
|
160
|
+
|
|
161
|
+
MIT — see `LICENSE`.
|
felits-0.1.0/README.md
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# FELITS: Feature Engineering and Large-scale Integration for Time Series
|
|
2
|
+
|
|
3
|
+
[](https://opensource.org/licenses/MIT)
|
|
4
|
+
[](https://www.python.org/downloads/)
|
|
5
|
+
|
|
6
|
+
FELITS is an open-source Python library for end-to-end **time series analysis and forecasting**, with a focus on **Short-Term Load Forecasting (STLF)**. It provides a complete pipeline: signal cleaning, feature engineering, feature selection, predictive modelling, and explainable AI (XAI).
|
|
7
|
+
|
|
8
|
+
The library is the result of the INIC01-6 research project (CONACYT, Paraguay) and was used to produce the methodology for a published research article.
|
|
9
|
+
|
|
10
|
+
## Highlights
|
|
11
|
+
|
|
12
|
+
- **Preprocessing** — outlier detection (IQR, Hampel/MAD, 3-sigma), STL decomposition, dual-scaler pattern
|
|
13
|
+
- **Feature extraction** — cyclic encodings, lag/shift features, rolling statistics, FFT, wavelets, tsfresh, FATS-style
|
|
14
|
+
- **Feature selection** — Granger causality, KSG mutual information, mRMR, Adaptive LASSO, RF/XGB importance
|
|
15
|
+
- **Models** — XGBoost, RandomForest, LinearRegression, plus `tf.keras` RNN models (LSTM/GRU/BiLSTM/BiGRU) and Bahdanau attention variants
|
|
16
|
+
- **XAI** — LIME, SHAP, and **Deep SHAP as a closed-loop meta-optimizer** for feature elimination
|
|
17
|
+
- **Optuna** hyperparameter optimization with multi-objective TPE sampler
|
|
18
|
+
- **Dual API** — all modules accept both `pandas` and `polars` DataFrames; internal logic uses `polars` for performance
|
|
19
|
+
|
|
20
|
+
## Requirements
|
|
21
|
+
|
|
22
|
+
- Python ≥3.11, <3.14 (TensorFlow requires ≤3.13)
|
|
23
|
+
- [uv](https://docs.astral.sh/uv/) (recommended) or pip
|
|
24
|
+
|
|
25
|
+
## Installation
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
git clone https://github.com/felits/felits.git
|
|
29
|
+
cd felits
|
|
30
|
+
|
|
31
|
+
# Create venv and install with uv (recommended)
|
|
32
|
+
uv venv --python 3.13
|
|
33
|
+
uv pip install -e ".[all,dev]"
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Extra dependency groups
|
|
37
|
+
|
|
38
|
+
| Extra | Includes |
|
|
39
|
+
|---|---|
|
|
40
|
+
| `[dl]` | TensorFlow for RNN/Attention models |
|
|
41
|
+
| `[xgb]` | XGBoost |
|
|
42
|
+
| `[wavelet]` | PyWavelets |
|
|
43
|
+
| `[duckdb]` | DuckDB for SQL-style batch feature engineering |
|
|
44
|
+
| `[all]` | Everything above |
|
|
45
|
+
|
|
46
|
+
### Python version management
|
|
47
|
+
|
|
48
|
+
uv handles Python downloads automatically. To switch Python versions:
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
uv python install 3.13 # download Python 3.13
|
|
52
|
+
uv venv --python 3.13 .venv # create a venv with it
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Quickstart
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
import polars as pl
|
|
59
|
+
from felits.preprocessing import HampelFilter, TimeSeriesScaler
|
|
60
|
+
from felits.feature_extraction import cyclical_encode, rolling_statistics
|
|
61
|
+
from felits.feature_selection import FeatureSelector
|
|
62
|
+
from felits.models import XGBoostForecaster
|
|
63
|
+
from felits import Metrics
|
|
64
|
+
|
|
65
|
+
df = pl.read_csv("demand.csv", try_parse_dates=True)
|
|
66
|
+
df = df.with_columns(
|
|
67
|
+
pl.Series("value_clean", HampelFilter(window_size=24).transform(df["value"]))
|
|
68
|
+
)
|
|
69
|
+
df = cyclical_encode(df, datetime_col="timestamp")
|
|
70
|
+
df = rolling_statistics(df, columns=["value_clean"], windows=[24, 168], stats=["mean", "std"])
|
|
71
|
+
|
|
72
|
+
model = XGBoostForecaster(n_estimators=500, max_depth=6)
|
|
73
|
+
model.fit(X_train, y_train)
|
|
74
|
+
preds = model.predict(X_test)
|
|
75
|
+
|
|
76
|
+
m = Metrics(y_test, preds)
|
|
77
|
+
print(m.dict_metrics())
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Project layout
|
|
81
|
+
|
|
82
|
+
```
|
|
83
|
+
felits/
|
|
84
|
+
├── _compat.py # pandas/polars compatibility layer
|
|
85
|
+
├── preprocessing/ # outliers, decomposition, scaling, imputation, metrics
|
|
86
|
+
├── feature_extraction/ # temporal, spectral, automated
|
|
87
|
+
├── feature_selection/ # causal, information, regularization, ensemble, xai
|
|
88
|
+
├── models/ # base, sklearn, dl (separate modules)
|
|
89
|
+
│ ├── base.py # _SklearnForecaster, TF detection
|
|
90
|
+
│ ├── sklearn.py # XGBoost/RF/Linear wrappers
|
|
91
|
+
│ └── dl.py # RNN/Attention models (requires TF)
|
|
92
|
+
├── optimization.py # Optuna wrappers
|
|
93
|
+
├── xai.py # LIME, SHAP, deep SHAP closed-loop
|
|
94
|
+
└── data.py # loaders and synthetic data
|
|
95
|
+
examples/ # Runnable .py example scripts
|
|
96
|
+
notebooks/ # Jupyter notebooks for each example
|
|
97
|
+
tests/ # pytest suite (79+ tests)
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Citation
|
|
101
|
+
|
|
102
|
+
If you use FELITS in academic work, please cite the associated research article (see `research-docs/`).
|
|
103
|
+
|
|
104
|
+
## License
|
|
105
|
+
|
|
106
|
+
MIT — see `LICENSE`.
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# FELITS examples
|
|
2
|
+
|
|
3
|
+
Each example is available as both a runnable Python script (`.py`) and a
|
|
4
|
+
Jupyter notebook (`.ipynb`). The `.py` scripts are the canonical versions;
|
|
5
|
+
the notebooks are generated from them.
|
|
6
|
+
|
|
7
|
+
| # | Topic | Script | Notebook |
|
|
8
|
+
|---|-------|--------|----------|
|
|
9
|
+
| 01 | Preprocessing (outliers, STL, scaling) | [`01_preprocessing.py`](01_preprocessing.py) | [`notebooks/01_preprocessing.ipynb`](../notebooks/01_preprocessing.ipynb) |
|
|
10
|
+
| 02 | Feature extraction (temporal, spectral, tsfresh) | [`02_feature_extraction.py`](02_feature_extraction.py) | [`notebooks/02_feature_extraction.ipynb`](../notebooks/02_feature_extraction.ipynb) |
|
|
11
|
+
| 03 | Feature selection (Granger, MI, LASSO, SHAP) | [`03_feature_selection.py`](03_feature_selection.py) | [`notebooks/03_feature_selection.ipynb`](../notebooks/03_feature_selection.ipynb) |
|
|
12
|
+
| 04 | Deep-learning models (LSTM, GRU, attention) | [`04_deep_learning_models.py`](04_deep_learning_models.py) | [`notebooks/04_deep_learning_models.ipynb`](../notebooks/04_deep_learning_models.ipynb) |
|
|
13
|
+
| 05 | XAI explainability (SHAP, LIME, closed-loop) | [`05_xai_explainability.py`](05_xai_explainability.py) | [`notebooks/05_xai_explainability.ipynb`](../notebooks/05_xai_explainability.ipynb) |
|
|
14
|
+
| 06 | Full STLF pipeline | [`06_full_pipeline.py`](06_full_pipeline.py) | [`notebooks/06_full_pipeline.ipynb`](../notebooks/06_full_pipeline.ipynb) |
|
|
15
|
+
|
|
16
|
+
Run any script with:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
uv run python examples/01_preprocessing.py
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The deep-learning examples (#04, #06) require the optional `[dl]` extra
|
|
23
|
+
and a working TensorFlow installation.
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"""FELITS: Feature Engineering and Large-scale Integration for Time Series.
|
|
2
|
+
|
|
3
|
+
Top-level package exposing the most commonly used classes and functions
|
|
4
|
+
through a flat, ergonomic API::
|
|
5
|
+
|
|
6
|
+
from felits import (
|
|
7
|
+
HampelFilter, TimeSeriesScaler, SlidingWindowSplitter, Metrics,
|
|
8
|
+
cyclical_encode, fft_features, tsfresh_extract,
|
|
9
|
+
FeatureSelector, granger_feature_selection, shap_feature_selection,
|
|
10
|
+
XGBoostForecaster, RandomForestForecaster, RNNBasedModel,
|
|
11
|
+
OptunaOptimizer, deep_shap_selector,
|
|
12
|
+
)
|
|
13
|
+
|
|
14
|
+
Submodules are still importable for advanced use::
|
|
15
|
+
|
|
16
|
+
from felits.preprocessing import iqr_outlier_detection
|
|
17
|
+
from felits.feature_selection import mrmr_selection
|
|
18
|
+
"""
|
|
19
|
+
|
|
20
|
+
from __future__ import annotations
|
|
21
|
+
|
|
22
|
+
from . import data, models, optimization
|
|
23
|
+
from .feature_extraction import (
|
|
24
|
+
cyclical_encode,
|
|
25
|
+
extract_all_features,
|
|
26
|
+
fats_extract,
|
|
27
|
+
fft_features,
|
|
28
|
+
lag_features,
|
|
29
|
+
rolling_statistics,
|
|
30
|
+
shift_features,
|
|
31
|
+
spectral_entropy,
|
|
32
|
+
tsfresh_extract,
|
|
33
|
+
wavelet_features,
|
|
34
|
+
)
|
|
35
|
+
from .feature_selection import (
|
|
36
|
+
FeatureSelector,
|
|
37
|
+
adaptive_lasso_selection,
|
|
38
|
+
elastic_net_selection,
|
|
39
|
+
granger_feature_selection,
|
|
40
|
+
lasso_selection,
|
|
41
|
+
lime_explain_instance,
|
|
42
|
+
mrmr_selection,
|
|
43
|
+
mutual_information_ksg,
|
|
44
|
+
permutation_importance_selection,
|
|
45
|
+
rf_importance_selection,
|
|
46
|
+
select_features,
|
|
47
|
+
shap_feature_selection,
|
|
48
|
+
shap_interaction_selection,
|
|
49
|
+
xgboost_importance_selection,
|
|
50
|
+
)
|
|
51
|
+
from .optimization import OptunaOptimizer
|
|
52
|
+
from .preprocessing import (
|
|
53
|
+
DecompositionResult,
|
|
54
|
+
HampelFilter,
|
|
55
|
+
Metrics,
|
|
56
|
+
SlidingWindowSplitter,
|
|
57
|
+
TimeSeriesScaler,
|
|
58
|
+
forward_fill,
|
|
59
|
+
hampel_filter,
|
|
60
|
+
iqr_outlier_detection,
|
|
61
|
+
linear_interpolate,
|
|
62
|
+
mae,
|
|
63
|
+
mape,
|
|
64
|
+
max_error,
|
|
65
|
+
mse,
|
|
66
|
+
r2,
|
|
67
|
+
rmse,
|
|
68
|
+
seasonal_adjust,
|
|
69
|
+
smape,
|
|
70
|
+
stl_decompose,
|
|
71
|
+
three_sigma_filter,
|
|
72
|
+
time_aware_interpolate,
|
|
73
|
+
)
|
|
74
|
+
from .xai import deep_shap_selector, explain_forecast
|
|
75
|
+
|
|
76
|
+
__version__ = "0.1.0"
|
|
77
|
+
__author__ = "Félix Morales Mareco"
|
|
78
|
+
__license__ = "MIT"
|
|
79
|
+
|
|
80
|
+
__all__ = [
|
|
81
|
+
"__version__",
|
|
82
|
+
"__author__",
|
|
83
|
+
"__license__",
|
|
84
|
+
# data
|
|
85
|
+
"data",
|
|
86
|
+
"models",
|
|
87
|
+
"optimization",
|
|
88
|
+
# preprocessing
|
|
89
|
+
"DecompositionResult",
|
|
90
|
+
"HampelFilter",
|
|
91
|
+
"Metrics",
|
|
92
|
+
"SlidingWindowSplitter",
|
|
93
|
+
"TimeSeriesScaler",
|
|
94
|
+
"forward_fill",
|
|
95
|
+
"hampel_filter",
|
|
96
|
+
"iqr_outlier_detection",
|
|
97
|
+
"linear_interpolate",
|
|
98
|
+
"mae",
|
|
99
|
+
"mape",
|
|
100
|
+
"max_error",
|
|
101
|
+
"mse",
|
|
102
|
+
"r2",
|
|
103
|
+
"rmse",
|
|
104
|
+
"seasonal_adjust",
|
|
105
|
+
"smape",
|
|
106
|
+
"stl_decompose",
|
|
107
|
+
"three_sigma_filter",
|
|
108
|
+
"time_aware_interpolate",
|
|
109
|
+
# feature_extraction
|
|
110
|
+
"cyclical_encode",
|
|
111
|
+
"extract_all_features",
|
|
112
|
+
"fats_extract",
|
|
113
|
+
"fft_features",
|
|
114
|
+
"lag_features",
|
|
115
|
+
"rolling_statistics",
|
|
116
|
+
"shift_features",
|
|
117
|
+
"spectral_entropy",
|
|
118
|
+
"tsfresh_extract",
|
|
119
|
+
"wavelet_features",
|
|
120
|
+
# feature_selection
|
|
121
|
+
"FeatureSelector",
|
|
122
|
+
"adaptive_lasso_selection",
|
|
123
|
+
"elastic_net_selection",
|
|
124
|
+
"granger_feature_selection",
|
|
125
|
+
"lasso_selection",
|
|
126
|
+
"lime_explain_instance",
|
|
127
|
+
"mrmr_selection",
|
|
128
|
+
"mutual_information_ksg",
|
|
129
|
+
"permutation_importance_selection",
|
|
130
|
+
"rf_importance_selection",
|
|
131
|
+
"select_features",
|
|
132
|
+
"shap_feature_selection",
|
|
133
|
+
"shap_interaction_selection",
|
|
134
|
+
"xgboost_importance_selection",
|
|
135
|
+
# optimization
|
|
136
|
+
"OptunaOptimizer",
|
|
137
|
+
# xai
|
|
138
|
+
"deep_shap_selector",
|
|
139
|
+
"explain_forecast",
|
|
140
|
+
]
|
|
141
|
+
|
|
142
|
+
# Re-export the DL models and sklearn forecasters at the top level
|
|
143
|
+
from .models import (
|
|
144
|
+
BahdanauAttention,
|
|
145
|
+
LinearForecaster,
|
|
146
|
+
RandomForestForecaster,
|
|
147
|
+
RNNAttentionModel,
|
|
148
|
+
RNNBasedModel,
|
|
149
|
+
XGBoostForecaster,
|
|
150
|
+
is_dl_available,
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
__all__ += [
|
|
154
|
+
"BahdanauAttention",
|
|
155
|
+
"LinearForecaster",
|
|
156
|
+
"RNNAttentionModel",
|
|
157
|
+
"RNNBasedModel",
|
|
158
|
+
"RandomForestForecaster",
|
|
159
|
+
"XGBoostForecaster",
|
|
160
|
+
"is_dl_available",
|
|
161
|
+
]
|