from pylab import * #ALWAYS IMPORT PYLAB BEFORE THE OTHER LIBRARIES import subprocess, sys, time, random, math from numpy import * from knn import * from matplotlib.pyplot import * from load_shrinked import load_dataset ''' Fourier descriptors not working as it should do, so dont use it (at least not until a fixed implementation is submitted) ''' percent_dataset_usage = 1 feature = 'input_space' #'input_space' or 'fds' - Use input_space ks = [1, 3] #k-values (classifiers) - multiple values '''Read shrinked dataset''' train, valid, test, traint, validt, testt = load_dataset() #concatenate train, valid sets train = np.concatenate((train, valid), axis=0) traint = np.concatenate((traint, validt), axis=0) #Sampling a subset of dataset train = train[:percent_dataset_usage * 60000 / 100] traint = traint[:percent_dataset_usage * 60000 / 100] start = time.time() if feature == 'fds': '''train set''' contours_train = [] for i in range(0, shape(train)[0]): pic = 255 * train[i] contours_train.append(
#import matplotlib.pyplot as plt #import mpl_toolkits.mplot3d.axes3d as p3 #import matplotlib.dates as dates PERCENT_DATASET_USED = 23 def print_time_elapsed(start): end = time.time() seconds = end - start minutes = math.floor(seconds / 60) secs = seconds % 60 print 'time elapsed: ' + str(minutes) + 'min ' + str(secs) + 's' + '\n\n' train_set, valid_set, test_set, traint_init, validt_init, testt = load_dataset( ) #Concatanate train, valid sets train_set = np.concatenate((train_set, valid_set), axis=0) traint = np.concatenate((traint_init, validt_init), axis=0) #Reshape X from NX14x14 to NX196 , Y remains Nx1 train = np.zeros(( np.shape(train_set)[0], 196, )) for i in range(0, np.shape(train)[0]): train[i] = train_set[i].reshape(196, ) test = np.zeros(( np.shape(test_set)[0], 196,
#import matplotlib.pyplot as plt #import mpl_toolkits.mplot3d.axes3d as p3 #import matplotlib.dates as dates PERCENT_DATASET_USED = 23 def print_time_elapsed(start): end = time.time() seconds = end-start minutes = math.floor(seconds / 60) secs = seconds % 60 print 'time elapsed: ' +str(minutes) + 'min ' +str(secs) +'s' + '\n\n' train_set, valid_set, test_set, traint_init, validt_init, testt = load_dataset() #Concatanate train, valid sets train_set = np.concatenate((train_set, valid_set), axis=0) traint = np.concatenate((traint_init, validt_init), axis=0) #Reshape X from NX14x14 to NX196 , Y remains Nx1 train = np.zeros((np.shape(train_set)[0], 196,)) for i in range(0, np.shape(train)[0]): train[i] = train_set[i].reshape(196,) test = np.zeros((np.shape(test_set)[0], 196,)) for i in range(0, np.shape(test)[0]): test[i] = test_set[i].reshape(196,) print np.shape(train), np.shape(traint) print np.shape(test), np.shape(testt)
from pylab import * # ALWAYS IMPORT PYLAB BEFORE THE OTHER LIBRARIES import subprocess, sys, time, random, math from numpy import * from knn import * from matplotlib.pyplot import * from load_shrinked import load_dataset """ Fourier descriptors not working as it should do, so dont use it (at least not until a fixed implementation is submitted) """ percent_dataset_usage = 1 feature = "input_space" #'input_space' or 'fds' - Use input_space ks = [1, 3] # k-values (classifiers) - multiple values """Read shrinked dataset""" train, valid, test, traint, validt, testt = load_dataset() # concatenate train, valid sets train = np.concatenate((train, valid), axis=0) traint = np.concatenate((traint, validt), axis=0) # Sampling a subset of dataset train = train[: percent_dataset_usage * 60000 / 100] traint = traint[: percent_dataset_usage * 60000 / 100] start = time.time() if feature == "fds": """train set"""