Skip to content

Commit d2d985d

Browse files
Merge pull request #154 from scikit-learn-contrib/rpca_patch
Rpca patch
2 parents e3ae559 + fe411a7 commit d2d985d

File tree

6 files changed

+26
-9
lines changed

6 files changed

+26
-9
lines changed

.bumpversion.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[bumpversion]
2-
current_version = 0.1.7
2+
current_version = 0.1.8
33
commit = True
44
tag = True
55

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
author = "Quantmetry"
2828

2929
# The full version, including alpha/beta/rc tags
30-
version = "0.1.7"
30+
version = "0.1.8"
3131
release = version
3232

3333
# -- General configuration ---------------------------------------------------

examples/RPCA.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ from qolmat.imputations.rpca import rpca_utils
3434
from qolmat.utils.data import generate_artificial_ts
3535
```
3636

37+
```python
38+
from qolmat.imputations.imputers import ImputerRpcaNoisy, ImputerRpcaPcp
39+
```
40+
3741
**Generate synthetic data**
3842

3943
```python tags=[]
@@ -46,16 +50,33 @@ amp_noise = 0.1
4650
X_true, A_true, E_true = generate_artificial_ts(n_samples, periods, amp_anomalies, ratio_anomalies, amp_noise)
4751

4852
signal = X_true + A_true + E_true
53+
signal = 10 + signal * 40
4954

5055
# Adding missing data
5156
signal[120:180] = np.nan
5257
signal[:20] = np.nan
58+
for i in range(10):
59+
signal[i::365] = np.nan
5360
# signal[80:220] = np.nan
5461
# mask = np.random.choice(len(signal), round(len(signal) / 20))
5562
# signal[mask] = np.nan
5663

5764
```
5865

66+
```python
67+
import pandas as pd
68+
df = pd.DataFrame({"signal": signal})
69+
irn = ImputerRpcaPcp(period=100)
70+
df_imp = irn.fit_transform(df)
71+
```
72+
73+
```python
74+
plt.plot(df_imp["signal"])
75+
plt.plot(df["signal"])
76+
77+
plt.xlim(0, 200)
78+
```
79+
5980
```python tags=[]
6081
fig = plt.figure(figsize=(15, 8))
6182
ax = fig.add_subplot(4, 1, 1)

qolmat/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.1.7"
1+
__version__ = "0.1.8"

qolmat/imputations/imputers.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1515,13 +1515,10 @@ def _transform_element(
15151515
D_scale = (D - means) / stds
15161516
M, A = model.decompose(D_scale, Omega)
15171517
M = M * stds + means
1518-
A = A * stds + means
15191518

15201519
M_final = utils.get_shape_original(M, X.shape)
1521-
A_final = utils.get_shape_original(A, X.shape)
1522-
X_imputed = M_final + A_final
15231520

1524-
df_imputed = pd.DataFrame(X_imputed, index=df.index, columns=df.columns)
1521+
df_imputed = pd.DataFrame(M_final, index=df.index, columns=df.columns)
15251522
df_imputed = df.where(~df.isna(), df_imputed)
15261523

15271524
return df_imputed
@@ -1705,7 +1702,6 @@ def _transform_element(
17051702
D_scale = (D - means) / stds
17061703
M, A = model.decompose_on_basis(D_scale, Omega, Q)
17071704
M = M * stds + means
1708-
A = A * stds + means
17091705

17101706
M_final = utils.get_shape_original(M, X.shape)
17111707

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from setuptools import find_packages, setup
44

55
DISTNAME = "qolmat"
6-
VERSION = "0.1.7"
6+
VERSION = "0.1.8"
77
DESCRIPTION = "A Python library for optimal data imputation."
88
LONG_DESCRIPTION_CONTENT_TYPE = "text/x-rst"
99
with codecs.open("README.rst", encoding="utf-8-sig") as f:

0 commit comments

Comments
 (0)