Skip to content

Commit 50093c5

Browse files
committed
improve test
1 parent 827d02d commit 50093c5

File tree

4 files changed

+29
-41
lines changed

4 files changed

+29
-41
lines changed

README.ipynb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,18 @@
300300
"outputs": [],
301301
"source": []
302302
},
303+
{
304+
"cell_type": "code",
305+
"execution_count": null,
306+
"outputs": [],
307+
"source": [],
308+
"metadata": {
309+
"collapsed": false,
310+
"pycharm": {
311+
"name": "#%%\n"
312+
}
313+
}
314+
},
303315
{
304316
"cell_type": "code",
305317
"execution_count": null,
@@ -329,4 +341,4 @@
329341
},
330342
"nbformat": 4,
331343
"nbformat_minor": 4
332-
}
344+
}
0 Bytes
Binary file not shown.

pkg/dist/wvpy-0.2.2.tar.gz

3 Bytes
Binary file not shown.

pkg/tests/test_stats1.py

Lines changed: 16 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,27 @@
11
import pandas
22
import wvpy.util
33
import data_algebra.test_util
4-
4+
import data_algebra.util
55

66
def test_stats1():
77
d = pandas.DataFrame({"x": [1, 2, 3, 4, 5], "y": [False, False, True, True, False]})
88

99
stats = wvpy.util.threshold_statistics(d, model_predictions="x", yvalues="y",)
10+
# print(data_algebra.util.pandas_to_example_str(stats))
1011

11-
expect = pandas.DataFrame(
12-
{
13-
"threshold": [0.999999, 1.0, 2.0, 3.0, 4.0, 5.0, 5.000001],
14-
"count": [5, 5, 4, 3, 2, 1, 0],
15-
"fraction": [1.0, 1.0, 0.8, 0.6, 0.4, 0.2, 0.0],
16-
"precision": [0.4, 0.4, 0.5, 0.6666666666666666, 0.5, 0.0, 0.0],
17-
"true_positive_rate": [1.0, 1.0, 1.0, 1.0, 0.5, 0.0, 0.0],
18-
"false_positive_rate": [
19-
1.0,
20-
1.0,
21-
0.6666666666666666,
22-
0.3333333333333333,
23-
0.3333333333333333,
24-
0.3333333333333333,
25-
0.0,
26-
],
27-
"true_negative_rate": [
28-
0.0,
29-
0.0,
30-
0.3333333333333333,
31-
0.6666666666666666,
32-
0.6666666666666666,
33-
0.6666666666666666,
34-
1.0,
35-
],
36-
"false_negative_rate": [0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 1.0],
37-
"recall": [1.0, 1.0, 1.0, 1.0, 0.5, 0.0, 0.0],
38-
"sensitivity": [1.0, 1.0, 1.0, 1.0, 0.5, 0.0, 0.0],
39-
"specificity": [
40-
0.0,
41-
0.0,
42-
0.33333333333333337,
43-
0.6666666666666667,
44-
0.6666666666666667,
45-
0.6666666666666667,
46-
1.0,
47-
],
48-
}
49-
)
12+
expect = pandas.DataFrame({
13+
'threshold': [0.999999, 1.0, 2.0, 3.0, 4.0, 5.0, 5.000001],
14+
'count': [5, 5, 4, 3, 2, 1, 0],
15+
'fraction': [1.0, 1.0, 0.8, 0.6, 0.4, 0.2, 0.0],
16+
'precision': [0.4, 0.4, 0.5, 0.6666666666666666, 0.5, 0.0, 0.0],
17+
'true_positive_rate': [1.0, 1.0, 1.0, 1.0, 0.5, 0.0, 0.0],
18+
'false_positive_rate': [1.0, 1.0, 0.6666666666666666, 0.3333333333333333, 0.3333333333333333, 0.3333333333333333, 0.0],
19+
'true_negative_rate': [0.0, 0.0, 0.3333333333333333, 0.6666666666666666, 0.6666666666666666, 0.6666666666666666, 1.0],
20+
'false_negative_rate': [0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 1.0],
21+
'cdf': [0.0, 0.0, 0.19999999999999996, 0.4, 0.6, 0.8, 1.0],
22+
'recall': [1.0, 1.0, 1.0, 1.0, 0.5, 0.0, 0.0],
23+
'sensitivity': [1.0, 1.0, 1.0, 1.0, 0.5, 0.0, 0.0],
24+
'specificity': [0.0, 0.0, 0.33333333333333337, 0.6666666666666667, 0.6666666666666667, 0.6666666666666667, 1.0],
25+
})
5026

5127
assert data_algebra.test_util.equivalent_frames(stats, expect)

0 commit comments

Comments
 (0)