Skip to content

Commit ad02a5c

Browse files
committed
test plot examples
1 parent 0121670 commit ad02a5c

File tree

13 files changed

+244
-57
lines changed

13 files changed

+244
-57
lines changed

coverage.txt

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,27 @@
22
platform darwin -- Python 3.9.7, pytest-6.2.4, py-1.10.0, pluggy-0.13.1
33
rootdir: /Users/johnmount/Documents/work/wvpy/pkg
44
plugins: cov-2.12.1, anyio-2.2.0, typeguard-2.13.0
5-
collected 13 items
5+
collected 14 items
66

77
tests/test_cross_plan1.py . [ 7%]
8-
tests/test_cross_predict.py .. [ 23%]
9-
tests/test_deviance_calc.py . [ 30%]
10-
tests/test_eval_fn_pre_row.py . [ 38%]
11-
tests/test_match_auc.py . [ 46%]
12-
tests/test_onehot.py .. [ 61%]
13-
tests/test_perm_score_vars.py . [ 69%]
14-
tests/test_search_grid.py .. [ 84%]
8+
tests/test_cross_predict.py .. [ 21%]
9+
tests/test_deviance_calc.py . [ 28%]
10+
tests/test_eval_fn_pre_row.py . [ 35%]
11+
tests/test_match_auc.py . [ 42%]
12+
tests/test_onehot.py .. [ 57%]
13+
tests/test_perm_score_vars.py . [ 64%]
14+
tests/test_plots.py . [ 71%]
15+
tests/test_search_grid.py .. [ 85%]
1516
tests/test_stats1.py . [ 92%]
1617
tests/test_threshold_stats.py . [100%]
1718

1819
---------- coverage: platform darwin, python 3.9.7-final-0 -----------
1920
Name Stmts Miss Cover
2021
--------------------------------------
2122
wvpy/__init__.py 3 0 100%
22-
wvpy/util.py 307 137 55%
23+
wvpy/util.py 307 7 98%
2324
--------------------------------------
24-
TOTAL 310 137 56%
25+
TOTAL 310 7 98%
2526

2627

27-
============================== 13 passed in 5.59s ==============================
28+
============================== 14 passed in 7.09s ==============================

pkg/Examples/example_graphs.ipynb renamed to examples/example_graphs.ipynb

Lines changed: 1 addition & 9 deletions
Large diffs are not rendered by default.

examples/graph.ipynb

Lines changed: 20 additions & 19 deletions
Large diffs are not rendered by default.

examples/stats.ipynb

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 0,
5+
"execution_count": null,
66
"metadata": {
77
"collapsed": true
88
},
@@ -15,7 +15,7 @@
1515
"outputs": [
1616
{
1717
"data": {
18-
"text/plain": "'0.2.2'"
18+
"text/plain": "'0.2.8'"
1919
},
2020
"execution_count": 1,
2121
"metadata": {},
@@ -70,8 +70,8 @@
7070
"outputs": [
7171
{
7272
"data": {
73-
"text/plain": " threshold count fraction precision true_positive_rate \\\n0 0.999999 5 1.0 0.400000 1.0 \n1 1.000000 5 1.0 0.400000 1.0 \n2 2.000000 4 0.8 0.500000 1.0 \n3 3.000000 3 0.6 0.666667 1.0 \n4 4.000000 2 0.4 0.500000 0.5 \n5 5.000000 1 0.2 0.000000 0.0 \n6 5.000001 0 0.0 NaN 0.0 \n\n false_positive_rate true_negative_rate false_negative_rate enrichment \\\n0 1.000000 0.000000 0.0 1.400000 \n1 1.000000 0.000000 0.0 1.400000 \n2 0.666667 0.333333 0.0 1.750000 \n3 0.333333 0.666667 0.0 2.333333 \n4 0.333333 0.666667 0.5 1.750000 \n5 0.333333 0.666667 1.0 0.000000 \n6 0.000000 1.000000 1.0 NaN \n\n gain lift recall sensitivity specificity \n0 1.400000 1.400000 1.0 1.0 0.000000 \n1 1.400000 1.400000 1.0 1.0 0.000000 \n2 1.750000 2.187500 1.0 1.0 0.333333 \n3 2.333333 3.888889 1.0 1.0 0.666667 \n4 1.750000 4.375000 0.5 0.5 0.666667 \n5 0.000000 0.000000 0.0 0.0 0.666667 \n6 NaN NaN 0.0 0.0 1.000000 ",
74-
"text/html": "<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>threshold</th>\n <th>count</th>\n <th>fraction</th>\n <th>precision</th>\n <th>true_positive_rate</th>\n <th>false_positive_rate</th>\n <th>true_negative_rate</th>\n <th>false_negative_rate</th>\n <th>enrichment</th>\n <th>gain</th>\n <th>lift</th>\n <th>recall</th>\n <th>sensitivity</th>\n <th>specificity</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>0.999999</td>\n <td>5</td>\n <td>1.0</td>\n <td>0.400000</td>\n <td>1.0</td>\n <td>1.000000</td>\n <td>0.000000</td>\n <td>0.0</td>\n <td>1.400000</td>\n <td>1.400000</td>\n <td>1.400000</td>\n <td>1.0</td>\n <td>1.0</td>\n <td>0.000000</td>\n </tr>\n <tr>\n <th>1</th>\n <td>1.000000</td>\n <td>5</td>\n <td>1.0</td>\n <td>0.400000</td>\n <td>1.0</td>\n <td>1.000000</td>\n <td>0.000000</td>\n <td>0.0</td>\n <td>1.400000</td>\n <td>1.400000</td>\n <td>1.400000</td>\n <td>1.0</td>\n <td>1.0</td>\n <td>0.000000</td>\n </tr>\n <tr>\n <th>2</th>\n <td>2.000000</td>\n <td>4</td>\n <td>0.8</td>\n <td>0.500000</td>\n <td>1.0</td>\n <td>0.666667</td>\n <td>0.333333</td>\n <td>0.0</td>\n <td>1.750000</td>\n <td>1.750000</td>\n <td>2.187500</td>\n <td>1.0</td>\n <td>1.0</td>\n <td>0.333333</td>\n </tr>\n <tr>\n <th>3</th>\n <td>3.000000</td>\n <td>3</td>\n <td>0.6</td>\n <td>0.666667</td>\n <td>1.0</td>\n <td>0.333333</td>\n <td>0.666667</td>\n <td>0.0</td>\n <td>2.333333</td>\n <td>2.333333</td>\n <td>3.888889</td>\n <td>1.0</td>\n <td>1.0</td>\n <td>0.666667</td>\n </tr>\n <tr>\n <th>4</th>\n <td>4.000000</td>\n <td>2</td>\n <td>0.4</td>\n <td>0.500000</td>\n <td>0.5</td>\n <td>0.333333</td>\n <td>0.666667</td>\n <td>0.5</td>\n <td>1.750000</td>\n <td>1.750000</td>\n <td>4.375000</td>\n <td>0.5</td>\n <td>0.5</td>\n <td>0.666667</td>\n </tr>\n <tr>\n <th>5</th>\n <td>5.000000</td>\n <td>1</td>\n <td>0.2</td>\n <td>0.000000</td>\n <td>0.0</td>\n <td>0.333333</td>\n <td>0.666667</td>\n <td>1.0</td>\n <td>0.000000</td>\n <td>0.000000</td>\n <td>0.000000</td>\n <td>0.0</td>\n <td>0.0</td>\n <td>0.666667</td>\n </tr>\n <tr>\n <th>6</th>\n <td>5.000001</td>\n <td>0</td>\n <td>0.0</td>\n <td>NaN</td>\n <td>0.0</td>\n <td>0.000000</td>\n <td>1.000000</td>\n <td>1.0</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>NaN</td>\n <td>0.0</td>\n <td>0.0</td>\n <td>1.000000</td>\n </tr>\n </tbody>\n</table>\n</div>"
73+
"text/plain": " threshold count fraction precision true_positive_rate \\\n0 0.999999 5 1.0 0.400000 1.0 \n1 1.000000 5 1.0 0.400000 1.0 \n2 2.000000 4 0.8 0.500000 1.0 \n3 3.000000 3 0.6 0.666667 1.0 \n4 4.000000 2 0.4 0.500000 0.5 \n5 5.000000 1 0.2 0.000000 0.0 \n6 5.000001 0 0.0 0.000000 0.0 \n\n false_positive_rate true_negative_rate false_negative_rate accuracy \\\n0 1.000000 0.000000 0.0 0.4 \n1 1.000000 0.000000 0.0 0.4 \n2 0.666667 0.333333 0.0 0.6 \n3 0.333333 0.666667 0.0 0.8 \n4 0.333333 0.666667 0.5 0.6 \n5 0.333333 0.666667 1.0 0.4 \n6 0.000000 1.000000 1.0 0.6 \n\n cdf recall sensitivity specificity \n0 0.0 1.0 1.0 0.000000 \n1 0.0 1.0 1.0 0.000000 \n2 0.2 1.0 1.0 0.333333 \n3 0.4 1.0 1.0 0.666667 \n4 0.6 0.5 0.5 0.666667 \n5 0.8 0.0 0.0 0.666667 \n6 1.0 0.0 0.0 1.000000 ",
74+
"text/html": "<div>\n<style scoped>\n .dataframe tbody tr th:only-of-type {\n vertical-align: middle;\n }\n\n .dataframe tbody tr th {\n vertical-align: top;\n }\n\n .dataframe thead th {\n text-align: right;\n }\n</style>\n<table border=\"1\" class=\"dataframe\">\n <thead>\n <tr style=\"text-align: right;\">\n <th></th>\n <th>threshold</th>\n <th>count</th>\n <th>fraction</th>\n <th>precision</th>\n <th>true_positive_rate</th>\n <th>false_positive_rate</th>\n <th>true_negative_rate</th>\n <th>false_negative_rate</th>\n <th>accuracy</th>\n <th>cdf</th>\n <th>recall</th>\n <th>sensitivity</th>\n <th>specificity</th>\n </tr>\n </thead>\n <tbody>\n <tr>\n <th>0</th>\n <td>0.999999</td>\n <td>5</td>\n <td>1.0</td>\n <td>0.400000</td>\n <td>1.0</td>\n <td>1.000000</td>\n <td>0.000000</td>\n <td>0.0</td>\n <td>0.4</td>\n <td>0.0</td>\n <td>1.0</td>\n <td>1.0</td>\n <td>0.000000</td>\n </tr>\n <tr>\n <th>1</th>\n <td>1.000000</td>\n <td>5</td>\n <td>1.0</td>\n <td>0.400000</td>\n <td>1.0</td>\n <td>1.000000</td>\n <td>0.000000</td>\n <td>0.0</td>\n <td>0.4</td>\n <td>0.0</td>\n <td>1.0</td>\n <td>1.0</td>\n <td>0.000000</td>\n </tr>\n <tr>\n <th>2</th>\n <td>2.000000</td>\n <td>4</td>\n <td>0.8</td>\n <td>0.500000</td>\n <td>1.0</td>\n <td>0.666667</td>\n <td>0.333333</td>\n <td>0.0</td>\n <td>0.6</td>\n <td>0.2</td>\n <td>1.0</td>\n <td>1.0</td>\n <td>0.333333</td>\n </tr>\n <tr>\n <th>3</th>\n <td>3.000000</td>\n <td>3</td>\n <td>0.6</td>\n <td>0.666667</td>\n <td>1.0</td>\n <td>0.333333</td>\n <td>0.666667</td>\n <td>0.0</td>\n <td>0.8</td>\n <td>0.4</td>\n <td>1.0</td>\n <td>1.0</td>\n <td>0.666667</td>\n </tr>\n <tr>\n <th>4</th>\n <td>4.000000</td>\n <td>2</td>\n <td>0.4</td>\n <td>0.500000</td>\n <td>0.5</td>\n <td>0.333333</td>\n <td>0.666667</td>\n <td>0.5</td>\n <td>0.6</td>\n <td>0.6</td>\n <td>0.5</td>\n <td>0.5</td>\n <td>0.666667</td>\n </tr>\n <tr>\n <th>5</th>\n <td>5.000000</td>\n <td>1</td>\n <td>0.2</td>\n <td>0.000000</td>\n <td>0.0</td>\n <td>0.333333</td>\n <td>0.666667</td>\n <td>1.0</td>\n <td>0.4</td>\n <td>0.8</td>\n <td>0.0</td>\n <td>0.0</td>\n <td>0.666667</td>\n </tr>\n <tr>\n <th>6</th>\n <td>5.000001</td>\n <td>0</td>\n <td>0.0</td>\n <td>0.000000</td>\n <td>0.0</td>\n <td>0.000000</td>\n <td>1.000000</td>\n <td>1.0</td>\n <td>0.6</td>\n <td>1.0</td>\n <td>0.0</td>\n <td>0.0</td>\n <td>1.000000</td>\n </tr>\n </tbody>\n</table>\n</div>"
7575
},
7676
"execution_count": 3,
7777
"metadata": {},
@@ -96,21 +96,34 @@
9696
},
9797
{
9898
"cell_type": "code",
99-
"execution_count": 5,
99+
"execution_count": 4,
100100
"outputs": [
101101
{
102-
"data": {
103-
"text/plain": "\"pandas.DataFrame({\\n 'threshold': [0.999999, 1.0, 2.0, 3.0, 4.0, 5.0, 5.000001],\\n 'count': [5, 5, 4, 3, 2, 1, 0],\\n 'fraction': [1.0, 1.0, 0.8, 0.6, 0.4, 0.2, 0.0],\\n 'precision': [0.4, 0.4, 0.5, 0.6666666666666666, 0.5, 0.0, None],\\n 'true_positive_rate': [1.0, 1.0, 1.0, 1.0, 0.5, 0.0, 0.0],\\n 'false_positive_rate': [1.0, 1.0, 0.6666666666666666, 0.3333333333333333, 0.3333333333333333, 0.3333333333333333, 0.0],\\n 'true_negative_rate': [0.0, 0.0, 0.3333333333333333, 0.6666666666666666, 0.6666666666666666, 0.6666666666666666, 1.0],\\n 'false_negative_rate': [0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 1.0],\\n 'enrichment': [1.4000000000000001, 1.4000000000000001, 1.75, 2.3333333333333335, 1.75, 0.0, None],\\n 'gain': [1.4000000000000001, 1.4000000000000001, 1.75, 2.3333333333333335, 1.75, 0.0, None],\\n 'lift': [1.4000000000000001, 1.4000000000000001, 2.1875, 3.8888888888888893, 4.375, 0.0, None],\\n 'recall': [1.0, 1.0, 1.0, 1.0, 0.5, 0.0, 0.0],\\n 'sensitivity': [1.0, 1.0, 1.0, 1.0, 0.5, 0.0, 0.0],\\n 'specificity': [0.0, 0.0, 0.33333333333333337, 0.6666666666666667, 0.6666666666666667, 0.6666666666666667, 1.0],\\n })\""
104-
},
105-
"execution_count": 5,
106-
"metadata": {},
107-
"output_type": "execute_result"
102+
"name": "stdout",
103+
"output_type": "stream",
104+
"text": [
105+
"pd.DataFrame({\n",
106+
" 'threshold': [0.999999, 1.0, 2.0, 3.0, 4.0, 5.0, 5.000001],\n",
107+
" 'count': [5, 5, 4, 3, 2, 1, 0],\n",
108+
" 'fraction': [1.0, 1.0, 0.8, 0.6, 0.4, 0.2, 0.0],\n",
109+
" 'precision': [0.4, 0.4, 0.5, 0.6666666666666666, 0.5, 0.0, 0.0],\n",
110+
" 'true_positive_rate': [1.0, 1.0, 1.0, 1.0, 0.5, 0.0, 0.0],\n",
111+
" 'false_positive_rate': [1.0, 1.0, 0.6666666666666666, 0.3333333333333333, 0.3333333333333333, 0.3333333333333333, 0.0],\n",
112+
" 'true_negative_rate': [0.0, 0.0, 0.3333333333333333, 0.6666666666666666, 0.6666666666666666, 0.6666666666666666, 1.0],\n",
113+
" 'false_negative_rate': [0.0, 0.0, 0.0, 0.0, 0.5, 1.0, 1.0],\n",
114+
" 'accuracy': [0.4, 0.4, 0.6, 0.8, 0.6, 0.4, 0.6],\n",
115+
" 'cdf': [0.0, 0.0, 0.19999999999999996, 0.4, 0.6, 0.8, 1.0],\n",
116+
" 'recall': [1.0, 1.0, 1.0, 1.0, 0.5, 0.0, 0.0],\n",
117+
" 'sensitivity': [1.0, 1.0, 1.0, 1.0, 0.5, 0.0, 0.0],\n",
118+
" 'specificity': [0.0, 0.0, 0.33333333333333337, 0.6666666666666667, 0.6666666666666667, 0.6666666666666667, 1.0],\n",
119+
" })\n"
120+
]
108121
}
109122
],
110123
"source": [
111124
"import data_algebra.util\n",
112125
"\n",
113-
"data_algebra.util.pandas_to_example_str(stats)"
126+
"print(data_algebra.util.pandas_to_example_str(stats))"
114127
],
115128
"metadata": {
116129
"collapsed": false,

pkg/build/lib/wvpy/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ def plot_roc(
206206
wvpy.util.plot_roc(
207207
prediction=d['x'],
208208
istrue=d['y'],
209+
ideal_line_color='lightgrey',
209210
extra_points=pandas.DataFrame({
210211
'tpr': [0, 1],
211212
'fpr': [0, 1],
@@ -235,7 +236,7 @@ def plot_roc(
235236
matplotlib.pyplot.fill_between(fpr, tpr, color="orange", alpha=0.3)
236237
matplotlib.pyplot.plot([0, 1], [0, 1], color="navy", lw=lw, linestyle="--")
237238
if extra_points is not None:
238-
matplotlib.pyplot.plot(extra_points.fpr, extra_points.tpr, "bo", color="red")
239+
matplotlib.pyplot.scatter(extra_points.fpr, extra_points.tpr, color="red")
239240
if "label" in extra_points.columns:
240241
tpr = extra_points.tpr.to_list()
241242
fpr = extra_points.fpr.to_list()
1 Byte
Binary file not shown.

pkg/dist/wvpy-0.2.8.tar.gz

-136 KB
Binary file not shown.

pkg/docs/search.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)