Skip to content

Commit 470476b

Browse files
committed
notebook
1 parent 117295c commit 470476b

File tree

8 files changed

+2742
-2
lines changed

8 files changed

+2742
-2
lines changed

_doc/api/datasets/data_ts.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
teachpyx.datasets.data_ts
3+
=========================
4+
5+
.. automodule:: teachpyx.datasets.data_ts
6+
:members:
7+
:no-undoc-members:

_doc/api/datasets/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ teachpyx.datasets
1717

1818

1919
data_helper
20+
data_ts
2021
documentation
2122
enedis
2223
gpd_helper

_doc/articles/2025/2025-03-01-route2025.rst

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,46 @@ accessible depuis le package `datasets <https://huggingface.co/docs/datasets/en/
156156
Séance 5 (6/3)
157157
==============
158158

159+
**Régression, Classification linéaires**
160+
161+
:epkg:`statsmodels` pour obtenir le résultat de tests de nullité des coefficients
162+
163+
* :ref:`Régression logistique en 2D <nbl-practice-ml-winesc_color_line>`
164+
* :ref:`Plusieurs modèles, données disjointes <nbl-practice-ml-winesc_color_linear>`
165+
166+
**Interprétabilité**
167+
168+
* `Partial Dependence <https://scikit-learn.org/stable/modules/partial_dependence.html>`_
169+
* `Permutation Importance <https://scikit-learn.org/stable/modules/permutation_importance.html>`_
170+
* `LIME <https://arxiv.org/abs/1602.04938>`_
171+
* `Shapley value <https://en.wikipedia.org/wiki/Shapley_value>`_,
172+
`SHAP <https://shap.readthedocs.io/en/latest/index.html>`_
173+
* `Counterfactual Reasoning and Learning Systems <https://arxiv.org/abs/1209.2355>`_
174+
159175
**séries temporelles**
160176

161-
* :epkg:`statsmodels`, :epkg:`sktime`, :epkg:`skforecast`, :epkg:`prophet`, :epkg:`pyflux`
177+
Le modèle de référence est :epkg:`statsmodels`
178+
179+
* :ref:`Single Spectrum Analysis (SSA) <nbl-practice-ml-timeseries_ssa>`
180+
* :ref:`Décomposition d'une série temporelle <nbl-practice-ml-timeseries_seasonal>`
181+
182+
:epkg:`sktime` propose une API plus proche de :epkg:`scikit-learn`
183+
et d'autres modèles comme le clusting ou la segmentation de séries temporelles.
184+
185+
:epkg:`prophet` fait aussi de la prédiction et contient aussi des algorithmes
186+
de détection de changement de régime, il contient une bonne base de jours
187+
fériés.
188+
189+
:epkg:`pyflux` permet d'estimer des modules `GARCH
190+
<https://en.wikipedia.org/wiki/Autoregressive_conditional_heteroskedasticity>`_.
191+
192+
**Analyse de survie**
193+
162194
* :epkg:`scikit-survival`, :epkg:`lifelines`, analyses de survie,
163195
`Analyse de survie <https://sdpython.github.io/doc/mlstatpy/dev/c_ml/survival_analysis.html>`_,
164196

197+
**Deep Learning**
198+
165199
* `DeepAR <https://arxiv.org/abs/1704.04110>`_
166200
* temps réel
167201

_doc/notebook_gallery.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ Machine Learning
179179
practice/ml/winesc_multi_stacking
180180
practice/ml/artificiel_multiclass
181181
practice/ml/ml_features_model
182-
practice/ml/timeseries_ssa
183182
practice/ml/ml_a_tree_overfitting
184183
practice/ml/gradient_boosting
185184
practice/ml/ridge_lasso
@@ -189,3 +188,8 @@ Machine Learning
189188
practice/ml/pretraitement_son
190189
practice/ml/pretraitement_texte
191190

191+
.. nblinkgallery::
192+
:caption: timeseries
193+
194+
practice/ml/timeseries_ssa
195+
practice/ml/timeseries_seasonal

_doc/practice/index_ml.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ Machine Learning
5555
:caption: Séries Temporelles
5656

5757
ml/timeseries_ssa
58+
ml/timeseries_seasonal
5859

5960
.. toctree::
6061
:maxdepth: 1

_doc/practice/ml/timeseries_seasonal.ipynb

Lines changed: 2638 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import unittest
2+
from teachpyx.ext_test_case import ExtTestCase
3+
from teachpyx.datasets.data_ts import generate_sells
4+
5+
6+
class TestDataTs(ExtTestCase):
7+
8+
def test_generate_sells(self):
9+
df = generate_sells()
10+
self.assertEqual(len(df), 731)
11+
12+
13+
if __name__ == "__main__":
14+
unittest.main()

teachpyx/datasets/data_ts.py

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
from typing import List, Optional
2+
from datetime import datetime, timedelta
3+
import numpy
4+
5+
6+
def generate_sells(
7+
duration: int = 730,
8+
end: Optional[datetime] = None,
9+
week_coef: Optional[List[float]] = None,
10+
month_coef: Optional[List[float]] = None,
11+
trend: float = 1.1,
12+
):
13+
"""
14+
Generates dummy data and trends and seasonality.
15+
"""
16+
if week_coef is None:
17+
week_coef = numpy.array([0.1, 0.12, 0.12, 0.15, 0.20, 0.0, 0.0])
18+
week_coef[5] = 1.0 - week_coef.sum()
19+
if month_coef is None:
20+
month_coef = [0.8, 1, 1, 1, 1, 1, 0.8, 0.6, 1, 1, 1, 1.5]
21+
month_coef = numpy.array(month_coef)
22+
month_coef /= month_coef.sum()
23+
24+
if end is None:
25+
end = datetime.now()
26+
begin = end - timedelta(duration)
27+
day = timedelta(1)
28+
29+
rows = []
30+
rnd = (numpy.random.randn(duration + 1) * 0.1) + 1
31+
exp = (1 + numpy.exp(-numpy.arange(duration + 1) / duration * trend)) ** (-1)
32+
pos = 0
33+
while begin <= end:
34+
month = begin.month
35+
weekd = begin.weekday()
36+
value = rnd[pos] * week_coef[weekd] * month_coef[month - 1] * exp[pos]
37+
pos += 1
38+
obs = dict(date=begin, value=value)
39+
rows.append(obs)
40+
begin += day
41+
return rows

0 commit comments

Comments
 (0)