funcast 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.
- funcast-0.1.0/.github/workflows/ci.yml +70 -0
- funcast-0.1.0/.gitignore +23 -0
- funcast-0.1.0/CHANGELOG.md +0 -0
- funcast-0.1.0/LICENSE +9 -0
- funcast-0.1.0/PKG-INFO +80 -0
- funcast-0.1.0/README.md +32 -0
- funcast-0.1.0/docs/.gitkeep +0 -0
- funcast-0.1.0/docs/Makefile +20 -0
- funcast-0.1.0/docs/make.bat +35 -0
- funcast-0.1.0/docs/source/api/basis.rst +7 -0
- funcast-0.1.0/docs/source/api/funcast.rst +7 -0
- funcast-0.1.0/docs/source/api/selection.rst +7 -0
- funcast-0.1.0/docs/source/changelog.md +4 -0
- funcast-0.1.0/docs/source/conf.py +73 -0
- funcast-0.1.0/docs/source/contributing.md +33 -0
- funcast-0.1.0/docs/source/index.rst +35 -0
- funcast-0.1.0/docs/source/installation.md +21 -0
- funcast-0.1.0/docs/source/quickstart.md +36 -0
- funcast-0.1.0/docs/source/userguide/basis.md +69 -0
- funcast-0.1.0/docs/source/userguide/model.md +63 -0
- funcast-0.1.0/docs/source/userguide/selection.md +57 -0
- funcast-0.1.0/examples/.gitkeep +0 -0
- funcast-0.1.0/examples/01_basic_usage.py +86 -0
- funcast-0.1.0/examples/02_with_covariates.py +104 -0
- funcast-0.1.0/examples/README.md +0 -0
- funcast-0.1.0/pyproject.toml +113 -0
- funcast-0.1.0/src/funcast/__init__.py +19 -0
- funcast-0.1.0/src/funcast/basis.py +102 -0
- funcast-0.1.0/src/funcast/model.py +347 -0
- funcast-0.1.0/src/funcast/selection.py +73 -0
- funcast-0.1.0/tests/test_basis.py +138 -0
- funcast-0.1.0/tests/test_model.py +209 -0
- funcast-0.1.0/tests/test_selection.py +79 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [main]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [main]
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
# Job 1: code quality (ruff and mypy)
|
|
11
|
+
# -----------------------------------
|
|
12
|
+
quality:
|
|
13
|
+
name: Code Quality
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
|
|
16
|
+
steps:
|
|
17
|
+
- name: Checkout du code
|
|
18
|
+
uses: actions/checkout@v4
|
|
19
|
+
|
|
20
|
+
- name: Installation de Python
|
|
21
|
+
uses: actions/setup-python@v5
|
|
22
|
+
with:
|
|
23
|
+
python-version: "3.12"
|
|
24
|
+
|
|
25
|
+
- name: Installation des dépendances
|
|
26
|
+
run: |
|
|
27
|
+
python -m pip install --upgrade pip
|
|
28
|
+
pip install -e ".[dev]"
|
|
29
|
+
|
|
30
|
+
- name: Ruff — vérification du linting
|
|
31
|
+
run: ruff check src/ tests/
|
|
32
|
+
|
|
33
|
+
- name: Ruff — vérification du formatage
|
|
34
|
+
run: ruff format --check src/ tests/
|
|
35
|
+
|
|
36
|
+
- name: Mypy — vérification des types
|
|
37
|
+
run: mypy src/funcast/
|
|
38
|
+
|
|
39
|
+
# Job 2: Tests on Python 3.10, 3.11 and 3.12
|
|
40
|
+
# ------------------------------------------
|
|
41
|
+
tests:
|
|
42
|
+
name: Tests (Python ${{ matrix.python-version }})
|
|
43
|
+
runs-on: ubuntu-latest
|
|
44
|
+
strategy:
|
|
45
|
+
fail-fast: false
|
|
46
|
+
matrix:
|
|
47
|
+
python-version: ["3.10", "3.11", "3.12"]
|
|
48
|
+
|
|
49
|
+
steps:
|
|
50
|
+
- name: Checkout du code
|
|
51
|
+
uses: actions/checkout@v4
|
|
52
|
+
|
|
53
|
+
- name: Installation de Python ${{ matrix.python-version }}
|
|
54
|
+
uses: actions/setup-python@v5
|
|
55
|
+
with:
|
|
56
|
+
python-version: ${{ matrix.python-version }}
|
|
57
|
+
|
|
58
|
+
- name: Installation des dépendances
|
|
59
|
+
run: |
|
|
60
|
+
python -m pip install --upgrade pip
|
|
61
|
+
pip install -e ".[dev]"
|
|
62
|
+
|
|
63
|
+
- name: Lancement des tests avec pytest
|
|
64
|
+
run: pytest
|
|
65
|
+
|
|
66
|
+
- name: Upload du rapport de couverture
|
|
67
|
+
uses: actions/upload-artifact@v4
|
|
68
|
+
with:
|
|
69
|
+
name: coverage-${{ matrix.python-version }}
|
|
70
|
+
path: .coverage
|
funcast-0.1.0/.gitignore
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
venv/
|
|
2
|
+
.venv/
|
|
3
|
+
env/
|
|
4
|
+
.env/
|
|
5
|
+
__pycache__/
|
|
6
|
+
*.py[cod]
|
|
7
|
+
*.egg-info/
|
|
8
|
+
dist/
|
|
9
|
+
build/
|
|
10
|
+
*.egg
|
|
11
|
+
.mypy_cache/
|
|
12
|
+
.ruff_cache/
|
|
13
|
+
.pytest_cache/
|
|
14
|
+
.coverage
|
|
15
|
+
htmlcov/
|
|
16
|
+
.vscode/
|
|
17
|
+
.idea/
|
|
18
|
+
.DS_Store
|
|
19
|
+
Thumbs.db
|
|
20
|
+
examples/*.png
|
|
21
|
+
.ipynb_checkpoints/
|
|
22
|
+
docs/build/
|
|
23
|
+
docs/source/api/_autosummary/
|
|
File without changes
|
funcast-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Selman Sezgin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
funcast-0.1.0/PKG-INFO
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: funcast
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Functional data forecasting with covariates (FunCast model)
|
|
5
|
+
Project-URL: Homepage, https://github.com/SelmanSzgn/funcast
|
|
6
|
+
Project-URL: Repository, https://github.com/SelmanSzgn/funcast
|
|
7
|
+
Project-URL: Documentation, https://funcast.readthedocs.io
|
|
8
|
+
Project-URL: Bug Tracker, https://github.com/SelmanSzgn/funcast/issues
|
|
9
|
+
Author-email: Selman Sezgin <selman.szg@gmail.com>
|
|
10
|
+
License: MIT License
|
|
11
|
+
|
|
12
|
+
Copyright (c) 2025 Selman Sezgin
|
|
13
|
+
|
|
14
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
15
|
+
|
|
16
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
17
|
+
|
|
18
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
19
|
+
License-File: LICENSE
|
|
20
|
+
Keywords: B-spline,forecasting,functional data analysis,statistics,time series
|
|
21
|
+
Classifier: Development Status :: 3 - Alpha
|
|
22
|
+
Classifier: Intended Audience :: Science/Research
|
|
23
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
24
|
+
Classifier: Programming Language :: Python :: 3
|
|
25
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
26
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
27
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
28
|
+
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
|
|
29
|
+
Classifier: Topic :: Scientific/Engineering :: Mathematics
|
|
30
|
+
Requires-Python: >=3.10
|
|
31
|
+
Requires-Dist: numpy>=1.24
|
|
32
|
+
Requires-Dist: scikit-learn>=1.3
|
|
33
|
+
Requires-Dist: scipy>=1.10
|
|
34
|
+
Provides-Extra: dev
|
|
35
|
+
Requires-Dist: mypy>=1.0; extra == 'dev'
|
|
36
|
+
Requires-Dist: pytest-cov>=4.0; extra == 'dev'
|
|
37
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
38
|
+
Requires-Dist: ruff>=0.4; extra == 'dev'
|
|
39
|
+
Provides-Extra: docs
|
|
40
|
+
Requires-Dist: myst-parser>=2.0; extra == 'docs'
|
|
41
|
+
Requires-Dist: sphinx-autodoc-typehints>=1.25; extra == 'docs'
|
|
42
|
+
Requires-Dist: sphinx-rtd-theme>=2.0; extra == 'docs'
|
|
43
|
+
Requires-Dist: sphinx>=7.0; extra == 'docs'
|
|
44
|
+
Provides-Extra: examples
|
|
45
|
+
Requires-Dist: jupyter>=1.0; extra == 'examples'
|
|
46
|
+
Requires-Dist: matplotlib>=3.7; extra == 'examples'
|
|
47
|
+
Description-Content-Type: text/markdown
|
|
48
|
+
|
|
49
|
+
Python implementation of the FunCast functional data forecasting model.
|
|
50
|
+
|
|
51
|
+
## Paper reference
|
|
52
|
+
|
|
53
|
+
Sezgin et al. (2025), *"Funcast: a forecasting model for functional data using covariates"*, under review at Journal of Statistical Planning and Inference (JSPI).
|
|
54
|
+
|
|
55
|
+
Authors : Selman Sezgin (a, b), Julien Jacques (a), Kahina Mokrani (b) and Sylvain Allio (b)
|
|
56
|
+
|
|
57
|
+
(a) ERIC, Université Lumière Lyon 2, Lyon, France
|
|
58
|
+
|
|
59
|
+
(b) Orange Research, Belfort, France
|
|
60
|
+
|
|
61
|
+
## Installation
|
|
62
|
+
``
|
|
63
|
+
pip install funcast
|
|
64
|
+
``
|
|
65
|
+
|
|
66
|
+
## Quick start
|
|
67
|
+
```
|
|
68
|
+
import numpy as np
|
|
69
|
+
from funcast import FunCast
|
|
70
|
+
|
|
71
|
+
n, m1, m2 = 50, 100, 20
|
|
72
|
+
t_past = np.linspace(0, 1, m1)
|
|
73
|
+
t_future = np.linspace(1, 1.2, m2)
|
|
74
|
+
Y_past = np.random.randn(n, m1)
|
|
75
|
+
Y_future = np.random.randn(n, m2)
|
|
76
|
+
|
|
77
|
+
model = FunCast(K=8, s=0.5)
|
|
78
|
+
model.fit(Y_past, Y_future, t_past, t_future)
|
|
79
|
+
Y_pred = model.predict(Y_past)
|
|
80
|
+
```
|
funcast-0.1.0/README.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
Python implementation of the FunCast functional data forecasting model.
|
|
2
|
+
|
|
3
|
+
## Paper reference
|
|
4
|
+
|
|
5
|
+
Sezgin et al. (2025), *"Funcast: a forecasting model for functional data using covariates"*, under review at Journal of Statistical Planning and Inference (JSPI).
|
|
6
|
+
|
|
7
|
+
Authors : Selman Sezgin (a, b), Julien Jacques (a), Kahina Mokrani (b) and Sylvain Allio (b)
|
|
8
|
+
|
|
9
|
+
(a) ERIC, Université Lumière Lyon 2, Lyon, France
|
|
10
|
+
|
|
11
|
+
(b) Orange Research, Belfort, France
|
|
12
|
+
|
|
13
|
+
## Installation
|
|
14
|
+
``
|
|
15
|
+
pip install funcast
|
|
16
|
+
``
|
|
17
|
+
|
|
18
|
+
## Quick start
|
|
19
|
+
```
|
|
20
|
+
import numpy as np
|
|
21
|
+
from funcast import FunCast
|
|
22
|
+
|
|
23
|
+
n, m1, m2 = 50, 100, 20
|
|
24
|
+
t_past = np.linspace(0, 1, m1)
|
|
25
|
+
t_future = np.linspace(1, 1.2, m2)
|
|
26
|
+
Y_past = np.random.randn(n, m1)
|
|
27
|
+
Y_future = np.random.randn(n, m2)
|
|
28
|
+
|
|
29
|
+
model = FunCast(K=8, s=0.5)
|
|
30
|
+
model.fit(Y_past, Y_future, t_past, t_future)
|
|
31
|
+
Y_pred = model.predict(Y_past)
|
|
32
|
+
```
|
|
File without changes
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Minimal makefile for Sphinx documentation
|
|
2
|
+
#
|
|
3
|
+
|
|
4
|
+
# You can set these variables from the command line, and also
|
|
5
|
+
# from the environment for the first two.
|
|
6
|
+
SPHINXOPTS ?=
|
|
7
|
+
SPHINXBUILD ?= sphinx-build
|
|
8
|
+
SOURCEDIR = source
|
|
9
|
+
BUILDDIR = build
|
|
10
|
+
|
|
11
|
+
# Put it first so that "make" without argument is like "make help".
|
|
12
|
+
help:
|
|
13
|
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
14
|
+
|
|
15
|
+
.PHONY: help Makefile
|
|
16
|
+
|
|
17
|
+
# Catch-all target: route all unknown targets to Sphinx using the new
|
|
18
|
+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
|
19
|
+
%: Makefile
|
|
20
|
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
@ECHO OFF
|
|
2
|
+
|
|
3
|
+
pushd %~dp0
|
|
4
|
+
|
|
5
|
+
REM Command file for Sphinx documentation
|
|
6
|
+
|
|
7
|
+
if "%SPHINXBUILD%" == "" (
|
|
8
|
+
set SPHINXBUILD=sphinx-build
|
|
9
|
+
)
|
|
10
|
+
set SOURCEDIR=source
|
|
11
|
+
set BUILDDIR=build
|
|
12
|
+
|
|
13
|
+
%SPHINXBUILD% >NUL 2>NUL
|
|
14
|
+
if errorlevel 9009 (
|
|
15
|
+
echo.
|
|
16
|
+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
|
17
|
+
echo.installed, then set the SPHINXBUILD environment variable to point
|
|
18
|
+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
|
19
|
+
echo.may add the Sphinx directory to PATH.
|
|
20
|
+
echo.
|
|
21
|
+
echo.If you don't have Sphinx installed, grab it from
|
|
22
|
+
echo.https://www.sphinx-doc.org/
|
|
23
|
+
exit /b 1
|
|
24
|
+
)
|
|
25
|
+
|
|
26
|
+
if "%1" == "" goto help
|
|
27
|
+
|
|
28
|
+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
29
|
+
goto end
|
|
30
|
+
|
|
31
|
+
:help
|
|
32
|
+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
|
33
|
+
|
|
34
|
+
:end
|
|
35
|
+
popd
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Sphinx configuration for FunCast documentation.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import os
|
|
6
|
+
import sys
|
|
7
|
+
|
|
8
|
+
sys.path.insert(0, os.path.abspath("../../src"))
|
|
9
|
+
|
|
10
|
+
project = "FunCast"
|
|
11
|
+
copyright = "2025, Sezgin"
|
|
12
|
+
author = "Sezgin"
|
|
13
|
+
release = "0.1.0"
|
|
14
|
+
|
|
15
|
+
extensions = [
|
|
16
|
+
"sphinx.ext.autodoc",
|
|
17
|
+
"sphinx.ext.autosummary",
|
|
18
|
+
"sphinx.ext.napoleon",
|
|
19
|
+
"sphinx.ext.viewcode",
|
|
20
|
+
"sphinx.ext.intersphinx",
|
|
21
|
+
"sphinx_autodoc_typehints",
|
|
22
|
+
"sphinx.ext.mathjax",
|
|
23
|
+
"myst_parser",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
autodoc_default_options = {
|
|
27
|
+
"members": True,
|
|
28
|
+
"undoc-members": False,
|
|
29
|
+
"private-members": False,
|
|
30
|
+
"show-inheritance": True,
|
|
31
|
+
"member-order": "bysource",
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
autosummary_generate = True
|
|
35
|
+
|
|
36
|
+
napoleon_google_docstring = False
|
|
37
|
+
napoleon_numpy_docstring = True
|
|
38
|
+
napoleon_use_param = True
|
|
39
|
+
napoleon_use_rtype = True
|
|
40
|
+
|
|
41
|
+
typehints_fully_qualified = False
|
|
42
|
+
always_document_param_types = True
|
|
43
|
+
typehints_document_rtype = True
|
|
44
|
+
|
|
45
|
+
intersphinx_mapping = {
|
|
46
|
+
"python": ("https://docs.python.org/3", None),
|
|
47
|
+
"numpy": ("https://numpy.org/doc/stable", None),
|
|
48
|
+
"scipy": ("https://docs.scipy.org/doc/scipy", None),
|
|
49
|
+
"sklearn": ("https://scikit-learn.org/stable", None),
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
myst_enable_extensions = [
|
|
53
|
+
"colon_fence",
|
|
54
|
+
"deflist",
|
|
55
|
+
"dollarmath",
|
|
56
|
+
]
|
|
57
|
+
|
|
58
|
+
html_theme = "sphinx_rtd_theme"
|
|
59
|
+
|
|
60
|
+
html_theme_options = {
|
|
61
|
+
"navigation_depth": 4,
|
|
62
|
+
"collapse_navigation": False,
|
|
63
|
+
"sticky_navigation": True,
|
|
64
|
+
"includehidden": True,
|
|
65
|
+
"titles_only": False,
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
html_static_path = ["_static"]
|
|
69
|
+
|
|
70
|
+
source_suffix = {
|
|
71
|
+
".rst": "restructuredtext",
|
|
72
|
+
".md": "markdown",
|
|
73
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# Contributing
|
|
2
|
+
|
|
3
|
+
## Development setup
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
git clone https://github.com/ton-username/funcast.git
|
|
7
|
+
cd funcast
|
|
8
|
+
pip install -e ".[dev,docs]"
|
|
9
|
+
pre-commit install
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Running tests
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pytest
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Building the documentation locally
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
cd docs
|
|
22
|
+
make html
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
The documentation is then available at `docs/build/html/index.html`.
|
|
26
|
+
|
|
27
|
+
## Submitting a pull request
|
|
28
|
+
|
|
29
|
+
1. Fork the repository
|
|
30
|
+
2. Create a feature branch : `git checkout -b feat/my-feature`
|
|
31
|
+
3. Commit your changes : `git commit -m "feat: my feature"`
|
|
32
|
+
4. Push : `git push origin feat/my-feature`
|
|
33
|
+
5. Open a pull request on GitHub
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
FunCast Documentation
|
|
2
|
+
=====================
|
|
3
|
+
|
|
4
|
+
**FunCast** is a Python package implementing the functional data forecasting
|
|
5
|
+
model with covariates introduced in Sezgin et al. (2025).
|
|
6
|
+
|
|
7
|
+
.. toctree::
|
|
8
|
+
:maxdepth: 2
|
|
9
|
+
:caption: Getting Started
|
|
10
|
+
|
|
11
|
+
installation
|
|
12
|
+
quickstart
|
|
13
|
+
|
|
14
|
+
.. toctree::
|
|
15
|
+
:maxdepth: 2
|
|
16
|
+
:caption: User Guide
|
|
17
|
+
|
|
18
|
+
userguide/model
|
|
19
|
+
userguide/basis
|
|
20
|
+
userguide/selection
|
|
21
|
+
|
|
22
|
+
.. toctree::
|
|
23
|
+
:maxdepth: 2
|
|
24
|
+
:caption: API Reference
|
|
25
|
+
|
|
26
|
+
api/funcast
|
|
27
|
+
api/basis
|
|
28
|
+
api/selection
|
|
29
|
+
|
|
30
|
+
.. toctree::
|
|
31
|
+
:maxdepth: 1
|
|
32
|
+
:caption: Development
|
|
33
|
+
|
|
34
|
+
changelog
|
|
35
|
+
contributing
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# Installation
|
|
2
|
+
|
|
3
|
+
## Stable release
|
|
4
|
+
|
|
5
|
+
```
|
|
6
|
+
pip install funcast
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## Development version
|
|
10
|
+
```
|
|
11
|
+
git clone https://github.com/SelmanSzgn/funcast.git
|
|
12
|
+
cd funcast
|
|
13
|
+
pip install -e ".[dev]"
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Dependencies
|
|
17
|
+
|
|
18
|
+
Python >= 3.10\
|
|
19
|
+
numpy >= 1.24\
|
|
20
|
+
scipy >= 1.10\
|
|
21
|
+
scikit-learn >= 1.3
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# Quick start
|
|
2
|
+
|
|
3
|
+
## Simple example
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
import numpy as np
|
|
7
|
+
from funcast import FunCast
|
|
8
|
+
|
|
9
|
+
# Timestamps
|
|
10
|
+
t_past = np.linspace(0, 1, 100)
|
|
11
|
+
t_future = np.linspace(1, 1.25, 25)
|
|
12
|
+
|
|
13
|
+
# Synthetic data
|
|
14
|
+
rng = np.random.default_rng(42)
|
|
15
|
+
n = 50
|
|
16
|
+
Y_past = np.sin(2 * np.pi * t_past) + 0.1 * rng.standard_normal((n, 100))
|
|
17
|
+
Y_future = np.sin(2 * np.pi * t_future) + 0.1 * rng.standard_normal((n, 25))
|
|
18
|
+
|
|
19
|
+
# Training
|
|
20
|
+
model = FunCast(K=8, s=0.8)
|
|
21
|
+
model.fit(Y_past, Y_future, t_past, t_future)
|
|
22
|
+
|
|
23
|
+
# Prediction
|
|
24
|
+
Y_pred = model.predict(Y_past)
|
|
25
|
+
print(f"RMSE : {model.score(Y_past, Y_future):.4f}")
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Choosing the basis
|
|
29
|
+
|
|
30
|
+
```python
|
|
31
|
+
# B-spline (default)
|
|
32
|
+
model_bs = FunCast(K=8, s=0.5, basis_type="bspline")
|
|
33
|
+
|
|
34
|
+
# Fourier
|
|
35
|
+
model_fo = FunCast(K=8, s=0.5, basis_type="fourier")
|
|
36
|
+
```
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Functional Bases
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
FunCast represents functional data as linear combinations of basis
|
|
6
|
+
functions. Two families are available :
|
|
7
|
+
|
|
8
|
+
- **B-spline** : well suited for non-periodic signals
|
|
9
|
+
- **Fourier** : well suited for periodic signals
|
|
10
|
+
|
|
11
|
+
## B-spline basis
|
|
12
|
+
|
|
13
|
+
A B-spline basis of degree $d$ with $h$ functions is built from a
|
|
14
|
+
knot sequence uniformly distributed over $[0, T]$.
|
|
15
|
+
|
|
16
|
+
**Key properties :**
|
|
17
|
+
|
|
18
|
+
- Local support : each function is non-zero only on a small interval
|
|
19
|
+
- Partition of unity : the functions sum to 1 at every point
|
|
20
|
+
- Smooth : $d-1$ times continuously differentiable
|
|
21
|
+
|
|
22
|
+
```python
|
|
23
|
+
from funcast.basis import bspline_basis
|
|
24
|
+
import numpy as np
|
|
25
|
+
|
|
26
|
+
t = np.linspace(0, 1, 100)
|
|
27
|
+
B = bspline_basis(t, n_basis=8, degree=3)
|
|
28
|
+
print(B.shape) # (100, 8)
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Fourier basis
|
|
32
|
+
|
|
33
|
+
A Fourier basis with $h$ functions is built from cosine and sine
|
|
34
|
+
harmonics of increasing frequency.
|
|
35
|
+
|
|
36
|
+
**Key properties :**
|
|
37
|
+
|
|
38
|
+
- Global support : each function is non-zero everywhere
|
|
39
|
+
- Orthogonal : the functions are orthogonal on $[0, T]$
|
|
40
|
+
- Periodic : well adapted to seasonal or cyclic signals
|
|
41
|
+
|
|
42
|
+
```python
|
|
43
|
+
from funcast.basis import fourier_basis
|
|
44
|
+
import numpy as np
|
|
45
|
+
|
|
46
|
+
t = np.linspace(0, 1, 100)
|
|
47
|
+
B = fourier_basis(t, n_basis=7)
|
|
48
|
+
print(B.shape) # (100, 7)
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Choosing the right basis
|
|
52
|
+
|
|
53
|
+
| Situation | Recommended basis |
|
|
54
|
+
|---|---|
|
|
55
|
+
| Signal with trend, no periodicity | B-spline |
|
|
56
|
+
| Seasonal or cyclic signal | Fourier |
|
|
57
|
+
| Unknown structure | B-spline (default) |
|
|
58
|
+
| Sharp local variations | B-spline |
|
|
59
|
+
|
|
60
|
+
## Using `get_basis`
|
|
61
|
+
|
|
62
|
+
The `get_basis` function is the recommended entry point :
|
|
63
|
+
|
|
64
|
+
```python
|
|
65
|
+
from funcast.basis import get_basis
|
|
66
|
+
|
|
67
|
+
B_bs = get_basis(t, n_basis=8, basis_type="bspline")
|
|
68
|
+
B_fo = get_basis(t, n_basis=8, basis_type="fourier")
|
|
69
|
+
```
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# The FunCast Model
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
FunCast forecasts the future trajectory of a functional process $Y$
|
|
6
|
+
over $[T, T+H]$ given its past trajectory over $[0, T]$ and optional
|
|
7
|
+
covariates $X_1, \ldots, X_p$.
|
|
8
|
+
|
|
9
|
+
## Four-step procedure
|
|
10
|
+
|
|
11
|
+
### Step 1 — Choose K
|
|
12
|
+
|
|
13
|
+
$K$ controls the richness of the future representation.
|
|
14
|
+
A larger $K$ allows more complex future shapes but increases
|
|
15
|
+
the risk of overfitting.
|
|
16
|
+
|
|
17
|
+
**Recommended range** : $K \in [4, 15]$
|
|
18
|
+
|
|
19
|
+
### Step 2 — Select $h_\ell$ via RRSS
|
|
20
|
+
|
|
21
|
+
For each covariate (including $Y$ itself), $h_\ell$ is the number
|
|
22
|
+
of basis functions used to represent it. It is selected automatically
|
|
23
|
+
by minimizing the Regularized Residual Sum of Squares (RRSS, Eq. 10).
|
|
24
|
+
|
|
25
|
+
### Step 3 — Compute $q_\ell$
|
|
26
|
+
|
|
27
|
+
The smoothing parameter $q_\ell$ controls the resolution of the
|
|
28
|
+
inner-product matrices :
|
|
29
|
+
|
|
30
|
+
$$q_\ell = \max(\text{degree}+1, \lfloor (1-s) \cdot h_\ell \rceil)$$
|
|
31
|
+
|
|
32
|
+
- $s = 0$ : no smoothing ($q_\ell = h_\ell$)
|
|
33
|
+
- $s = 1$ : maximum smoothing ($q_\ell = \text{degree}+1$)
|
|
34
|
+
|
|
35
|
+
### Step 4 — Solve the OLS problem
|
|
36
|
+
|
|
37
|
+
The coefficient vector $\hat{\beta}$ is estimated by ordinary
|
|
38
|
+
least squares.
|
|
39
|
+
|
|
40
|
+
## Parameters
|
|
41
|
+
|
|
42
|
+
| Parameter | Type | Default | Description |
|
|
43
|
+
|---|---|---|---|
|
|
44
|
+
| `K` | int | 10 | Number of basis functions ψ for future Y |
|
|
45
|
+
| `s` | float | 0.5 | Smoothing coefficient ∈ [0, 1] |
|
|
46
|
+
| `basis_type` | str | `'bspline'` | Basis type |
|
|
47
|
+
| `auto_h` | bool | `True` | Auto-select hℓ via RRSS |
|
|
48
|
+
| `h_list` | list | `None` | Manual hℓ values |
|
|
49
|
+
| `degree` | int | 3 | B-spline degree |
|
|
50
|
+
| `rcond` | float | `None` | Pseudo-inverse threshold |
|
|
51
|
+
|
|
52
|
+
## Fitted attributes
|
|
53
|
+
|
|
54
|
+
After calling `fit()`, the following attributes are available :
|
|
55
|
+
|
|
56
|
+
| Attribute | Description |
|
|
57
|
+
|---|---|
|
|
58
|
+
| `h_values_` | Selected $h_\ell$ for each covariate |
|
|
59
|
+
| `q_values_` | Computed $q_\ell$ for each covariate |
|
|
60
|
+
| `b_hat_` | Estimated coefficient vector $\hat{\beta}$ |
|
|
61
|
+
| `C_list_` | Projection coefficients for each covariate |
|
|
62
|
+
| `J_list_` | Inner-product matrices |
|
|
63
|
+
| `theta_list_` | Basis matrices for each covariate |
|