from sklearn import neighbors from sklearn.decomposition import PCA, IncrementalPCA, KernelPCA import make_dataset if __name__ == '__main__': test_file_names = os.listdir('/media/dick/Storage/test') N_test = len(test_file_names) print(str(N_test) + ' test files.') train_file_names = os.listdir('/media/dick/Storage64GB_2/train') N_train = len(train_file_names) print(str(N_train) + ' train files.') array_train, array_list_train = make_dataset.read_retina_images(which_set='train') array_test, array_list_test = make_dataset.read_retina_images(which_set='test') # train_labels = np.load('/media/dick/Storage64GB_2/train_labels.npy') # print(train_labels.shape) train_imgs, train_labels = make_dataset.read_retina_images(which_set='train') test_imgs, test_labels = make_dataset.read_retina_images(which_set='test') N_train, m_train, n_train, chan_train = train_imgs.shape N_test, m_test, n_test, chan_test = test_imgs.shape # cv2.imshow('image', train_imgs[0]) # cv2.waitKey(0) # cv2.destroyAllWindows() print(train_imgs.reshape((N_train, m_train*n_train))[:5000].shape)
from wabbit_wappa import * import make_dataset def make_features(data): length = 64 features = [] for i in range(length): features.append(str(data[i])) return features if __name__ == '__main__': test_file_names = os.listdir('/media/dick/Storage1TB/test') train_imgs, train_labels = make_dataset.read_retina_images(which_set='train') test_imgs, test_labels = make_dataset.read_retina_images(which_set='test') N_train, m_train, n_train, chan_train = train_imgs.shape N_test, m_test, n_test, chan_test = test_imgs.shape print('# of training examples: ' + str(N_train) + '\n# of testing examples: ' + str(N_test)) # of training examples: 1580670 # of testing examples: 2410920 y_train = train_labels print(len(y_train)) # Create/Open the memory mapped variables X_train = np.memmap('/media/dick/Storage1TB/transformed/train_ipca.mmap', mode='r', shape=(N_train, 64), dtype='float') num_train = int(round(0.8*N_train))