Skip to content

Commit

Permalink
FIX: n_seen discrepancy; revert + UPDATE: more ellipsis
Browse files Browse the repository at this point in the history
  • Loading branch information
MarekWadinger committed Mar 14, 2024
1 parent 64272e8 commit 972abea
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions river/decomposition/osvd.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,8 @@ class OnlineSVD(MiniBatchTransformer):
>>> svd.learn_many(X.iloc[30:60])
>>> svd.transform_many(X.iloc[60:62])
0 1 2 3
0 -0.103403 0.134656 -0.108399 -0.125872
1 -0.063485 0.023943 -0.120235 -0.088502
0 ...0.103403 0.134656 ...0.108399 ...0.125872
1 ...0.063485 0.023943 ...0.120235 ...0.088502
References:
[^1]: Brand, M. (2006). Fast low-rank modifications of the thin singular value decomposition. Linear Algebra and its Applications, 415(1), pp.20-30. doi:[10.1016/j.laa.2005.07.021](https://doi.org/10.1016/j.laa.2005.07.021).
Expand Down Expand Up @@ -185,8 +185,8 @@ def update(self, x: dict | np.ndarray):
self._X_init[self.n_seen, :] = x
if self.n_seen == self.initialize - 1:
self.learn_many(self._X_init)
# revert the number of seen samples to avoid doubling
self.n_seen -= self._X_init.shape[0]
# revert I seen which learn_many accounted for
self.n_seen -= 1
else:
m = (x @ self._U).T
p = x.T - self._U @ m
Expand Down Expand Up @@ -224,7 +224,7 @@ def revert(self, x: dict | np.ndarray, idx: int = 0):
x = x.reshape(1, -1)

b = np.zeros(self._V.shape[1])
b[idx] = 1.
b[-1] = 1.
b = b.reshape(-1, 1)

n = self._V[:, idx].reshape(-1, 1)
Expand Down

0 comments on commit 972abea

Please sign in to comment.