Skip to content

Commit 0150afb

Browse files
authored
Merge pull request #3 from MLD3/hotfix-2021-feb
Hotfix 2021 feb (v0.2.2)
2 parents f260174 + 7bece88 commit 0150afb

File tree

6 files changed

+372
-429
lines changed

6 files changed

+372
-429
lines changed

FIDDLE/helpers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,10 +153,10 @@ def smart_qcut_dummify(x, bin_edges, use_ordinal_encoding=False):
153153
out = pd.get_dummies(x, prefix=x.name)
154154
else:
155155
if use_ordinal_encoding:
156-
col_names = ['{}>={}'.format(z.name, bin_edge) for bin_edge in bin_edges[:-1]]
156+
col_names = ['{}>{}'.format(z.name, bin_edge) for bin_edge in bin_edges[:-1]]
157157
out = pd.DataFrame(0, z.index, col_names)
158158
for i, bin_edge in enumerate(bin_edges[:-1]):
159-
out.loc[m, col_names[i]] = (z.loc[m] >= bin_edge).astype(int)
159+
out.loc[m, col_names[i]] = (z.loc[m] > bin_edge).astype(int)
160160
out = pd.concat([out, pd.get_dummies(z.where(~m, np.nan), prefix=z.name)], axis=1)
161161
else:
162162
z.loc[m] = pd.cut(z.loc[m].astype(float).to_numpy(), bin_edges, duplicates='drop', include_lowest=True)
@@ -179,15 +179,15 @@ def smart_dummify_impute(x):
179179
def make_float(v):
180180
try:
181181
return float(v)
182-
except ValueError:
182+
except (ValueError, TypeError):
183183
return v
184184
assert False
185185

186186
def is_numeric(v):
187187
try:
188188
float(v)
189189
return True
190-
except ValueError:
190+
except (ValueError, TypeError):
191191
return False
192192
assert False
193193

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ s = sparse.load_npz('{data_path}/s.npz'.format(data_path=...)).todense()
8181
Example usage:
8282
```bash
8383
python -m FIDDLE.run \
84-
--data_path='./test/small_test/' \
85-
--population='./test/small_test/pop.csv' \
84+
--data_path='./tests/small_test/' \
85+
--population='./tests/small_test/pop.csv' \
8686
--T=24 --dt=5 \
8787
--theta_1=0.001 --theta_2=0.001 --theta_freq=1 \
8888
--stats_functions 'min' 'max' 'mean'

tests/icd_test/Run.ipynb

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,7 @@
44
"cell_type": "code",
55
"execution_count": 1,
66
"metadata": {},
7-
"outputs": [
8-
{
9-
"name": "stdout",
10-
"output_type": "stream",
11-
"text": [
12-
"zsh:1: no matches found: output-*/\n"
13-
]
14-
}
15-
],
7+
"outputs": [],
168
"source": [
179
"!rm -rf output-*/"
1810
]
@@ -111,25 +103,24 @@
111103
"--------------------------------------------------------------------------------\n",
112104
"(N × ^d) table :\t (200, 19)\n",
113105
"number of missing entries :\t 2816 out of 3800 total\n",
114-
"Time elapsed: 0.025395 seconds\n",
106+
"Time elapsed: 0.012328 seconds\n",
115107
"\n",
116108
"Output\n",
117109
"S_all, binary features :\t (200, 21)\n",
118-
"Time elapsed: 0.171098 seconds\n",
110+
"Time elapsed: 0.101575 seconds\n",
119111
"\n",
120112
"--------------------------------------------------------------------------------\n",
121113
"3-A) Post-filter time-invariant data\n",
122114
"--------------------------------------------------------------------------------\n",
123115
"Original : 21\n",
124116
"Nearly-constant: 0\n",
125117
"Correlated : 0\n",
126-
"Time elapsed: 0.178303 seconds\n",
118+
"Time elapsed: 0.104368 seconds\n",
127119
"\n",
128120
"Output\n",
129121
"S: shape=(200, 21), density=0.234\n",
130-
"Total time: 0.180898 seconds\n",
131-
"\n",
132-
"\u001b[0m"
122+
"Total time: 0.106207 seconds\n",
123+
"\n"
133124
]
134125
}
135126
],
@@ -732,25 +723,24 @@
732723
"--------------------------------------------------------------------------------\n",
733724
"(N × ^d) table :\t (200, 129)\n",
734725
"number of missing entries :\t 23337 out of 25800 total\n",
735-
"Time elapsed: 0.057711 seconds\n",
726+
"Time elapsed: 0.034244 seconds\n",
736727
"\n",
737728
"Output\n",
738729
"S_all, binary features :\t (200, 129)\n",
739-
"Time elapsed: 0.830818 seconds\n",
730+
"Time elapsed: 0.558320 seconds\n",
740731
"\n",
741732
"--------------------------------------------------------------------------------\n",
742733
"3-A) Post-filter time-invariant data\n",
743734
"--------------------------------------------------------------------------------\n",
744735
"Original : 129\n",
745736
"Nearly-constant: 0\n",
746737
"Correlated : 2\n",
747-
"Time elapsed: 0.840801 seconds\n",
738+
"Time elapsed: 0.564048 seconds\n",
748739
"\n",
749740
"Output\n",
750741
"S: shape=(200, 127), density=0.097\n",
751-
"Total time: 0.844234 seconds\n",
752-
"\n",
753-
"\u001b[0m"
742+
"Total time: 0.567541 seconds\n",
743+
"\n"
754744
]
755745
}
756746
],
@@ -1353,25 +1343,24 @@
13531343
"--------------------------------------------------------------------------------\n",
13541344
"(N × ^d) table :\t (200, 455)\n",
13551345
"number of missing entries :\t 86795 out of 91000 total\n",
1356-
"Time elapsed: 0.112510 seconds\n",
1346+
"Time elapsed: 0.092419 seconds\n",
13571347
"\n",
13581348
"Output\n",
13591349
"S_all, binary features :\t (200, 455)\n",
1360-
"Time elapsed: 2.377939 seconds\n",
1350+
"Time elapsed: 1.690453 seconds\n",
13611351
"\n",
13621352
"--------------------------------------------------------------------------------\n",
13631353
"3-A) Post-filter time-invariant data\n",
13641354
"--------------------------------------------------------------------------------\n",
13651355
"Original : 455\n",
13661356
"Nearly-constant: 0\n",
13671357
"Correlated : 87\n",
1368-
"Time elapsed: 2.428499 seconds\n",
1358+
"Time elapsed: 1.715216 seconds\n",
13691359
"\n",
13701360
"Output\n",
13711361
"S: shape=(200, 368), density=0.055\n",
1372-
"Total time: 2.435949 seconds\n",
1373-
"\n",
1374-
"\u001b[0m"
1362+
"Total time: 1.719981 seconds\n",
1363+
"\n"
13751364
]
13761365
}
13771366
],
@@ -1916,7 +1905,7 @@
19161905
"name": "python",
19171906
"nbconvert_exporter": "python",
19181907
"pygments_lexer": "ipython3",
1919-
"version": "3.8.6"
1908+
"version": "3.8.5"
19201909
}
19211910
},
19221911
"nbformat": 4,

0 commit comments

Comments
 (0)