In [9]:
import pandas as pd
import matplotlib.pyplot as plt

from matplotlib import axes
from matplotlib import rc

%matplotlib inline
font = {'family' : 'monospace',
        'weight' : 'bold',
        'size'   : 20}

rc('font', **font)
import

In [2]:
ionosphere = pd.read_csv("results/ionosphere_results.csv", index_col="Unnamed: 0")
ionosphere['dataset'] = 'ionosphere'
ionosphere['dim_reduction'] = 33 - ionosphere['encoding_dim']
ionosphere['accuracy_reduction'] = ionosphere['neural_net_acc'] - ionosphere['auto_classifier_acc']
ionosphere.head()


Out[2]:
auto_classifier_acc encoding_dim neural_net_acc dataset dim_reduction accuracy_reduction
0 0.942857 33 0.857143 ionosphere 0 -0.085714
1 0.914286 32 0.857143 ionosphere 1 -0.057143
2 0.857143 31 0.857143 ionosphere 2 0.000000
3 0.857143 30 0.857143 ionosphere 3 0.000000
4 0.942857 29 0.857143 ionosphere 4 -0.085714

In [3]:
robo = pd.read_csv("results/robo_results.csv", index_col="Unnamed: 0")
robo['dataset'] = 'robo'
robo['dim_reduction'] = 24 - robo['encoding_dim']
robo['accuracy_reduction'] = robo['neural_net_acc'] - robo['auto_classifier_acc']
robo.head()


Out[3]:
auto_classifier_acc encoding_dim neural_net_acc dataset dim_reduction accuracy_reduction
0 0.939560 24 0.945055 robo 0 0.005495
1 0.939560 23 0.945055 robo 1 0.005495
2 0.935897 22 0.945055 robo 2 0.009158
3 0.959707 21 0.945055 robo 3 -0.014652
4 0.928571 20 0.945055 robo 4 0.016484

In [4]:
semeion = pd.read_csv("results/semeion_results.csv", index_col="Unnamed: 0")
semeion['dataset'] = 'semeion'
semeion['dim_reduction'] = 40 - semeion['encoding_dim']
semeion['accuracy_reduction'] = semeion['neural_net_acc'] - semeion['auto_classifier_acc']
semeion.head()


Out[4]:
auto_classifier_acc encoding_dim neural_net_acc dataset dim_reduction accuracy_reduction
0 0.918239 40 0.91195 semeion 0 -6.289308e-03
1 0.899371 39 0.91195 semeion 1 1.257861e-02
2 0.937107 38 0.91195 semeion 2 -2.515724e-02
3 0.911950 37 0.91195 semeion 3 0.000000e+00
4 0.911950 36 0.91195 semeion 4 -5.623080e-09

In [5]:
results = pd.concat([ionosphere, robo, semeion], axis=0, ignore_index=True)
results.to_csv("results/combined_results")

In [11]:
results.iloc[results.groupby('dataset').accuracy_reduction.idxmin()]


Out[11]:
auto_classifier_acc encoding_dim neural_net_acc dataset dim_reduction accuracy_reduction
0 0.942857 33 0.857143 ionosphere 0 -0.085714
36 0.959707 21 0.945055 robo 3 -0.014652
59 0.937107 38 0.911950 semeion 2 -0.025157

In [12]:
results[results['accuracy_reduction'] < 0]


Out[12]:
auto_classifier_acc encoding_dim neural_net_acc dataset dim_reduction accuracy_reduction
0 0.942857 33 0.857143 ionosphere 0 -8.571429e-02
1 0.914286 32 0.857143 ionosphere 1 -5.714286e-02
4 0.942857 29 0.857143 ionosphere 4 -8.571429e-02
5 0.942857 28 0.857143 ionosphere 5 -8.571429e-02
6 0.914286 27 0.857143 ionosphere 6 -5.714286e-02
8 0.942857 25 0.857143 ionosphere 8 -8.571429e-02
9 0.914286 24 0.857143 ionosphere 9 -5.714286e-02
10 0.914286 23 0.857143 ionosphere 10 -5.714286e-02
11 0.942857 22 0.857143 ionosphere 11 -8.571429e-02
12 0.942857 21 0.857143 ionosphere 12 -8.571429e-02
14 0.914286 19 0.857143 ionosphere 14 -5.714286e-02
15 0.942857 18 0.857143 ionosphere 15 -8.571429e-02
17 0.885714 16 0.857143 ionosphere 17 -2.857143e-02
18 0.885714 15 0.857143 ionosphere 18 -2.857143e-02
19 0.885714 14 0.857143 ionosphere 19 -2.857143e-02
20 0.885714 13 0.857143 ionosphere 20 -2.857143e-02
21 0.914286 12 0.857143 ionosphere 21 -5.714286e-02
22 0.885714 11 0.857143 ionosphere 22 -2.857143e-02
23 0.942857 10 0.857143 ionosphere 23 -8.571429e-02
24 0.942857 9 0.857143 ionosphere 24 -8.571429e-02
25 0.885714 8 0.857143 ionosphere 25 -2.857143e-02
27 0.914286 6 0.857143 ionosphere 27 -5.714286e-02
28 0.885714 5 0.857143 ionosphere 28 -2.857143e-02
29 0.914286 4 0.857143 ionosphere 29 -5.714286e-02
36 0.959707 21 0.945055 robo 3 -1.465201e-02
57 0.918239 40 0.911950 semeion 0 -6.289308e-03
59 0.937107 38 0.911950 semeion 2 -2.515724e-02
61 0.911950 36 0.911950 semeion 4 -5.623080e-09
62 0.924528 35 0.911950 semeion 5 -1.257862e-02
63 0.937107 34 0.911950 semeion 6 -2.515723e-02
64 0.930818 33 0.911950 semeion 7 -1.886792e-02
65 0.918239 32 0.911950 semeion 8 -6.289308e-03
69 0.930818 28 0.911950 semeion 12 -1.886793e-02
70 0.930818 27 0.911950 semeion 13 -1.886792e-02
71 0.924528 26 0.911950 semeion 14 -1.257862e-02
73 0.924528 24 0.911950 semeion 16 -1.257862e-02
74 0.930818 23 0.911950 semeion 17 -1.886793e-02
76 0.911950 21 0.911950 semeion 19 -5.623080e-09
77 0.918239 20 0.911950 semeion 20 -6.289308e-03
79 0.918239 18 0.911950 semeion 22 -6.289308e-03
83 0.918239 14 0.911950 semeion 26 -6.289309e-03
84 0.918239 13 0.911950 semeion 27 -6.289313e-03
85 0.930818 12 0.911950 semeion 28 -1.886792e-02

In [ ]:
fig = plt.figure(figsize=(20,10))
plt.plot(model.history.history['val_acc'])
plt.plot(model.history.history['acc'])
plt.axhline(y=nn_score, c="red")
plt.text(0, nn_score, "test: " + str(round(nn_score, 4)), fontdict=font)
plt.title('model accuracy for neural net with 2 hidden layers')
plt.ylabel('accuracy')
plt.xlabel('epochs')
plt.legend(['valid', 'train'], loc='lower right')
plt.show()

In [14]:
fig = plt.figure(figsize=(20,10))

plt.bar(results['accuracy_reduction'])


---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-14-63cf67195831> in <module>()
      1 fig = plt.figure(figsize=(20,10))
      2 
----> 3 plt.bar(results['accuracy_reduction'])

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\pyplot.py in bar(*args, **kwargs)
   2625                       mplDeprecation)
   2626     try:
-> 2627         ret = ax.bar(*args, **kwargs)
   2628     finally:
   2629         ax._hold = washold

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\__init__.py in inner(ax, *args, **kwargs)
   1708                     warnings.warn(msg % (label_namer, func.__name__),
   1709                                   RuntimeWarning, stacklevel=2)
-> 1710             return func(ax, *args, **kwargs)
   1711         pre_doc = inner.__doc__
   1712         if pre_doc is None:

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_axes.py in bar(self, *args, **kwargs)
   2025                 break
   2026         else:
-> 2027             raise exps[0]
   2028         # if we matched the second-case, then the user passed in
   2029         # left=val as a kwarg which we want to deprecate

C:\ProgramData\Anaconda3\lib\site-packages\matplotlib\axes\_axes.py in bar(self, *args, **kwargs)
   2017         for matcher in matchers:
   2018             try:
-> 2019                 dp, x, height, width, y, kwargs = matcher(*args, **kwargs)
   2020             except TypeError as e:
   2021                 # This can only come from a no-match as there is

TypeError: <lambda>() missing 1 required positional argument: 'height'