Skip to content

Commit edf847c

Browse files
author
Gsaes
committed
Merge branch 'dev' of https://github.com/Quantmetry/qolmat into dev_test_rpca
2 parents a1d23e8 + cf46338 commit edf847c

File tree

3 files changed

+8
-13
lines changed

3 files changed

+8
-13
lines changed

environment.ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ dependencies:
1212
- numpydoc==1.5.0
1313
- pytest==7.2.0
1414
- pytest-cov==4.0.0
15+
- tensorflow
1516
- -e .

examples/benchmark.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ dict_imputers["MLP"] = imputer_mlp = imputers_keras.ImputerRegressorKeras(estima
329329

330330
We can re-run the imputation model benchmark as before.
331331

332-
```python tags=[] jupyter={"outputs_hidden": true}
332+
```python tags=[]
333333
generator_holes = missing_patterns.EmpiricalHoleGenerator(n_splits=2, subset = cols_to_impute, ratio_masked=ratio_masked)
334334

335335
comparison = comparator.Comparator(
@@ -350,7 +350,7 @@ plt.ylabel("mae")
350350
plt.show()
351351
```
352352

353-
```python jupyter={"outputs_hidden": true}
353+
```python
354354
df_plot = df_data
355355
dfs_imputed = {name: imp.fit_transform(df_plot) for name, imp in dict_imputers.items()}
356356
station = df_plot.index.get_level_values("station")[0]

qolmat/utils/data.py

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,7 @@ def add_station_features(df: pd.DataFrame):
189189
"""
190190
stations = df.index.get_level_values("station")
191191
for station in stations.unique():
192-
df[f"station={station}"] = 1 * (stations == station)
192+
df[f"station={station}"] = (stations == station).astype(float)
193193
return df
194194

195195

@@ -208,15 +208,9 @@ def add_datetime_features(df: pd.DataFrame):
208208
dataframe with missing values
209209
"""
210210

211-
time = np.concatenate(
212-
[
213-
np.cos(2 * np.pi * np.arange(60, 366) / 365),
214-
np.cos(2 * np.pi * np.arange(1, 366) / 365),
215-
np.cos(2 * np.pi * np.arange(1, 366) / 365),
216-
np.cos(2 * np.pi * np.arange(1, 367) / 366),
217-
np.cos(2 * np.pi * np.arange(1, 60) / 365),
218-
]
211+
time = df.index.get_level.values("datetime")
212+
days_in_year = time.dt.year.apply(
213+
lambda x: 366 if ((x % 4 == 0) and (x % 100 != 0)) or (x % 400 == 0) else 365
219214
)
220-
for i_station, (station, dfs) in enumerate(df.groupby("station")):
221-
df.loc[station, "Time"] = time
215+
df["time_cos"] = np.cos(2 * np.pi * time.dt.dayofyear / days_in_year)
222216
return df

0 commit comments

Comments
 (0)