Skip to content

Commit

Permalink
fixing merge
Browse files Browse the repository at this point in the history
  • Loading branch information
dainis-boumber committed Feb 4, 2018
2 parents 2ca1480 + 04d383a commit d5d4741
Show file tree
Hide file tree
Showing 7 changed files with 84,195 additions and 4 deletions.
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2018 Dainis Boumber

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
# complexity
# complexity
Authors: Ricardo Vilalta, Dainis Boumber, Michael Meskhi.

Current work on estimating complexity of a distribution.

10 changes: 7 additions & 3 deletions complexity.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

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 @@ -119,9 +120,12 @@ def main():

# experiments.append('moons')
# datasets.append((u.hastie(1000), u.hastie(1000)))
datasets.append((make_gaussian_quantiles(cov=0.5, n_samples=50, n_features=10, n_classes=2),
make_gaussian_quantiles(n_samples=50, n_features=10, n_classes=2)))
experiments.append('gauus')

# 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
42,001 changes: 42,001 additions & 0 deletions data/mnist/train_src.csv

Large diffs are not rendered by default.

101 changes: 101 additions & 0 deletions data/mnist/train_src_100.csv

Large diffs are not rendered by default.

42,001 changes: 42,001 additions & 0 deletions data/mnist/train_trgt.csv

Large diffs are not rendered by default.

59 changes: 59 additions & 0 deletions modules/mnist.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import numpy as np
import pandas as pd
from scipy import ndimage
import matplotlib.pyplot as plt
from sklearn.utils import shuffle


# Import data and preprocess
mnist = pd.read_csv('./data/mnist/train_src_100.csv') # Using 100 samples only for this test run
labels = mnist.as_matrix(columns=['label'])
dataset = mnist.drop('label', axis = 1).as_matrix()
dataset[dataset > 0] = 1 # Convert each pixel either 0 for white and 1 for black for better classification


def load_mnist():

rows = 100
columns = 784
index = 1
X = []
for image in dataset[:rows*columns]:
img = np.reshape(image, [28, 28])
X.append(img)
index += 1
X = np.array(X).reshape(rows, -1)
mnist = pd.DataFrame(X)
mnist = mnist.as_matrix()
y = labels.flatten()

print("Completed with X shape: ", mnist.shape)
print("Flattened y shape: ", y.shape)

mnist, y = shuffle(X, y, random_state = 5)
return mnist, y


def load_mnist_rotated():

rows = 100
columns = 784
indx = 1
X = []
for image in dataset[:rows*columns]:
img = np.reshape(image, [28, 28])
rotated = ndimage.rotate(img, 90) # Rotate the images by 90 degrees
X.append(rotated)
indx += 1
X = np.array(X).reshape(rows, -1)

mnist_rotated = pd.DataFrame(X)
# mnist_rotated.to_csv('./data/mnist_rotated/minst_rotated_21000.csv', index=False, header=False)
mnist_rotated = mnist_rotated.as_matrix()

y = labels.flatten()
print("Completed with X shape: ", mnist_rotated.shape)
print("Flattened y shape: ", y.shape)

mnist_rotated, y = shuffle(X, y, random_state = 15)
return mnist_rotated, y

0 comments on commit d5d4741

Please sign in to comment.