def train_n_invests_for_name(self, corp_names: list, invest_only: bool = False) -> None: """회사이름으로 검색하여 학습시킴 """ corp = Corp() comp_rmses = [] no = 1 date = None for corp_name in corp_names: corp_code = corp.get_corp_code(corp_name) try: result, invest_daily = self.train_n_invest( corp_code, corp_name, no, invest_only) date = result[1] except Exception: exc_type, exc_value, exc_traceback = sys.exc_info() traceback.print_exception(exc_type, exc_value, exc_traceback, file=sys.stdout) no += 1 continue #result = self.let_train_invest(corp_code, corp_name, no) comp_rmses.append(result) no += 1 df_comp_rmses = pd.DataFrame(comp_rmses, columns=self.result_columns) DataUtils.save_csv(df_comp_rmses, self.get_result_file_path(date))
def let_train_invests_for_name(self, corp_names): """회사이름으로 검색하여 학습시킴 """ corp = Corp() comp_rmses = [] no = 1 for corp_name in corp_names: corp_code = corp.get_corp_code(corp_name) result = self.let_train_invest(corp_code, corp_name, no) comp_rmses.append(result) no += 1 df_comp_rmses = pd.DataFrame(comp_rmses, columns=self.result_columns) DataUtils.save_excel(df_comp_rmses, self.get_result_file_path())
verbose_eval=10) print('Plotting metrics recorded during training...') ax = lgb.plot_metric(evals_result, metric='l1') plt.show() print('Plotting feature importances...') ax = lgb.plot_importance(gbm, max_num_features=10) plt.show() print('Plotting 84th tree...') # one tree use categorical feature to split ax = lgb.plot_tree(gbm, tree_index=83, figsize=(20, 8), show_info=['split_gain']) plt.show() print('Plotting 84th tree with graphviz...') graph = lgb.create_tree_digraph(gbm, tree_index=83, name='Tree84') graph.render(view=True) if __name__ == '__main__': corp_name = "카카오" corp = Corp() corp_code = corp.get_corp_code(corp_name) learning = LearningPlainModels('light_gbm') learning.train(corp_code, corp_name, 1) # from sklearn.datasets import load_iris # # iris = load_iris() # X = iris.data[:, [2, 3]] # y = iris.target # print(X, y)