In [80]:
    
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import pickle
import functools as ft
    
In [87]:
    
X = x_train[1]
X
    
    Out[87]:
In [88]:
    
not ft.reduce(lambda old, new: old == new,X >= 0)
    
    Out[88]:
In [90]:
    
def xor(X):
    if not ft.reduce(lambda old, new: old == new,X >= 0):
        return 1
    else:
        return 0 
    
x_train = np.array([(np.random.random_sample(5000) - 0.5) * 2 for dim in range(2)]).transpose()
x_test  = np.array([(np.random.random_sample(100)  - 0.5) * 2 for dim in range(2)]).transpose()
y_train = np.apply_along_axis(xor, 1, x_train)
y_test  = np.apply_along_axis(xor, 1, x_test)
with open('data/xor.tuple', 'wb') as xtuple:
    pickle.dump((x_train, y_train, x_test, y_test), xtuple)
    
https://archive.ics.uci.edu/ml/datasets/Housing
In [16]:
    
!wget -P data/ https://archive.ics.uci.edu/ml/machine-learning-databases/housing/housing.data
    
    
In [31]:
    
housing = pd.read_csv('data/housing.data', delim_whitespace=True, 
                   names=['CRIM', 
                          'ZM', 
                          'INDUS', 
                          'CHAS', 
                          'NOX', 
                          'RM', 
                          'AGE', 
                          'DIS', 
                          'RAD',
                          'TAX',
                          'PTRATIO',
                          'B',
                          'LSTAT',
                          'MEDV'])
housing.head()
with open('data/housing.dframe', 'wb') as dhousing:
    pickle.dump(housing, dhousing)
    
https://archive.ics.uci.edu/ml/datasets/Pima+Indians+Diabetes
In [2]:
    
!wget -P data/ https://archive.ics.uci.edu/ml/machine-learning-databases/pima-indians-diabetes/pima-indians-diabetes.data
    
    
In [72]:
    
data = pd.read_csv('data/pima-indians-diabetes.data',
                   names=['n_pregnant', 
                          'glucose', 
                          'mmHg', 
                          'triceps', 
                          'insulin', 
                          'BMI', 
                          'pedigree', 
                          'age', 
                          'class'])
data.head()
x = np.array(data)[:,:-1]
y = np.array(data)[:,-1]
n_train = int(len(x) * 0.70)
x_train = x[:n_train]
x_test  = x[n_train:]
y_train = y[:n_train]
y_test  = y[n_train:]
with open('data/pima-indians-diabetes.tuple', 'wb') as xtuple:
    pickle.dump((x_train, y_train, x_test, y_test), xtuple)
    
In [9]:
    
!wget -P data/ http://deeplearning.net/data/mnist/mnist.pkl.gz
    
    
In [11]:
    
import cPickle, gzip, numpy
# Load the dataset
f = gzip.open('data/mnist.pkl.gz', 'rb')
train_set, valid_set, test_set = cPickle.load(f)
f.close()
    
In [26]:
    
plt.imshow(train_set[0][0].reshape((28,28)),cmap='gray', interpolation=None)
    
    Out[26]:
    
In [71]:
    
!wget -P data/ http://data.dmlc.ml/mxnet/data/mnist.zip
!unzip -d data/ -u data/mnist.zip
    
    
In [1]:
    
!wget -P data/ https://www.cs.toronto.edu/~kriz/cifar-10-python.tar.gz
!tar -xzf data/cifar-10-python.tar.gz -C data/
    
    
In [27]:
    
with open('data/cifar-10-batches-py/data_batch_1', 'rb') as batch:
    cifar1 = cPickle.load(batch)
    
In [57]:
    
cifar1.keys()
    
    Out[57]:
In [54]:
    
img = np.stack([cifar1['data'][0].reshape((3,32,32))[0,:,:],
                cifar1['data'][0].reshape((3,32,32))[1,:,:],
                cifar1['data'][0].reshape((3,32,32))[2,:,:]],axis=2)
plt.imshow(img, cmap='gray')
    
    Out[54]: