def read_information(): import datetime """ Read information from csv file :return: Information """ dat: [Data] = [] with open(f'{csv_file}', "r") as file: lines = file.readlines() for l in lines[1:]: dat.append( Data( l.split(';')[0], int(l.split(';')[1]), float(l.split(';')[2]))) primos = 0 tiempo = 0 for d in dat: primos += d.number_of_primes tiempo += d.duration info = { 'rangos': len(dat), 'primos': primos, 'tiempo': str(datetime.timedelta(seconds=tiempo)) } print(info)
def openDialog(self): # Only single instance of Plugin if self.exists == True: return else: self.exists = True self.resources = Resources(self.plugin_dir) self.dlg = PlanHeatDMMDialog(self) self.data = Data(plugin=False) splash = QSplashScreen( QtGui.QPixmap(self.plugin_dir + os.path.sep + 'resources/PlanHeatPrincipal.png'), QtCore.Qt.WindowStaysOnTopHint) splash.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint) splash.setEnabled(False) splash.show() # Run the dialog event loop self.run() splash.finish(self.dlg) self.dlg.show() result = self.dlg.exec_() self.exists = False # See if OK was pressed if result: # Do something useful here pass else: pass
class RangeOfNumbers: data = Data() _increment = 1 * 1000 * 1000 @staticmethod def get_increment(): return RangeOfNumbers._increment def __init__(self, start: int = 0, final: int = None): self.start = start self.final = final if final else start + self.get_increment() self.file = f'{self.start}-{self.final}' def calculate(self): a = time.time() self.create_files() b = time.time() self.data.__dict__.update({'duration': round(b - a, 5)}) export_information(self.data) def create_files(self): if not os.path.exists(path_files): os.mkdir(path_files) range_start, range_end = self.file.split('-') list = prime_list(int(range_start), int(range_end)) write_primes(f"primos-{range_start}-{range_end}.txt", list) self.data.__dict__.update({ 'range': self.file, 'number_of_primes': len(list) }) def __str__(self): return f'start: {self.start}, end: {self.final}, file: {self.file}'
class TestData: data = { 'device': '1', 'seqNumber': 0, 'data': { 'temperature': 10, 'latitude': 38, 'longitude': 20 }, 'time': '2019-10-10 17:00:00' } dataR = Data() def test_received(self): rec = self.dataR.received(json.dumps(self.data)) assert self.data.get('device') == rec.get('device') assert self.data.get('seqNumber') == rec.get('seqNumber') assert self.data.get('data').get('temperature') == rec.get('data').get( 'temperature') def test_get_data(self): rec = self.dataR.received(json.dumps(self.data)) getted = self.dataR.get_data() assert getted.get('device') == rec.get('device') assert getted.get('seqNumber') == rec.get('seqNumber') assert getted.get('data').get('temperature') == rec.get('data').get( 'temperature')
def run(self): """Run method that performs all the real work""" try: # locale.setlocale(locale.LC_ALL, 'en-GB') # Only single instance of Plugin if self.exists == True: return else: self.exists = True self.dlg = PlanHeatDMMDialog(self) self.resources = Resources(self.plugin_dir) self.data = Data(plugin=True) # Name of project self.data.projectName = master_mapping_config.CURRENT_PROJECT_NAME # Redirection dmm_folder = os.path.join(master_mapping_config.CURRENT_MAPPING_DIRECTORY, master_mapping_config.DMM_FOLDER) os.makedirs(dmm_folder, exist_ok=True) self.data.outputSaveFile = os.path.join(dmm_folder, master_mapping_config.DMM_PREFIX) splash = QSplashScreen(QtGui.QPixmap(self.plugin_dir + os.path.sep + 'resources/PlanHeatPrincipal.png'), QtCore.Qt.WindowStaysOnTopHint) splash.setWindowFlags(QtCore.Qt.WindowStaysOnTopHint | QtCore.Qt.FramelessWindowHint) splash.setEnabled(False) splash.show() # Run the dialog event loop initWindowStatus(self) self.resources.loadAppResources() initWindowbehavior(self) # Deserialize the module DMMSerializer.deserialize(self) splash.finish(self.dlg) # show the dialog self.dlg.show() # Run the dialog event loop result = self.dlg.exec_() self.exists = False # See if OK was pressed if result: # Do something useful here - pass else: pass except Exception as e: self.exists = False print(str(e))
def test_update_as_dict(self): data = Data() data.__dict__.update({ "range": "1", "number_of_primes": 1, "duration": 1.0 }) self.assertEqual("1;1;1.0", data.__str__())
def setUp(self): self.alg = System(self.sc, config=StubConfig) self.data = Data(self.sc, config=StubConfig) self.maximum_weight = StubConfig.get('System', 'maximum_weight') # Replace all other recommenders with a # stub that likes every restaurant # This stub must be defined in default.cfg self.alg.recommenders = {'CuisineType': StubCuisineType(self.sc)} self.alg.weights = {'CuisineType': 1}
def createtrndata(path="data/train/", topn=8000, bcvocab=None): data = Data(bcvocab=bcvocab, withdp=WITHDP, fdpvocab="data/resources/word-dict.pickle.gz", fprojmat="data/resources/projmat.pickle.gz") data.builddata(path) data.buildvocab(topn=topn) data.buildmatrix() fdata = "data/sample/trn.data" flabel = "data/sample/trn.label" data.savematrix(fdata, flabel) data.savevocab("data/sample/vocab.pickle.gz")
def parse_dat_file(self): self.dat_dict = {} count = 0 for fname in self.all_file_list: count += 1 print("{}/{} Reading... {}".format(count, len(self.all_file_list), fname)) data = Data() dat = parse_dat(fname) self.dat_dict[fname] = dat data.dat_data = dat self.data_dict[fname] = data
def trainmodel(): fvocab = "data/sample/vocab.pickle.gz" fdata = "data/sample/trn.data" flabel = "data/sample/trn.label" D = load(gzip.open(fvocab)) vocab, labelidxmap = D['vocab'], D['labelidxmap'] print('len(vocab) = {}'.format(len(vocab))) data = Data() trnM, trnL = data.loadmatrix(fdata, flabel) print('trnM.shape = {}'.format(trnM.shape)) idxlabelmap = reversedict(labelidxmap) pm = ParsingModel(vocab=vocab, idxlabelmap=idxlabelmap) pm.train(trnM, trnL) pm.savemodel("models/parsing-model.pickle.gz")
def __init__(self): data = Data() def empty_check(dict): if dict: return False else: return True with open('final_data.txt', 'r+') as f: # set text inside to this var which is now a list of our data a_data = ast.literal_eval(f.read()) a_data = [d for d in a_data if d] self.df = pd.DataFrame(a_data) self.df.dropna() self.df.isna()
def detect_type(self): for data in self.data_list: d = Data(data) if (d.my_type == 'ENC'): continue elif ('KEY' in d.my_type): d = Key(data) # creation de la class Key elif ('CRT' in d.my_type): try: # creation de la class Certificat avec PEM d = Certificate(data, 'PEM') except: continue elif ('DER' in d.my_type): try: # creation de la class Certificat avec DER d = Certificate(data, 'DER') except: continue self.objects_list.append(d) return len(self.objects_list)
def __init__(self) -> None: super().__init__() # 加载UI self.ui = ui_main.Ui_MainWindow() self.ui.setupUi(self) # 加载数据 self.data = Data(self) self.data.setItems() # 绑定槽函数 ## 数据.添加项 self.add_window = InfoEditor() self.ui.item_add.triggered.connect(self.add_window.show) # 显示窗口 self.add_window.ui.ok.clicked.connect(self.data.addItem) # (窗口) 确认 self.add_window.ui.close.clicked.connect( self.add_window.close) # (窗口) 关闭 ## 数据.删除项 self.ui.item_remove.triggered.connect(self.data.rmItem) ## 编辑.信息 self.change_window = InfoEditor() self.ui.item_change.triggered.connect(self.chitem_show) # 显示窗口 self.change_window.ui.ok.clicked.connect(self.data.chItem) # (窗口) 确认 self.change_window.ui.close.clicked.connect( self.change_window.close) # (窗口) 关闭 ## 编辑.内容 self.markdown_editor = MarkdownEditor() self.ui.content.triggered.connect(self.markdown_editor_show) # 显示窗口 self.markdown_editor.ui.open.triggered.connect( self.markdown_editor_open) self.markdown_editor.ui.save.triggered.connect( self.markdown_editor_save) self.markdown_editor.ui.view.triggered.connect( self.markdown_editor_view) ## 查找.排序 self.ui.sort.triggered.connect(self.item_sort) ## 查找.搜索 self.search_window = FindEditor() self.ui.search.triggered.connect(self.search_window.show) self.search_window.ui.submit.clicked.connect(self.item_find)
# -*- coding:UTF-8 -*- """ @author: ZhaoHe """ from src.data import Data from src.config import dataset2_table_name if __name__ == "__main__": data = Data() # 处理数据集的标称属性 data.process_nom_features(data.dataset2_nom_feature_list, dataset2_table_name)
def test_load_pickle(self): data = Data("this") data.load_pickle("data.pickle") self.assertEqual( data.class_names, ["Vanilla Ice Cream", "Pizza", "Salad", "Fish and Chips"])
class Solver: def __init__(self, data): self.data = data self.initial_guess = [1, 1, 1, data.center[0], data.center[1]] # constraint function (x[0] == a, x[1] == b, x[2] == c, x[3] == d, x[4] == alpha, x[5] == beta) # def h(self, x, number): # det = x[0] * x[3] - x[1] * x[2] # if det == 0: # return - 1 # 1 is more than 0 so the constraint does not hold # else: # return -((1 / det ** 2) * ((x[3] * self.data.df.iloc[0, number] - x[1] * (self.data.df.iloc[1, number] # - x[4] * (det ** 2))) ** 2 # + (x[0] * self.data.df.iloc[1, number] - x[2] * self.data.df.iloc[0, number] # - x[5] * (det ** 2)) ** 2) - 1) def h(self, x, number): return 1 - ( (x[0]**2 * self.data.new_df.iloc[0, number] + x[0] * x[2] * self.data.new_df.iloc[1, number] - x[3])**2 + (x[0] * x[2] * self.data.new_df.iloc[0, number] + (x[1]**2 + x[2]**2) * self.data.new_df.iloc[1, number] - x[4])**2) # variables used for finding out whether to discard the point point_cost = 10 square_cost = 1 # cost of one m^2 of area square = 0.0 # ellipse area - target function value x = 0.0 # elements of S y = 0.0 z = 0.0 alpha = 0.0 # shift vector beta = 0.0 vector = np.zeros(5) data = Data() # Data object will be transferred here initial_guess = np.zeros(5) def set_fields(self, x, y, z, alpha, beta): # self.a = a # self.b = b # self.c = c # self.d = d # self.alpha = alpha # self.beta = beta # self.vector = [a, b, c, d, alpha, beta] self.x = x self.y = y self.z = z self.alpha = alpha self.beta = beta self.vector = [x, y, z, alpha, beta] def restrictions( self): # counting all restrictions and assembling together cons = list() # list of dictionaries h_list = list() # list of constraints - functions h_i # number of restrictions == number of points left (columns in new_df) for i in range(len(self.data.new_df.columns)): h_list.append(lambda x: self.h(x, i)) cons.append({ 'type': 'ineq', 'fun': h_list[i] }) # appending each constraint as a dictionary return cons def optimize(self): # computing matrix S and vector (alpha, beta)^T w = self.minimal_result() self.set_fields(w[0], w[1], w[2], w[3], w[4]) current_square = f(w[0:3]) # latest calculated square # print("\n" + "Starting square is " + str(current_square)) self.data.discard_point(False) while True: self.square = current_square w = self.minimal_result() current_square = f(w[0:3]) delta_square = self.square - current_square # area change if delta_square * self.square_cost < self.point_cost: break self.set_fields(w[0], w[1], w[2], w[3], w[4]) self.data.discard_point(False) # counting optimal values for points in new_df def minimal_result(self): result = minimize(f, self.initial_guess, constraints=self.restrictions()) return result.x def display(self): # Let ellipse be (x y)*Q*(x y)^T + L^T*(x y) + c # set edges for of displayed field edge = 40.0 x_min = -edge x_max = edge y_min = -edge y_max = edge axes = plt.gca() axes.set_xlim([x_min, x_max]) axes.set_ylim([y_min, y_max]) x = np.linspace(-20.0, 20.0, 100) y = np.linspace(-20.0, 20.0, 100) xx, yy = np.meshgrid(x, y) # draw the ellipse # ellipse = ((self.a ** 2 + self.c ** 2) * xx) ** 2 + 2 * (self.a * self.b + self.c * self.d) * xx * yy \ # + ((self.b ** 2 + self.d ** 2) * yy) ** 2 - 2 * (self.alpha * self.a + self.beta * self.c) * xx \ # - 2 * (self.alpha * self.b + self.beta * self.d) * yy + self.alpha ** 2 + self.beta ** 2 - 1 ellipse = 0 plt.contour(xx, yy, ellipse, [0]) # just draw points for i in range(len(self.data.df.columns)): plt.plot(self.data.df.iloc[0, i], self.data.df.iloc[1, i], 'bo') plt.show()
def test_load_images(self): data = Data("this") data.load_images() print(data.class_names)
def setUpClass(self): self.bookings = Data(self.sc).get_bookings(os.path.join( os.path.dirname(__file__), 'stubs', 'datastubs', 'stub_bookings.txt')) self.evaluator = Evaluator(self.sc, ExplicitALS(self.sc), StubConfig)
def test_try_download_imagenet(self): data = Data("this") data.try_download_imagenet("laurynas", "**")
logger.setLevel(logging.INFO) logger.info("Initializing settings") config = configparser.ConfigParser() config.read("Settings.ini") logger.info("Settings read") API_TOKEN = (os.environ.get("TOKEN", False) if os.environ.get("TOKEN", False) else config["TG"]["token"]) CONNECTION_STRING = (os.environ.get("DB", False) if os.environ.get( "DB", False) else config["Mongo"]["db"]) bot = TeleBot(API_TOKEN, parse_mode="HTML") data = Data(conn_string=CONNECTION_STRING, bot=bot) logger.info("Connected to db") admin_section = AdminSection(data=data) hr_section = HRSection(data=data) user_section = UserSection(data=data) job_fair_section = JobFairSection(data=data) updater = Updater() @bot.message_handler(commands=["start"]) def start_bot(message): user = updater.update_user_interaction_time(message)
if not os.path.exists(save_dir): os.makedirs(save_dir) print('Trained models will be stored in: ', save_dir) # input files data_dir = join('./data', args.data) file_train = join(data_dir, 'train.tsv') # training data file_val = join(data_dir, 'val.tsv') # validation datan file_psl = join(data_dir, 'softlogic.tsv') # probabilistic soft logic print('file_psl: %s' % file_psl) more_filt = [file_val, join(data_dir, 'test.tsv')] print('Read train.tsv from', data_dir) # load data this_data = Data() this_data.load_data(file_train=file_train, file_val=file_val, file_psl=file_psl) for f in more_filt: this_data.record_more_data(f) this_data.save_meta_table( save_dir) # output: idx_concept.csv, idx_relation.csv m_train = Trainer() m_train.build(this_data, save_dir) # Model will be trained, validated, and saved in './trained_models' ht_embedding, r_embedding = m_train.train(epochs=param.n_epoch, save_every_epoch=param.val_save_freq, lr=param.learning_rate,
class Solver: def __init__(self, data): self.data = data data = Data() x = 0 y = 0 z = 0 alpha = 0 beta = 0 square = 0 vector = np.zeros(5) initial_guess = np.array([0.1, 0.1, 0, data.center[0], data.center[1]]) def set_fields(self, x, y, z, alpha, beta): self.x = x self.y = y self.z = z self.alpha = alpha self.beta = beta self.vector = [x, y, z, alpha, beta] self.square = f(self.vector) # constraints # x[0] == x, x[1] == y, x[2] == z, x[3] == alpha, x[4] == beta def h(self, x, number): return (x[0] ** 2 * self.data.df.iloc[0, number] + x[0] * x[2] * self.data.df.iloc[1, number] - x[3]) ** 2 +\ (x[0] * x[2] * self.data.df.iloc[0, number] + (x[1] ** 2 + x[2] ** 2) * self.data.df.iloc[1, number] - x[4]) ** 2 - 1 def gradh(self, x, number): x_i = self.data.df.iloc[0, number] y_i = self.data.df.iloc[1, number] res = np.zeros(5) res[0] = 2 * (x[0]**2 * x_i + x[0] * x[2] * y_i - x[3]) * ( 2 * x[0] * x_i + x[2] * y_i) + 2 *\ (x[0] * x[2] * x_i + (x[1]**2 + x[2]**2) * y_i - x[4]) * x[2] * x_i res[1] = 2 * (x[0] * x[2] * x_i + (x[1]**2 + x[2]**2) * y_i - x[4]) * 2 * y_i * x[1] res[2] = 2 * (x[0]**2 * x_i + x[0] * x[2] * y_i - x[3]) * x[0] * y_i + 2 *\ (x[0] * x[2] * x_i + (x[1]**2 + x[2]**2) * y_i - x[4]) * (x[0] * x_i + 2 * x[2] * y_i) res[3] = - 2 * (x[0]**2 * x_i + x[0] * x[2] * y_i - x[3]) res[4] = - 2 * (x[0] * x[2] * x_i + (x[1]**2 + x[2]**2) * y_i - x[4]) return res def q(self, x, t): if self.h(x, 0) >= 0 or self.h(x, 10) >= 0 or self.h(x, 20) >= 0: return np.inf else: return f(x) - t*np.log(- self.h(x, 0)) - t*np.log(- self.h(x, 10)) - t*np.log(- self.h(x, 20)) def gradq(self, x, t): return gradf(x) - t * self.gradh(x, 0) / self.h(x, 0) - t * self.gradh(x, 10) / self.h(x, 10) -\ t * self.gradh(x, 20) / self.h(x, 20) def hessq(self, x, t): return np.identity(5) def optimize(self): gamma = 0.4 t = 1 epsilon = 10**(-7) while t*self.data.m > epsilon: q = lambda x: self.q(x, t) gradq = lambda x: self.gradq(x, t) hessq = lambda x: self.hessq(x, t) result = minimize(q, self.initial_guess, jac=gradq, method='CG') self.initial_guess = result.x print("NEW T = ", t, ", x = ", self.initial_guess, ", q = ", q(self.initial_guess)) print("now h equals: ", self.h(self.initial_guess, 0), self.h(self.initial_guess, 10), self.h(self.initial_guess, 20)) #self.initial_guess = self.newton(self.initial_guess, t, epsilon, 100) #self.initial_guess = self.gradient_descent(self.initial_guess, gradq, epsilon) t = gamma * t return self.initial_guess def check_constraints(self, x): print("Checking constraints: ") for i in [0, 10, 20]: print(self.h(x, i) < 0) def gradient_descent(self, x0, gradff, epsilon): x = x0 iteration = 0 while np.linalg.norm(gradff(x)) > epsilon: h = gradff(x) alpha = 0.8 x = x - alpha * h iteration += 1 #print(x, iteration) return x def newton(self, x0, t, epsilon, num_iter, **kwargs): x = x0 iteration = 0 q = lambda x: self.q(x, t) gradq = lambda x: self.gradq(x, t) hessq = lambda x: self.hessq(x, t) opt_arg = {"q": q, "grad_q": gradq} for key in kwargs: opt_arg[key] = kwargs[key] while True: gradient = gradq(x) hess = hessq(x) h = -np.linalg.solve(hess, gradient) alpha = 1 x = x + alpha * h iteration += 1 print(x, iteration) if np.linalg.norm(gradq(x)) < epsilon: break if iteration >= num_iter: break return x
def __init__(self, cartFile, basePriceFile): cartFile = Data(cartFile) self.cart= cartFile.get_data() bpFile = Data(basePriceFile) self.baseprices= bpFile.get_data()
from sklearn.neighbors import KNeighborsClassifier from src.data import Data data = Data("img") data.load_images() #data.load_pickle("images.pickle") #X_train, X_test, y_train, y_test = data.train_test_split() #print(X_test[0].shape, y_test) neigh = KNeighborsClassifier(n_neighbors=1) #neigh.fit(X_train, y_train) #print(neigh.predict(X_test[0]),y_test[0])
blob[ 'gt'] = '/media/dell/OS/data/mall/formatted_trainval_15_4/mall_patches_1_resize_05_rgb/val_den' blob[ 'roi'] = '/media/dell/OS/data/mall/formatted_trainval_15_4/mall_patches_1_resize_05_rgb/val_roi' test_path.append(blob) data_path['test'] = test_path if random_seed is not None: np.random.seed(random_seed) torch.manual_seed(random_seed) torch.cuda.manual_seed_all(random_seed) # load data data = Data(data_path, shuffle=True, random_seed=random_seed, pre_load=is_pre_load_data, is_label=False) data = data.get() save_path = './info' if not os.path.exists(save_path): os.mkdir(save_path) excel_book = excel.Workbook() excel_sheet = excel_book.active excel_sheet.title = 'Image' excel_sheet['A1'] = 'filename' excel_sheet['B1'] = 'gt max density' excel_sheet['C1'] = 'gt mean density'
def main(): tesla_filename = os.path.join(DATA_DIR, 'TSLA.csv') hitachy_filename = os.path.join(DATA_DIR, './HTHIY.csv') # Hitachi, Ltd. ivr_filename = os.path.join(DATA_DIR, './IYR.csv') # iShares U.S. Real Estate ETF lithium_filename = os.path.join( DATA_DIR, './LIT.csv') # Global X Lithium & Battery Tech ETF (LIT) # Read CSV files into Panda Dataframes r_y = Data(tesla_filename) y = r_y.to_panda('tesla') r_x1 = Data(hitachy_filename) x1 = r_x1.to_panda('hitachy') r_x2 = Data(lithium_filename) x2 = r_x2.to_panda('lithium') r_x3 = Data(ivr_filename) x3 = r_x3.to_panda('ivr') from functools import reduce data_frames = [ x1.drop(['hitachy_price'], axis=1), x2.drop(['lithium_price'], axis=1), x3.drop(['ivr_price'], axis=1), y.drop(['tesla_price'], axis=1) ] df_merged = reduce( lambda left, right: pd.merge(left, right, on=['Date'], how='outer'), data_frames).fillna('void') # Get the correlation Matrix dt = DataTool(df_merged) dt.corr_matrix(OUT_DIR) # Stack multiple independent variables, only keep the Returns columns x = np.vstack( (x1['hitachy_returns'], x2['lithium_returns'], x3['ivr_returns'])) x = x.T y = y['tesla_returns'] # Apply linear regression regression = Regression() model = regression.createModel() model.fit(x, y) model.score(x, y) # R-square import statsmodels.api as sm # By default statsmodel does not include intercept for regression (A in : y = A + B*x1 + C*x2 ) X = sm.add_constant(x) # Create Ordinary Least-Squares (OLS) model sm_model = sm.OLS(y, X) fit = sm_model.fit() # Save summary in pickle fit.save(OUT_DIR + "/fit_summary.pickle") with open(OUT_DIR + "/fit_summary.txt", 'w') as f: print(fit.summary(), file=f) print(fit.summary())
def setUpClass(self): self.alg = ExplicitALS(self.sc, config=StubConfig) self.data = Data(self.sc, config=StubConfig)
elif is_trancos: test_model_path = r'E:\PycharmProjects\crowdcount_8\best_models\model_20190318_DPLNet\trancos\pool_16_3.83\saved_models_trancos\trancos_18.h5' # test_model_path = './saved_models_trancos/trancos_9.h5' original_dataset_name = 'trancos' test_data_config = dict() test_data_config['tran1Resize1_test'] = test_flag.copy() elif is_ucf_qnrf: test_model_path = r'E:\PycharmProjects\crowdcount_8\best_models\model_20190318_DPLNet\ucf_qnrf\pool_4_112.33_205.77\saved_models_ucf_qnrf\ucf_qnrf_26_21617.h5' original_dataset_name = 'ucf_qnrf' test_data_config = dict() test_data_config['ucfQnrf1Resize1024_test'] = test_flag.copy() # load data all_data = Data(test_data_config) all_data = all_data.get() net = CrowdCount() network.load_net(test_model_path, net) net.cuda() net.eval() # log_info = [] save_path = './test_output' make_path(save_path) make_path(os.path.join(save_path, 'ground_truth_map')) make_path(os.path.join(save_path, 'estimate_map'))
import xgboost as xgb import numpy as np from sklearn.ensemble import RandomForestRegressor import src.constants as const from src.data import Data from src.evaluation import Evaluator as eval from src.params import Params from src.visualization import Visualisation as visual input_files = [ f for f in listdir(const.data_path) if isfile(join(const.data_path, f)) ] data = Data(input_files, fill_strategy='gate') params = Params() visual.create_feature_map(data.lagged_feature_names) #visual.plot2d(data, 'crude_oil') #visual.plot_all_2d(data) # Global variables xgb_num_rounds = 80 td = np.array(data.train_data.drop(['output'], axis=1)) train_data = data.train_data.drop(['output'], axis=1).as_matrix() train_label = data.train_data[['output']].as_matrix() test_data = data.test_data.drop(['output'], axis=1).as_matrix()
def test_update(self): data = Data() self.assertEqual("0;0;0.0", str(data)) data.update("1", 1, 1.0) self.assertEqual("1;1;1.0", data.__str__())