book_top = xlrd.open_workbook('top50Info.xlsx') table_top = book_top.sheet_by_name('data') data_top = [] for i in range(1,51): data_tmp = table_top.row_values(i) data_top.append(data_tmp[4:56]) book = xlrd.open_workbook('candidatesFeatures.xlsx') table = book.sheet_by_name('data') data = [] for i in range(1,2934): data_tmp = table.row_values(i) data_top.append(data_tmp[4:56]) book_last = xlrd.open_workbook('last200Info.xlsx') table_last = book_last.sheet_by_name('data') for i in range(1,51): data_tmp = table_last.row_values(i) data_top.append(data_tmp[4:56]) data_x=data_top data_y=np.concatenate((np.ones(50),-np.ones(2933),np.zeros(50))) data=[data_x,data_y] writeParamsIntoFile(data,'dataset')
valid_set_x_top = np.array(data_top[40:45]) test_set_x_top = np.array(data_top[45:]) book_last = xlrd.open_workbook('last200Info.xlsx') table_last = book_last.sheet_by_name('data') data_last = [] for i in range(1,51): data_tmp = table_last.row_values(i) data_last.append(data_tmp[4:56]) set_y_last=np.zeros(50) ''' for i in range(0,50): set_y_last.append(random.randint(5,9)) ''' train_set_x_last = np.array(data_last[0:40]) valid_set_x_last = np.array(data_last[40:45]) test_set_x_last = np.array(data_last[45:]) train_set_x=np.concatenate((train_set_x_top,train_set_x_last)) train_set_y=np.concatenate((set_y_top[0:40],set_y_last[0:40])) valid_set_x=np.concatenate((valid_set_x_top,valid_set_x_last)) valid_set_y=np.concatenate((set_y_top[40:45],set_y_last[40:45])) test_set_x=np.concatenate((test_set_x_top,test_set_x_last)) test_set_y=np.concatenate((set_y_top[45:],set_y_last[45:])) dataset=[(train_set_x,train_set_y),(valid_set_x,valid_set_y),(test_set_x,test_set_y)] writeParamsIntoFile(dataset,'dataset_train') print train_set_y