Skip to content

Commit

Permalink
added histograms
Browse files Browse the repository at this point in the history
  • Loading branch information
dainis-boumber committed Jun 20, 2018
1 parent aea3e28 commit 8c9ab11
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 deletions.
12 changes: 6 additions & 6 deletions complexity.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import modules.complexity_estimator as ce
import modules.util as u
from modules import mnist
from modules.oracle import Oracle
from nd_boundary_plot.plots import nd_boundary_plot

Expand Down Expand Up @@ -107,6 +106,7 @@ def active(classifiers, datasets, experiments, quota=25, plot_every_n=5):
plt.tight_layout()
plt.show()


def main():
# clfs = [SVC(), LinearSVC(), AdaBoostClassifier(), GaussianNB()]
datasets = []
Expand All @@ -121,11 +121,11 @@ def main():
# experiments.append('moons')
# datasets.append((u.hastie(1000), u.hastie(1000)))

# datasets.append((make_gaussian_quantiles(n_samples=500, n_features=10, n_classes=3),
# make_gaussian_quantiles(n_samples=500, n_features=10, n_classes=3)))
# experiments.append('gauus')
datasets.append((mnist.load_mnist(), mnist.load_mnist_rotated()))
experiments.append('MNIST_vs_MNIST_Rotated')
datasets.append((make_gaussian_quantiles(n_samples=500, n_features=10, n_classes=3),
make_gaussian_quantiles(n_samples=500, n_features=10, n_classes=3)))
experiments.append('gauus')
# datasets.append((mnist.load_mnist(), mnist.load_mnist_rotated()))
# experiments.append('MNIST_vs_MNIST_Rotated')

active(classifiers=clfs, datasets=datasets, experiments=experiments)

Expand Down
32 changes: 31 additions & 1 deletion demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ def demo(datasets, dsnames, classifiers, nwindows):
f1 = figure.number
figure2 = plt.figure(figsize=(27, 9))
f2 = figure2.number
figure3 = plt.figure(figsize=(27, 9))
f3 = figure3.number

i = 1
j = 1
Expand Down Expand Up @@ -110,6 +112,32 @@ def demo(datasets, dsnames, classifiers, nwindows):
ax.set_title('Avg. Complexity')
ax.plot(Ks, Es)
j+=1


# plot data and
figure3, a = plt.subplots(nrows=len(datasets), ncols=2,figsize=(27,9))
a = a.ravel()

for idx,ax in enumerate(a):
if idx % 2 == 0:
ax.set_title(dsnames[ds_cnt])
# Plot also the training points
ax.scatter(X[:, 0], X[:, 1], c=y)
# and seeds
ax.scatter(X[estimator.seeds, 0], X[estimator.seeds, 1],
alpha=1.0, facecolors='black')
ax.set_xlim(xx.min(), xx.max())
ax.set_ylim(yy.min(), yy.max())
ax.set_xticks(())
ax.set_yticks(())
else:
ax.hist(Es, 10)
ax.set_xlabel('E')
ax.set_ylabel('frequency')
ax.set_title('Hist. of Entropy')
figure3.tight_layout()
figure3.savefig(filename=('./vis/' + dsnames[ds_cnt] + 'Histograms.png'))

'''
ws = estimator.get_w_complexity()
for wi, w in enumerate(ws):
Expand All @@ -121,16 +149,18 @@ def demo(datasets, dsnames, classifiers, nwindows):

figure.tight_layout()
figure2.tight_layout()


figure.savefig(filename=('./vis/'+ ''.join(dsnames)+'Classifications.png'))
figure2.savefig(filename=('./vis/'+''.join(dsnames) + 'Complexities.png'))

plt.show()

def main():
classifiers = [
LinearDiscriminantAnalysis(),
QuadraticDiscriminantAnalysis(),
KNeighborsClassifier(3),
MLPClassifier(alpha=1),
SVC(gamma=2, C=1),
LinearSVC(),
GaussianProcessClassifier(1.0 * RBF(1.0), warm_start=True),
Expand Down
2 changes: 1 addition & 1 deletion nd_boundary_plot
Submodule nd_boundary_plot updated 1 files
+1 −1 LICENSE

0 comments on commit 8c9ab11

Please sign in to comment.