We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents a04afd3 + f1525b8 commit 3c50162Copy full SHA for 3c50162
.github/workflows/test.yml
@@ -35,8 +35,6 @@ jobs:
35
run: |
36
conda install pytest
37
make coverage
38
- - name: Test docstrings examples
39
- run: make doctest
40
- name: typing with mypy
41
42
mypy qolmat
Makefile
@@ -4,6 +4,10 @@ coverage:
4
doctest:
5
pytest --doctest-modules --pyargs qolmat
6
7
+doc:
8
+ make html -C docs
9
+
10
clean:
11
rm -rf .mypy_cache .pytest_cache .coverage*
12
rm -rf **__pycache__
13
+ make clean -C docs
qolmat/imputations/em_sampler.py
@@ -664,14 +664,19 @@ class VARpEM(EM):
664
Examples
665
--------
666
>>> import numpy as np
667
- >>> import pandas as pd
668
>>> from qolmat.imputations.em_sampler import VARpEM
669
- >>> imputer = VARpEM(method="sample")
670
- >>> X = pd.DataFrame(data=[[1, 1, 1, 1],
671
- ... [np.nan, np.nan, 3, 2],
672
- ... [1, 2, 2, 1], [2, 2, 2, 2]],
673
- ... columns=["var1", "var2", "var3", "var4"])
674
- >>> imputer.fit_transform(X) # doctest: +SKIP
+ >>> imputer = VARpEM(method="sample", random_state=11)
+ >>> X = np.array([[1, 1, 1, 1],
+ ... [np.nan, np.nan, 3, 2],
+ ... [1, 2, 2, 1], [2, 2, 2, 2]])
+ >>> imputer.fit_transform(X)
+ EM converged after 9 iterations.
+ EM converged after 20 iterations.
675
+ EM converged after 13 iterations.
676
+ array([[1. , 1. , 1. , 1. ],
677
+ [1.17054054, 1.49986137, 3. , 2. ],
678
+ [1. , 2. , 2. , 1. ],
679
+ [2. , 2. , 2. , 2. ]])
680
"""
681
682
def __init__(
qolmat/imputations/imputers.py
@@ -1114,10 +1114,10 @@ class ImputerResiduals(_Imputer):
1114
1115
1116
1117
- TODO review/remake this exemple
1118
1119
>>> import pandas as pd
1120
>>> from qolmat.imputations.imputers import ImputerResiduals
+ >>> np.random.seed(100)
1121
>>> df = pd.DataFrame(index=pd.date_range('2015-01-01','2020-01-01'))
1122
>>> mean = 5
1123
>>> offset = 10
@@ -1127,11 +1127,24 @@ class ImputerResiduals(_Imputer):
1127
>>> noise_mean = 0
1128
>>> noise_var = 2
1129
>>> df['y'] = df['y'] + np.random.normal(noise_mean, noise_var, df.shape[0])
1130
- >>> np.random.seed(100)
1131
>>> mask = np.random.choice([True, False], size=df.shape)
1132
>>> df = df.mask(mask)
1133
- >>> imputor.fit_transform(df) # doctest: +SKIP
1134
>>> imputor = ImputerResiduals(period=365, model_tsa="additive")
+ >>> imputor.fit_transform(df)
+ y
1135
+ 2015-01-01 1.501210
1136
+ 2015-01-02 5.691061
1137
+ 2015-01-03 4.404106
1138
+ 2015-01-04 3.531540
1139
+ 2015-01-05 3.129532
1140
+ ... ...
1141
+ 2019-12-28 10.288054
1142
+ 2019-12-29 10.632659
1143
+ 2019-12-30 14.900671
1144
+ 2019-12-31 12.957837
1145
+ 2020-01-01 12.780517
1146
+ <BLANKLINE>
1147
+ [1827 rows x 1 columns]
1148
1149
1150
qolmat/imputations/softimpute.py
@@ -46,12 +46,12 @@ class SoftImpute(BaseEstimator, TransformerMixin):
46
47
>>> from qolmat.imputations.softimpute import SoftImpute
48
>>> X = np.array([[1, 2, np.nan, 4], [1, 5, 3, np.nan], [4, 2, 3, 2], [1, 1, 5, 4]])
49
- >>> X_imputed = SoftImpute().fit_transform(X)
+ >>> X_imputed = SoftImpute(random_state=11).fit_transform(X)
50
>>> print(X_imputed)
51
- [[ 1. 2. 4.7369014 4. ]
52
- [ 1. 5. 3. -0.52477073]
53
- [ 4. 2. 3. 2. ]
54
- [ 1. 1. 5. 4. ]]
+ [[1. 2. 3.7242757 4. ]
+ [1. 5. 3. 1.97846028]
+ [4. 2. 3. 2. ]
+ [1. 1. 5. 4. ]]
55
56
57
0 commit comments