def run(x): data_txt = "point_li.txt" LI.li(data_txt) data_txt = "point_ls.txt" LS.ls(data_txt) data_txt = 'point_ni.txt' NI.ni(data_txt)
def LSTM_Test(self): self.canvas.hide() self.fig3.clear() stock_file = self.data.loc[:, [self.Date_combobox.currentText()]] for combo in self.LSTMcomboboxes: if combo == self.Date_combobox: continue stock_file = pd.merge(stock_file, self.data.loc[:, [combo.currentText()]], left_index=True, right_index=True, how='left') # window_size = int(self.Window_size_lineText.text()) dense = int(self.predict_periods.text()) graph, result = LS.Test(stock_file, 0.95, dense, dense, self.model) self.fore = result self.idx = range(len(self.fore)) try: self.result_gridLayout.removeWidget(self.canvas3) except: pass self.canvas3 = FigureCanvas(graph) self.result_gridLayout.addWidget(self.canvas3) self.canvas3.show() self.minus_pushButton.hide() self.plus_pushButton.hide()
def algrun(): global t, list time_start = time.time() map = Map.Map() x, y = Read.Read() map.path[0] = x map.path[1] = y # state == 0: SA, state == 1: LS state = 0 if state == 0: # SA(map, T, Coolrate) alg = SA.SA(map, 100, 0.001) alg.run() elif state == 1: # LS(map, state), state = 0: LS1, state = 1: LS2, state = 2: 2-OPT alg = LS.LS(map, 2) alg.run() list.append(alg.path.distance()) time_end = time.time() t += (time_end - time_start) print('totally cost', time_end - time_start, 's')
def lsBtnCallback(self): global length global matrix global isLS_CLICK global ls_res v0 = int(self.input_1.get()) v1 = int(self.input_2.get()) if hasattr(self, 'comboBox'): self.comboBox.destroy() self.comboBox_label.destroy() if hasattr(self, 'treeview'): self.treeview.destroy() if hasattr(self, 'error'): self.error.destroy() if not isLS_CLICK: isLS_CLICK = True ls_res = ls.dijkstra(length, copy.deepcopy(matrix), v0) distance = ls_res[0] path = ls_res[1] print(distance) print(path) ways = ls.get_ways(v0, v1, path) print(ways) if len(ways) == 2: print('ssss') if type(ways) == 'NoneType': self.createError() return self.createWays(ways) drawNetwork.drawResult(ways) self.createPhoto()
def find_best_model(df, tgt): lr, ls, dt, dnn = [], [], [], [] for i in range(100): seed = random.randrange(100) lr.append(LR.linreg(df, tgt, seed)) ls.append(LS.lasso(df, tgt, seed)) dt.append(DT.dectree(df, tgt, seed)) dnn.append(DNN.nn(df, tgt, seed)) print(pd.DataFrame({'lr': lr}).describe()) print(pd.DataFrame({'ls': ls}).describe()) print(pd.DataFrame({'dt': dt}).describe()) print(pd.DataFrame({'dnn': dnn}).describe())
def LSTM_Train(self): if self.studying_rate.text() == '': QMessageBox.about(self, "Alert", "학습 비율을 입력해주세요") return elif int(self.studying_rate.text()) < 0: QMessageBox.about(self, "Alert", "학습 비율을 양수로 입력해주세요") return elif self.verification_rate.text() == '': QMessageBox.about(self, "Alert", "검증 비율을 입력해주세요") return elif int(self.verification_rate.text()) < 0: QMessageBox.about(self, "Alert", "검증 비율을 양수로 입력해주세요") return elif self.test_rate.text() == '': QMessageBox.about(self, "Alert", "테스트 비율을 입력해주세요") return elif int(self.test_rate.text()) < 0: QMessageBox.about(self, "Alert", "테스트 비율을 양수로 입력해주세요") return elif self.ModelSize_lineText.text() == '': QMessageBox.about(self, "Alert", "Model Size 값을 입력해주세요") return elif self.WindowSize_lineText.text() == '': QMessageBox.about(self, "Alert", "Window Size 값을 입력해주세요") return elif self.PredictSize_lineText.text() == '': QMessageBox.about(self, "Alert", "Dense 값을 입력해주세요") return elif self.Epochs_linetext.text() == '': QMessageBox.about(self, "Alert", "Epochs 값을 입력해주세요") return elif self.BatchSize_lineText.text() == '': QMessageBox.about(self, "Alert", "Batch Size 값을 입력해주세요") return elif self.Patience_lineText.text() == '': QMessageBox.about(self, "Alert", "Early Stop 값을 입력해주세요") return stock_file = self.data.loc[:, [self.Date_combobox.currentText()]] for combo in self.LSTMcomboboxes: if combo == self.Date_combobox: continue stock_file = pd.merge(stock_file, self.data.loc[:, [combo.currentText()]], left_index=True, right_index=True, how='left') epochs = int(self.Epochs_linetext.text()) batch_size = int(self.BatchSize_lineText.text()) train_ratio = int(self.studying_rate.text()) / ( int(self.studying_rate.text()) + int(self.verification_rate.text()) + int(self.test_rate.text())) valid_ratio = int(self.verification_rate.text()) / ( int(self.studying_rate.text()) + int(self.verification_rate.text()) + int(self.test_rate.text())) window_size = int(self.WindowSize_lineText.text()) dense = int(self.PredictSize_lineText.text()) Model_size = int(self.ModelSize_lineText.text()) patience = int(self.Patience_lineText.text()) LSTM_lossgraph, LSTM_validgraph_origin, LSTM_validgraph_plus, train_part, rmse, self.LSTM_model = LS.Train( stock_file, train_ratio, valid_ratio, window_size, dense, Model_size, patience, epochs, batch_size) # Loss self.canvas = FigureCanvas(LSTM_lossgraph) # 학습 origin self.canvas2 = FigureCanvas(LSTM_validgraph_origin) # 학습 확대 self.canvas3 = FigureCanvas(LSTM_validgraph_plus) self.canvas3.hide() self.LSTM_Loss_gridLayout.addWidget(self.canvas) self.LSTM_Valid_gridLayout.addWidget(self.canvas3) self.LSTM_Valid_gridLayout.addWidget(self.canvas2) self.Rmse_label.setText(f'RMSE : {rmse}') self.Train_label.setText(f'학습량 : {train_part}') self.model_status = 'LSTM'
# we define first the continuous time mass-damper system and # then discretize it using transitions from Hartmut's course from LS import * from scipy import linalg from scipy import integrate # [0 1] # A = [-1 d] corresponds to periodic motion altered by damping d # first we shall observe the velocity of the object and use # output feedback control md_velocity_feedback = LS([[0, 1],[-1, 1]], [[0],[1]], [0, 1], [0]) D1 = md_velocity_feedback.discretize(0.01) # now we observe the position of the object in what would seem a much # trickier control problem md_position_feedback = LS([[0, 1],[-1, 1]], [[0],[1]], [1, 0], [0]) D2 = md_position_feedback.discretize(0.01)
lr.append(LR.linreg(df, tgt, seed)) ls.append(LS.lasso(df, tgt, seed)) dt.append(DT.dectree(df, tgt, seed)) dnn.append(DNN.nn(df, tgt, seed)) print(pd.DataFrame({'lr': lr}).describe()) print(pd.DataFrame({'ls': ls}).describe()) print(pd.DataFrame({'dt': dt}).describe()) print(pd.DataFrame({'dnn': dnn}).describe()) tgt = 'medv' df = prepro.Data(tgt) y = df[tgt] seed = 101 LR.linreg(df, tgt, seed) LS.lasso(df, tgt, seed) DT.dectree(df, tgt, seed) DNN.nn(df, tgt, seed) #find_best_model(df, tgt) #PCA.analysis(df)