deep-river 0.2.7__tar.gz → 0.2.8__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.
Files changed (38) hide show
  1. {deep_river-0.2.7 → deep_river-0.2.8}/PKG-INFO +27 -109
  2. {deep_river-0.2.7 → deep_river-0.2.8}/README.md +7 -4
  3. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/__version__.py +1 -1
  4. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/anomaly/__init__.py +1 -5
  5. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/anomaly/ae.py +4 -6
  6. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/anomaly/probability_weighted_ae.py +5 -10
  7. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/anomaly/rolling_ae.py +2 -6
  8. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/anomaly/scaler.py +2 -6
  9. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/base.py +4 -12
  10. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/classification/__init__.py +1 -4
  11. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/classification/classifier.py +9 -15
  12. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/classification/rolling_classifier.py +11 -20
  13. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/classification/zoo.py +1 -3
  14. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/regression/multioutput.py +2 -6
  15. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/regression/regressor.py +6 -16
  16. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/regression/rolling_regressor.py +4 -9
  17. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/regression/zoo.py +1 -3
  18. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/utils/params.py +3 -9
  19. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/utils/tensor_conversion.py +13 -1
  20. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/utils/test_estimators.py +2 -6
  21. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/utils/test_tensor_conversion.py +3 -9
  22. deep_river-0.2.8/pyproject.toml +83 -0
  23. deep_river-0.2.7/deep_river.egg-info/PKG-INFO +0 -291
  24. deep_river-0.2.7/deep_river.egg-info/SOURCES.txt +0 -36
  25. deep_river-0.2.7/deep_river.egg-info/dependency_links.txt +0 -1
  26. deep_river-0.2.7/deep_river.egg-info/requires.txt +0 -102
  27. deep_river-0.2.7/deep_river.egg-info/top_level.txt +0 -1
  28. deep_river-0.2.7/pyproject.toml +0 -63
  29. deep_river-0.2.7/setup.cfg +0 -9
  30. deep_river-0.2.7/setup.py +0 -111
  31. {deep_river-0.2.7 → deep_river-0.2.8}/LICENSE +0 -0
  32. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/__init__.py +0 -0
  33. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/regression/__init__.py +0 -0
  34. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/utils/__init__.py +0 -0
  35. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/utils/estimator_checks.py +0 -0
  36. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/utils/hooks.py +0 -0
  37. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/utils/layer_adaptation.py +0 -0
  38. {deep_river-0.2.7 → deep_river-0.2.8}/deep_river/utils/test_layer_adaptation.py +0 -0
@@ -1,120 +1,34 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: deep_river
3
- Version: 0.2.7
3
+ Version: 0.2.8
4
4
  Summary: Online Deep Learning for river
5
- Home-page: https://online-ml.github.io/deep-river/
5
+ Home-page: https://github.com/online-ml/deep-river
6
+ License: BSD-3-Clause
7
+ Keywords: online-learning,deep-learning,data-streams
6
8
  Author: Cedric Kulbach
7
9
  Author-email: cedric.kulbach@googlemail.com
8
- License: BSD-3
10
+ Requires-Python: >=3.10,<3.13
9
11
  Classifier: License :: OSI Approved :: BSD License
10
12
  Classifier: Programming Language :: Python
11
13
  Classifier: Programming Language :: Python :: 3
12
- Classifier: Programming Language :: Python :: 3.8
13
- Classifier: Programming Language :: Python :: 3.9
14
14
  Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
15
17
  Classifier: Programming Language :: Python :: Implementation :: CPython
16
18
  Classifier: Programming Language :: Python :: Implementation :: PyPy
17
- Requires-Python: >=3.6.0
19
+ Requires-Dist: mkdocstrings[python] (>=0.19.0)
20
+ Requires-Dist: numpy (>=1.26.4,<1.27.0)
21
+ Requires-Dist: ordered-set (>=4.1.0,<4.2.0)
22
+ Requires-Dist: pandas (>=2.2.2,<2.3.0)
23
+ Requires-Dist: pytkdocs[numpy-style] (>=0.5.0)
24
+ Requires-Dist: river
25
+ Requires-Dist: scikit-learn (>=1.5.0,<1.6.0)
26
+ Requires-Dist: torch (>=2.2.2,<2.3.0)
27
+ Requires-Dist: torchviz (>=0.0.2,<0.1.0)
28
+ Requires-Dist: tqdm (>=4.66.5,<4.67.0)
29
+ Project-URL: Documentation, https://github.com/online-ml/deep-river
30
+ Project-URL: Repository, https://github.com/online-ml/deep-river
18
31
  Description-Content-Type: text/markdown
19
- License-File: LICENSE
20
- Requires-Dist: scikit-learn~=1.5.0
21
- Requires-Dist: torch~=2.2.2
22
- Requires-Dist: pandas~=2.2.2
23
- Requires-Dist: numpy~=1.26.4
24
- Requires-Dist: river~=0.21.2
25
- Requires-Dist: scipy~=1.13.0
26
- Requires-Dist: tqdm~=4.66.5
27
- Requires-Dist: ordered-set~=4.1.0
28
- Requires-Dist: torchviz~=0.0.2
29
- Provides-Extra: dev
30
- Requires-Dist: scikit-learn~=1.5.0; extra == "dev"
31
- Requires-Dist: torch~=2.2.2; extra == "dev"
32
- Requires-Dist: pandas~=2.2.2; extra == "dev"
33
- Requires-Dist: numpy~=1.26.4; extra == "dev"
34
- Requires-Dist: river~=0.21.2; extra == "dev"
35
- Requires-Dist: scipy~=1.13.0; extra == "dev"
36
- Requires-Dist: tqdm~=4.66.5; extra == "dev"
37
- Requires-Dist: ordered-set~=4.1.0; extra == "dev"
38
- Requires-Dist: torchviz~=0.0.2; extra == "dev"
39
- Requires-Dist: graphviz>=0.20.3; extra == "dev"
40
- Requires-Dist: matplotlib>=3.9.2; extra == "dev"
41
- Requires-Dist: mypy>=1.11.1; extra == "dev"
42
- Requires-Dist: pre-commit>=3.8.0; extra == "dev"
43
- Requires-Dist: pytest>=8.3.2; extra == "dev"
44
- Requires-Dist: pytest-cov>=5.0.0; extra == "dev"
45
- Requires-Dist: black>=24.8.0; extra == "dev"
46
- Requires-Dist: flake8>=7.1.1; extra == "dev"
47
- Requires-Dist: isort>=5.13.2; extra == "dev"
48
- Requires-Dist: jupyter>=1.0.0; extra == "dev"
49
- Requires-Dist: pyupgrade==3.17.0; extra == "dev"
50
- Provides-Extra: docs
51
- Requires-Dist: scikit-learn~=1.5.0; extra == "docs"
52
- Requires-Dist: torch~=2.2.2; extra == "docs"
53
- Requires-Dist: pandas~=2.2.2; extra == "docs"
54
- Requires-Dist: numpy~=1.26.4; extra == "docs"
55
- Requires-Dist: river~=0.21.2; extra == "docs"
56
- Requires-Dist: scipy~=1.13.0; extra == "docs"
57
- Requires-Dist: tqdm~=4.66.5; extra == "docs"
58
- Requires-Dist: ordered-set~=4.1.0; extra == "docs"
59
- Requires-Dist: torchviz~=0.0.2; extra == "docs"
60
- Requires-Dist: flask>=2.0.2; extra == "docs"
61
- Requires-Dist: ipykernel>=6.9.0; extra == "docs"
62
- Requires-Dist: mike>=0.5.3; extra == "docs"
63
- Requires-Dist: mkdocs>=1.2.3; extra == "docs"
64
- Requires-Dist: mkdocs-awesome-pages-plugin>=2.7.0; extra == "docs"
65
- Requires-Dist: mkdocs-gen-files>=0.3.5; extra == "docs"
66
- Requires-Dist: mkdocs-charts-plugin>=0.0.8; extra == "docs"
67
- Requires-Dist: mkdocs-literate-nav>=0.4.1; extra == "docs"
68
- Requires-Dist: mkdocs-material>=8.1.11; extra == "docs"
69
- Requires-Dist: mkdocstrings[python]>=0.19.0; extra == "docs"
70
- Requires-Dist: pytkdocs[numpy-style]>=0.5.0; extra == "docs"
71
- Requires-Dist: ipython_genutils>=0.1.0; extra == "docs"
72
- Requires-Dist: mkdocs-jupyter>=0.20.0; extra == "docs"
73
- Requires-Dist: nbconvert>=6.4.2; extra == "docs"
74
- Requires-Dist: numpydoc>=1.2; extra == "docs"
75
- Requires-Dist: spacy>=3.2.2; extra == "docs"
76
- Requires-Dist: jinja2>=3.0.3; extra == "docs"
77
- Requires-Dist: dominate; extra == "docs"
78
- Requires-Dist: jupyter-client; extra == "docs"
79
- Requires-Dist: mkdocs-charts-plugin; extra == "docs"
80
- Requires-Dist: python-slugify; extra == "docs"
81
- Requires-Dist: watermark==2.3.1; extra == "docs"
82
- Provides-Extra: all
83
- Requires-Dist: graphviz>=0.20.3; extra == "all"
84
- Requires-Dist: matplotlib>=3.9.2; extra == "all"
85
- Requires-Dist: mypy>=1.11.1; extra == "all"
86
- Requires-Dist: pre-commit>=3.8.0; extra == "all"
87
- Requires-Dist: pytest>=8.3.2; extra == "all"
88
- Requires-Dist: pytest-cov>=5.0.0; extra == "all"
89
- Requires-Dist: black>=24.8.0; extra == "all"
90
- Requires-Dist: flake8>=7.1.1; extra == "all"
91
- Requires-Dist: isort>=5.13.2; extra == "all"
92
- Requires-Dist: jupyter>=1.0.0; extra == "all"
93
- Requires-Dist: pyupgrade==3.17.0; extra == "all"
94
- Requires-Dist: flask>=2.0.2; extra == "all"
95
- Requires-Dist: ipykernel>=6.9.0; extra == "all"
96
- Requires-Dist: mike>=0.5.3; extra == "all"
97
- Requires-Dist: mkdocs>=1.2.3; extra == "all"
98
- Requires-Dist: mkdocs-awesome-pages-plugin>=2.7.0; extra == "all"
99
- Requires-Dist: mkdocs-gen-files>=0.3.5; extra == "all"
100
- Requires-Dist: mkdocs-charts-plugin>=0.0.8; extra == "all"
101
- Requires-Dist: mkdocs-literate-nav>=0.4.1; extra == "all"
102
- Requires-Dist: mkdocs-material>=8.1.11; extra == "all"
103
- Requires-Dist: mkdocstrings[python]>=0.19.0; extra == "all"
104
- Requires-Dist: pytkdocs[numpy-style]>=0.5.0; extra == "all"
105
- Requires-Dist: ipython_genutils>=0.1.0; extra == "all"
106
- Requires-Dist: mkdocs-jupyter>=0.20.0; extra == "all"
107
- Requires-Dist: nbconvert>=6.4.2; extra == "all"
108
- Requires-Dist: numpydoc>=1.2; extra == "all"
109
- Requires-Dist: spacy>=3.2.2; extra == "all"
110
- Requires-Dist: jinja2>=3.0.3; extra == "all"
111
- Requires-Dist: dominate; extra == "all"
112
- Requires-Dist: jupyter-client; extra == "all"
113
- Requires-Dist: mkdocs-charts-plugin; extra == "all"
114
- Requires-Dist: python-slugify; extra == "all"
115
- Requires-Dist: watermark==2.3.1; extra == "all"
116
- Requires-Dist: dataclasses; python_version == "3.6"
117
-
118
32
 
119
33
  <p align="center">
120
34
  <img height="150px" src="https://raw.githubusercontent.com/online-ml/deep-river/master/docs/img/logo.png" alt="incremental dl logo">
@@ -124,6 +38,7 @@ Requires-Dist: dataclasses; python_version == "3.6"
124
38
  <a href="https://codecov.io/gh/online-ml/deep-river" >
125
39
  <img src="https://codecov.io/gh/online-ml/deep-river/branch/master/graph/badge.svg?token=ZKUIISZAYA"/>
126
40
  </a>
41
+ <img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/deep-river">
127
42
  <img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/deep-river">
128
43
  <img alt="GitHub" src="https://img.shields.io/github/license/online-ml/deep-river">
129
44
  <a href="https://joss.theoj.org/papers/6a76784f55e8b041d71a7fa776eb386a"><img src="https://joss.theoj.org/papers/6a76784f55e8b041d71a7fa776eb386a/status.svg"></a>
@@ -135,7 +50,9 @@ Requires-Dist: dataclasses; python_version == "3.6"
135
50
  </p>
136
51
 
137
52
  ## 📚 [Documentation](https://online-ml.github.io/deep-river/)
138
- The [documentation](https://online-ml.github.io/deep-river/) contains an overview of all features of this repository as well as the repository's full features list. In each of these, the git repo reference is listed in a section that shows examples of the features and functionality.
53
+ The [documentation](https://online-ml.github.io/deep-river/) contains an overview of all features of this repository as well as the repository's full features list.
54
+ In each of these, the git repo reference is listed in a section that shows [examples](https://github.com/online-ml/deep-river/blob/master/docs/examples) of the features and functionality.
55
+ As we are always looking for further use cases and examples, feel free to contribute to the documentation or the repository itself via a pull request
139
56
 
140
57
  ## 💈 Installation
141
58
 
@@ -250,7 +167,7 @@ MicroAverage(MAE): 34.31
250
167
  >>> from river.preprocessing import MinMaxScaler
251
168
 
252
169
  >>> dataset = CreditCard().take(5000)
253
- >>> metric = metrics.ROCAUC(n_thresholds=50)
170
+ >>> metric = metrics.RollingROCAUC(window_size=5000)
254
171
 
255
172
  >>> class MyAutoEncoder(nn.Module):
256
173
  ... def __init__(self, n_features, latent_dim=3):
@@ -275,8 +192,8 @@ MicroAverage(MAE): 34.31
275
192
  ... model.learn_one(x=x)
276
193
  ... metric.update(y, score)
277
194
  ...
278
- >>> print(f"ROCAUC: {metric.get():.4f}")
279
- ROCAUC: 0.7812
195
+ >>> print(f"Rolling ROCAUC: {metric.get():.4f}")
196
+ Rolling ROCAUC: 0.8901
280
197
 
281
198
  ```
282
199
 
@@ -289,3 +206,4 @@ ROCAUC: 0.7812
289
206
  <p align="center">
290
207
  <img src="https://lieferbotnet.de/wp-content/uploads/2022/09/LieferBotNet-Logo.png?raw=true" alt="Lieferbot net" height="200"/>
291
208
  </p>
209
+
@@ -6,6 +6,7 @@
6
6
  <a href="https://codecov.io/gh/online-ml/deep-river" >
7
7
  <img src="https://codecov.io/gh/online-ml/deep-river/branch/master/graph/badge.svg?token=ZKUIISZAYA"/>
8
8
  </a>
9
+ <img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/deep-river">
9
10
  <img alt="PyPI - Downloads" src="https://img.shields.io/pypi/dm/deep-river">
10
11
  <img alt="GitHub" src="https://img.shields.io/github/license/online-ml/deep-river">
11
12
  <a href="https://joss.theoj.org/papers/6a76784f55e8b041d71a7fa776eb386a"><img src="https://joss.theoj.org/papers/6a76784f55e8b041d71a7fa776eb386a/status.svg"></a>
@@ -17,7 +18,9 @@
17
18
  </p>
18
19
 
19
20
  ## 📚 [Documentation](https://online-ml.github.io/deep-river/)
20
- The [documentation](https://online-ml.github.io/deep-river/) contains an overview of all features of this repository as well as the repository's full features list. In each of these, the git repo reference is listed in a section that shows examples of the features and functionality.
21
+ The [documentation](https://online-ml.github.io/deep-river/) contains an overview of all features of this repository as well as the repository's full features list.
22
+ In each of these, the git repo reference is listed in a section that shows [examples](https://github.com/online-ml/deep-river/blob/master/docs/examples) of the features and functionality.
23
+ As we are always looking for further use cases and examples, feel free to contribute to the documentation or the repository itself via a pull request
21
24
 
22
25
  ## 💈 Installation
23
26
 
@@ -132,7 +135,7 @@ MicroAverage(MAE): 34.31
132
135
  >>> from river.preprocessing import MinMaxScaler
133
136
 
134
137
  >>> dataset = CreditCard().take(5000)
135
- >>> metric = metrics.ROCAUC(n_thresholds=50)
138
+ >>> metric = metrics.RollingROCAUC(window_size=5000)
136
139
 
137
140
  >>> class MyAutoEncoder(nn.Module):
138
141
  ... def __init__(self, n_features, latent_dim=3):
@@ -157,8 +160,8 @@ MicroAverage(MAE): 34.31
157
160
  ... model.learn_one(x=x)
158
161
  ... metric.update(y, score)
159
162
  ...
160
- >>> print(f"ROCAUC: {metric.get():.4f}")
161
- ROCAUC: 0.7812
163
+ >>> print(f"Rolling ROCAUC: {metric.get():.4f}")
164
+ Rolling ROCAUC: 0.8901
162
165
 
163
166
  ```
164
167
 
@@ -1,3 +1,3 @@
1
- VERSION = (0, 2, 7)
1
+ VERSION = (0, 2, 8)
2
2
 
3
3
  __version__ = ".".join(map(str, VERSION)) # noqa: F401
@@ -1,11 +1,7 @@
1
1
  from .ae import Autoencoder
2
2
  from .probability_weighted_ae import ProbabilityWeightedAutoencoder
3
3
  from .rolling_ae import RollingAutoencoder
4
- from .scaler import (
5
- AnomalyMeanScaler,
6
- AnomalyMinMaxScaler,
7
- AnomalyStandardScaler,
8
- )
4
+ from .scaler import AnomalyMeanScaler, AnomalyMinMaxScaler, AnomalyStandardScaler
9
5
 
10
6
  """
11
7
  This module contains the anomaly detection algorithms for the
@@ -68,7 +68,7 @@ class Autoencoder(DeepEstimator, AnomalyDetector):
68
68
  >>> from river.preprocessing import MinMaxScaler
69
69
 
70
70
  >>> dataset = CreditCard().take(5000)
71
- >>> metric = metrics.ROCAUC(n_thresholds=50)
71
+ >>> metric = metrics.RollingROCAUC(window_size=5000)
72
72
 
73
73
  >>> class MyAutoEncoder(torch.nn.Module):
74
74
  ... def __init__(self, n_features, latent_dim=3):
@@ -93,8 +93,8 @@ class Autoencoder(DeepEstimator, AnomalyDetector):
93
93
  ... model.learn_one(x=x)
94
94
  ... metric.update(y, score)
95
95
  ...
96
- >>> print(f"ROCAUC: {metric.get():.4f}")
97
- ROCAUC: 0.7812
96
+ >>> print(f"Rolling ROCAUC: {metric.get():.4f}")
97
+ Rolling ROCAUC: 0.8901
98
98
  """
99
99
 
100
100
  def __init__(
@@ -212,9 +212,7 @@ class Autoencoder(DeepEstimator, AnomalyDetector):
212
212
 
213
213
  self._adapt_input_dim(x)
214
214
 
215
- x_t = dict2tensor(
216
- x, features=self.observed_features, device=self.device
217
- )
215
+ x_t = dict2tensor(x, features=self.observed_features, device=self.device)
218
216
  self.module.eval()
219
217
  with torch.inference_mode():
220
218
  x_pred = self.module(x_t)
@@ -62,7 +62,7 @@ class ProbabilityWeightedAutoencoder(ae.Autoencoder):
62
62
 
63
63
  >>> _ = manual_seed(42)
64
64
  >>> dataset = CreditCard().take(5000)
65
- >>> metric = metrics.ROCAUC(n_thresholds=50)
65
+ >>> metric = metrics.RollingROCAUC(window_size=5000)
66
66
 
67
67
  >>> class MyAutoEncoder(torch.nn.Module):
68
68
  ... def __init__(self, n_features, latent_dim=3):
@@ -87,8 +87,8 @@ class ProbabilityWeightedAutoencoder(ae.Autoencoder):
87
87
  ... model.learn_one(x=x)
88
88
  ... metric.update(y, score)
89
89
  ...
90
- >>> print(f"ROCAUC: {metric.get():.4f}")
91
- ROCAUC: 0.7572
90
+ >>> print(f"Rolling ROCAUC: {metric.get():.4f}")
91
+ Rolling ROCAUC: 0.8530
92
92
  """
93
93
 
94
94
  def __init__(
@@ -114,9 +114,7 @@ class ProbabilityWeightedAutoencoder(ae.Autoencoder):
114
114
  )
115
115
  self.window_size = window_size
116
116
  self.skip_threshold = skip_threshold
117
- self.rolling_mean = utils.Rolling(
118
- stats.Mean(), window_size=window_size
119
- )
117
+ self.rolling_mean = utils.Rolling(stats.Mean(), window_size=window_size)
120
118
  self.rolling_var = utils.Rolling(stats.Var(), window_size=window_size)
121
119
 
122
120
  def learn_one(
@@ -165,10 +163,7 @@ class ProbabilityWeightedAutoencoder(ae.Autoencoder):
165
163
 
166
164
  loss_scaled = (losses_numpy - mean) / math.sqrt(var)
167
165
  prob = ndtr(loss_scaled)
168
- loss = (
169
- torch.tensor((self.skip_threshold - prob) / self.skip_threshold)
170
- * loss
171
- )
166
+ loss = torch.tensor((self.skip_threshold - prob) / self.skip_threshold) * loss
172
167
 
173
168
  self.optimizer.zero_grad()
174
169
  loss.backward()
@@ -11,9 +11,7 @@ from deep_river.utils.tensor_conversion import deque2rolling_tensor
11
11
 
12
12
 
13
13
  class _TestLSTMAutoencoder(nn.Module):
14
- def __init__(
15
- self, n_features, hidden_size=30, n_layers=1, batch_first=False
16
- ):
14
+ def __init__(self, n_features, hidden_size=30, n_layers=1, batch_first=False):
17
15
  super().__init__()
18
16
  self.n_features = n_features
19
17
  self.hidden_size = hidden_size
@@ -142,9 +140,7 @@ class RollingAutoencoder(RollingDeepEstimator, anomaly.base.AnomalyDetector):
142
140
  loss.backward()
143
141
  self.optimizer.step()
144
142
 
145
- def learn_one(
146
- self, x: dict, y: Any = None, **kwargs
147
- ) -> "RollingAutoencoder":
143
+ def learn_one(self, x: dict, y: Any = None, **kwargs) -> "RollingAutoencoder":
148
144
  """
149
145
  Performs one step of training with a single example.
150
146
 
@@ -145,9 +145,7 @@ class AnomalyStandardScaler(AnomalyScaler):
145
145
  super().__init__(anomaly_detector)
146
146
  self.rolling = rolling
147
147
  self.window_size = window_size
148
- self.mean = (
149
- utils.Rolling(Mean(), self.window_size) if self.rolling else Mean()
150
- )
148
+ self.mean = utils.Rolling(Mean(), self.window_size) if self.rolling else Mean()
151
149
  self.sq_mean = (
152
150
  utils.Rolling(Mean(), self.window_size) if self.rolling else Mean()
153
151
  )
@@ -208,9 +206,7 @@ class AnomalyMeanScaler(AnomalyScaler):
208
206
  super().__init__(anomaly_detector=anomaly_detector)
209
207
  self.rolling = rolling
210
208
  self.window_size = window_size
211
- self.mean = (
212
- utils.Rolling(Mean(), self.window_size) if self.rolling else Mean()
213
- )
209
+ self.mean = utils.Rolling(Mean(), self.window_size) if self.rolling else Mean()
214
210
 
215
211
  def score_one(self, *args):
216
212
  """
@@ -21,9 +21,7 @@ try:
21
21
  from graphviz import Digraph
22
22
  from torchviz import make_dot
23
23
  except ImportError as e:
24
- raise ValueError(
25
- "You have to install graphviz to use the draw method"
26
- ) from e
24
+ raise ValueError("You have to install graphviz to use the draw method") from e
27
25
 
28
26
 
29
27
  class DeepEstimator(base.Estimator):
@@ -119,9 +117,7 @@ class DeepEstimator(base.Estimator):
119
117
  first_parameter = next(self.module.parameters())
120
118
  input_shape = first_parameter.size()
121
119
  y_pred = self.module(torch.rand(input_shape))
122
- return make_dot(
123
- y_pred.mean(), params=dict(self.module.named_parameters())
124
- )
120
+ return make_dot(y_pred.mean(), params=dict(self.module.named_parameters()))
125
121
 
126
122
  def initialize_module(self, x: dict | pd.DataFrame, **kwargs):
127
123
  """
@@ -151,9 +147,7 @@ class DeepEstimator(base.Estimator):
151
147
  )
152
148
 
153
149
  self.module.to(self.device)
154
- self.optimizer = self.optimizer_func(
155
- self.module.parameters(), lr=self.lr
156
- )
150
+ self.optimizer = self.optimizer_func(self.module.parameters(), lr=self.lr)
157
151
  self.module_initialized = True
158
152
 
159
153
  self._get_input_output_layers(n_features=n_features)
@@ -245,9 +239,7 @@ class DeepEstimator(base.Estimator):
245
239
  tracker.ordered_modules[0], SUPPORTED_LAYERS
246
240
  ):
247
241
  self.input_layer = tracker.ordered_modules[0]
248
- self.input_expansion_instructions = load_instructions(
249
- self.input_layer
250
- )
242
+ self.input_expansion_instructions = load_instructions(self.input_layer)
251
243
  else:
252
244
  warnings.warn(
253
245
  "The model will not be able to adapt its input layer to "
@@ -1,9 +1,6 @@
1
1
  from deep_river.classification.classifier import Classifier
2
2
  from deep_river.classification.rolling_classifier import RollingClassifier
3
- from deep_river.classification.zoo import (
4
- LogisticRegression,
5
- MultiLayerPerceptron,
6
- )
3
+ from deep_river.classification.zoo import LogisticRegression, MultiLayerPerceptron
7
4
 
8
5
  """
9
6
  This module contains the classifiers for the deep_river package.
@@ -227,9 +227,7 @@ class Classifier(DeepEstimator, base.MiniBatchClassifier):
227
227
  self._adapt_input_dim(x)
228
228
  self._adapt_output_dim(y)
229
229
 
230
- x_t = dict2tensor(
231
- x, features=self.observed_features, device=self.device
232
- )
230
+ x_t = dict2tensor(x, features=self.observed_features, device=self.device)
233
231
 
234
232
  return self._learn(x=x_t, y=y)
235
233
 
@@ -254,16 +252,12 @@ class Classifier(DeepEstimator, base.MiniBatchClassifier):
254
252
 
255
253
  self._adapt_input_dim(x)
256
254
 
257
- x_t = dict2tensor(
258
- x, features=self.observed_features, device=self.device
259
- )
255
+ x_t = dict2tensor(x, features=self.observed_features, device=self.device)
260
256
 
261
257
  self.module.eval()
262
258
  with torch.inference_mode():
263
259
  y_pred = self.module(x_t)
264
- return output2proba(
265
- y_pred, self.observed_classes, self.output_is_logit
266
- )[0]
260
+ return output2proba(y_pred, self.observed_classes, self.output_is_logit)[0]
267
261
 
268
262
  def _update_observed_classes(self, y) -> bool:
269
263
  n_existing_classes = len(self.observed_classes)
@@ -292,13 +286,13 @@ class Classifier(DeepEstimator, base.MiniBatchClassifier):
292
286
  output=True,
293
287
  )
294
288
 
295
- def learn_many(self, x: pd.DataFrame, y: pd.Series) -> "Classifier":
289
+ def learn_many(self, X: pd.DataFrame, y: pd.Series) -> "Classifier":
296
290
  """
297
291
  Performs one step of training with a batch of examples.
298
292
 
299
293
  Parameters
300
294
  ----------
301
- x
295
+ X
302
296
  Input examples.
303
297
  y
304
298
  Target values.
@@ -311,14 +305,14 @@ class Classifier(DeepEstimator, base.MiniBatchClassifier):
311
305
  # check if model is initialized
312
306
 
313
307
  if not self.module_initialized:
314
- self._update_observed_features(x)
308
+ self._update_observed_features(X)
315
309
  self._update_observed_classes(y)
316
- self.initialize_module(x=x, **self.kwargs)
310
+ self.initialize_module(x=X, **self.kwargs)
317
311
 
318
- self._adapt_input_dim(x)
312
+ self._adapt_input_dim(X)
319
313
  self._adapt_output_dim(y)
320
314
 
321
- x_t = df2tensor(x, features=self.observed_features, device=self.device)
315
+ x_t = df2tensor(X, features=self.observed_features, device=self.device)
322
316
 
323
317
  return self._learn(x=x_t, y=y)
324
318
 
@@ -6,10 +6,7 @@ from river.base.typing import ClfTarget
6
6
 
7
7
  from deep_river.base import RollingDeepEstimator
8
8
  from deep_river.classification import Classifier
9
- from deep_river.utils.tensor_conversion import (
10
- deque2rolling_tensor,
11
- output2proba,
12
- )
9
+ from deep_river.utils.tensor_conversion import deque2rolling_tensor, output2proba
13
10
 
14
11
 
15
12
  class _TestLSTM(torch.nn.Module):
@@ -150,9 +147,7 @@ class RollingClassifier(Classifier, RollingDeepEstimator):
150
147
  "check_predict_proba_one",
151
148
  }
152
149
 
153
- def learn_one(
154
- self, x: dict, y: ClfTarget, **kwargs
155
- ) -> "RollingClassifier":
150
+ def learn_one(self, x: dict, y: ClfTarget, **kwargs) -> "RollingClassifier":
156
151
  """
157
152
  Performs one step of training with the most recent training examples
158
153
  stored in the sliding window.
@@ -177,9 +172,7 @@ class RollingClassifier(Classifier, RollingDeepEstimator):
177
172
 
178
173
  self._adapt_input_dim(x)
179
174
  self._adapt_output_dim(y)
180
- self._x_window.append(
181
- [x.get(feature, 0) for feature in self.observed_features]
182
- )
175
+ self._x_window.append([x.get(feature, 0) for feature in self.observed_features])
183
176
 
184
177
  # training process
185
178
  if len(self._x_window) == self.window_size:
@@ -217,20 +210,18 @@ class RollingClassifier(Classifier, RollingDeepEstimator):
217
210
  with torch.inference_mode():
218
211
  x_t = deque2rolling_tensor(x_win, device=self.device)
219
212
  y_pred = self.module(x_t)
220
- proba = output2proba(
221
- y_pred, self.observed_classes, self.output_is_logit
222
- )
213
+ proba = output2proba(y_pred, self.observed_classes, self.output_is_logit)
223
214
 
224
215
  return proba[0]
225
216
 
226
- def learn_many(self, x: pd.DataFrame, y: pd.Series) -> "RollingClassifier":
217
+ def learn_many(self, X: pd.DataFrame, y: pd.Series) -> "RollingClassifier":
227
218
  """
228
219
  Performs one step of training with the most recent training examples
229
220
  stored in the sliding window.
230
221
 
231
222
  Parameters
232
223
  ----------
233
- x
224
+ X
234
225
  Input examples.
235
226
  y
236
227
  Target values.
@@ -243,13 +234,13 @@ class RollingClassifier(Classifier, RollingDeepEstimator):
243
234
  # check if model is initialized
244
235
  if not self.module_initialized:
245
236
  self._update_observed_classes(y)
246
- self._update_observed_features(x)
247
- self.initialize_module(x=x, **self.kwargs)
237
+ self._update_observed_features(X)
238
+ self.initialize_module(x=X, **self.kwargs)
248
239
 
249
- self._adapt_input_dim(x)
240
+ self._adapt_input_dim(X)
250
241
  self._adapt_output_dim(y)
251
- x = x[list(self.observed_features)]
252
- self._x_window.extend(x.values.tolist())
242
+ X = X[list(self.observed_features)]
243
+ self._x_window.extend(X.values.tolist())
253
244
 
254
245
  if self.is_class_incremental:
255
246
  self._adapt_output_dim(y)
@@ -205,9 +205,7 @@ class MultiLayerPerceptron(Classifier):
205
205
  def __init__(self, n_width, n_layers, n_features):
206
206
  super().__init__()
207
207
  hidden = [nn.Linear(n_features, n_width)]
208
- hidden += [
209
- nn.Linear(n_width, n_width) for _ in range(n_layers - 1)
210
- ]
208
+ hidden += [nn.Linear(n_width, n_width) for _ in range(n_layers - 1)]
211
209
  self.hidden = nn.ModuleList(hidden)
212
210
  self.denselast = nn.Linear(n_width, 1)
213
211
 
@@ -106,9 +106,7 @@ class MultiTargetRegressor(RiverMultiTargetRegressor, DeepEstimator):
106
106
  seed=seed,
107
107
  **kwargs,
108
108
  )
109
- self.observed_targets: OrderedDict[FeatureName, RegTarget] = (
110
- OrderedDict()
111
- )
109
+ self.observed_targets: OrderedDict[FeatureName, RegTarget] = OrderedDict()
112
110
 
113
111
  @classmethod
114
112
  def _unit_test_params(cls):
@@ -195,7 +193,5 @@ class MultiTargetRegressor(RiverMultiTargetRegressor, DeepEstimator):
195
193
  self.module.eval()
196
194
  with torch.inference_mode():
197
195
  y_pred_t = self.module(x_t).squeeze().tolist()
198
- y_pred = {
199
- t: y_pred_t[i] for i, t in enumerate(self.observed_targets)
200
- }
196
+ y_pred = {t: y_pred_t[i] for i, t in enumerate(self.observed_targets)}
201
197
  return y_pred
@@ -1,4 +1,4 @@
1
- from typing import Callable, List, Type, Union
1
+ from typing import Callable, Type, Union
2
2
 
3
3
  import pandas as pd
4
4
  import torch
@@ -6,11 +6,7 @@ from river import base
6
6
  from river.base.typing import RegTarget
7
7
 
8
8
  from deep_river.base import DeepEstimator
9
- from deep_river.utils.tensor_conversion import (
10
- df2tensor,
11
- dict2tensor,
12
- float2tensor,
13
- )
9
+ from deep_river.utils.tensor_conversion import df2tensor, dict2tensor, float2tensor
14
10
 
15
11
 
16
12
  class _TestModule(torch.nn.Module):
@@ -143,9 +139,7 @@ class Regressor(DeepEstimator, base.MiniBatchRegressor):
143
139
  self._update_observed_features(x)
144
140
  self.initialize_module(x=x, **self.kwargs)
145
141
  self._adapt_input_dim(x)
146
- x_t = dict2tensor(
147
- x, features=self.observed_features, device=self.device
148
- )
142
+ x_t = dict2tensor(x, features=self.observed_features, device=self.device)
149
143
  y_t = float2tensor(y, device=self.device)
150
144
 
151
145
  self._learn(x_t, y_t)
@@ -177,9 +171,7 @@ class Regressor(DeepEstimator, base.MiniBatchRegressor):
177
171
  self._update_observed_features(x)
178
172
  self.initialize_module(x=x, **self.kwargs)
179
173
  self._adapt_input_dim(x)
180
- x_t = dict2tensor(
181
- x, features=self.observed_features, device=self.device
182
- )
174
+ x_t = dict2tensor(x, features=self.observed_features, device=self.device)
183
175
 
184
176
  self.module.eval()
185
177
  with torch.inference_mode():
@@ -209,14 +201,12 @@ class Regressor(DeepEstimator, base.MiniBatchRegressor):
209
201
 
210
202
  self._adapt_input_dim(X)
211
203
  X_t = df2tensor(X, features=self.observed_features, device=self.device)
212
- y_t = torch.tensor(
213
- y, device=self.device, dtype=torch.float32
214
- ).unsqueeze(1)
204
+ y_t = torch.tensor(y, device=self.device, dtype=torch.float32).unsqueeze(1)
215
205
 
216
206
  self._learn(X_t, y_t)
217
207
  return self
218
208
 
219
- def predict_many(self, X: pd.DataFrame) -> List:
209
+ def predict_many(self, X: pd.DataFrame) -> pd.Series:
220
210
  """
221
211
  Predicts the target value for a batch of examples.
222
212