In [1]:
import pandas as pd
import numpy as np

In [62]:
pwd


Out[62]:
u'/Users/ganthony/Documents/notebooks/neon/luna16'

In [63]:
df = pd.read_csv('/Users/ganthony/Desktop/predictions9.csv')
df_perfect = pd.read_csv('/Users/ganthony/Documents/evaluationScript/exampleFiles/submission/perfect_submission.csv')

In [69]:
df_perfect['seriesuid'].loc[13]


Out[69]:
'1.3.6.1.4.1.14519.5.2.1.6279.6001.100225287222365663678666836860'

In [70]:
df_perfect.loc[13]


Out[70]:
seriesuid      1.3.6.1.4.1.14519.5.2.1.6279.6001.100225287222...
coordX                                                   104.165
coordY                                                  -211.686
coordZ                                                  -227.011
probability                                                    1
Name: 13, dtype: object

In [80]:
df_perfect2 = df_perfect[(df_perfect['seriesuid'] == df['filename'].loc[0])]

In [83]:
sum(df['filename']==df['filename'].loc[0])


Out[83]:
620

In [81]:
df_perfect2


Out[81]:
seriesuid coordX coordY coordZ probability
6453 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -32.557644 -22.198961 -215.086481 0
6454 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 92.870000 16.110000 -115.810000 0
6455 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 123.491069 2.980240 -202.344555 0
6456 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 109.618624 11.210602 -127.961579 0
6457 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 59.014300 15.181310 -120.080000 0
6458 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -38.144943 44.809336 -276.644144 0
6459 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -53.284858 56.858563 -275.995790 0
6460 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 84.818961 89.958424 -174.631405 0
6461 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -66.562991 -22.192829 -177.408871 0
6462 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 100.774655 -35.013297 -205.862048 0
6463 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -28.487734 -42.213851 -204.433520 0
6464 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 63.307771 -3.913908 -176.632596 0
6465 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 92.442792 9.261215 -193.238013 0
6466 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 131.024804 -68.340102 -281.485567 0
6467 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 69.592766 77.164999 -177.933202 0
6468 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 66.791114 40.123599 -187.369461 0
6469 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 114.673472 37.329904 -225.713208 0
6470 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 91.318395 -13.583161 -163.389057 0
6471 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 87.358201 -60.743964 -192.043773 0
6472 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -44.178623 51.949368 -207.204274 0
6473 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 110.933594 99.446233 -271.401250 0
6474 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -66.324328 -16.590934 -162.147446 0
6475 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 73.045470 51.385564 -141.354717 0
6476 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -26.377982 2.239656 -170.508120 0
6477 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 79.378169 -1.015675 -203.566480 0
6478 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 80.062767 8.502244 -254.565990 0
6479 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 90.744387 27.071561 -95.875218 0
6480 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -46.086500 -29.814700 -232.276000 0
6481 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -77.548028 76.477255 -283.398305 0
6482 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -55.801403 49.090214 -231.027300 0
... ... ... ... ... ...
6785 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -6.014112 55.058761 -175.747872 0
6786 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 57.162758 39.078119 -314.366265 0
6787 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 106.635337 45.651078 -197.855556 0
6788 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -92.751398 22.623912 -182.015663 0
6789 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -9.440754 10.685435 -86.286962 0
6790 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 76.024588 85.649073 -194.346392 0
6791 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 102.271172 -6.130424 -134.563298 0
6792 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 81.848811 35.204611 -226.174755 0
6793 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 58.975839 13.996170 -195.903392 0
6794 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 84.322029 45.677255 -104.455368 0
6795 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -93.362000 -4.844120 -185.180000 0
6796 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 58.621968 -1.640901 -106.367456 0
6797 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 83.469201 41.444611 -144.193853 0
6798 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -21.144297 18.893719 -209.373544 0
6799 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -39.644124 99.785421 -259.259091 0
6800 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 129.534181 45.608767 -158.374577 0
6801 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -31.601893 -14.779938 -94.371540 0
6802 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 107.733082 18.411353 -296.253261 0
6803 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 72.378037 53.502247 -211.853684 0
6804 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -34.198125 20.248542 -161.368021 0
6805 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 45.125724 16.920182 -90.430496 0
6806 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 59.940000 79.170000 -288.930000 0
6807 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 64.840000 11.910000 -103.140000 0
6808 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 95.670000 -73.560000 -260.780000 0
6809 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 87.960000 2.800000 -293.860000 0
6810 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -12.220000 19.620000 -258.670000 0
6811 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... -33.240000 -7.700000 -213.630000 0
6812 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 79.550000 77.770000 -301.600000 0
6813 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 106.880000 3.500000 -193.920000 0
6814 1.3.6.1.4.1.14519.5.2.1.6279.6001.102681962408... 97.070000 -63.050000 -213.630000 0

362 rows × 5 columns


In [ ]:


In [16]:
sum(df['pred'] == df['target']) / float(df.shape[0])


Out[16]:
0.98506375710067395

In [35]:
from sklearn.metrics import confusion_matrix, classification_report

In [51]:
[[tn, fp], [fn, tp]] = confusion_matrix(df['target'], df['pred'], labels=[0, 1])
print classification_report(df['target'], df['pred'], target_names=['Class 0', 'Class 1'])


             precision    recall  f1-score   support

    Class 0       1.00      0.99      0.99     75379
    Class 1       0.10      0.85      0.18       142

avg / total       1.00      0.99      0.99     75521


In [44]:
true_negative = sum((df['target']==0) & (df['pred'] == 0))
print true_negative


74273

In [45]:
false_negative = sum((df['target']==1) & (df['pred'] == 0))
print false_negative


22

In [46]:
true_positive = sum((df['target']==1) & (df['pred'] == 1))
print true_positive


120

In [47]:
false_positive = sum((df['target']==0) & (df['pred'] == 1))
print false_positive


1106

In [58]:
df2 = df[df['filename']==df['filename'][0]]

In [60]:
df2[df2['x']==105.0557924]


Out[60]:
filename x y z prob pred target

In [ ]: