def button_train(name): scale_img = prepro.collect_data( os.path.join(os.getcwd(), 'avengers/' + name + '/' + name + '_p.jpg')) obj = training(modeldir, scale_img, name) emb_array = obj.main_train() emb_list = list(map(list, emb_array)) return jsonify({name: emb_list})
def visualization(): for idx, stock in enumerate(config.stock_names): timestamps = get_timestamps(config.yrs, config.mths, config.dys) df = collect_data(timestamps, stock, config.moving_averages, True) fig1 = plot_closing(df, moving_averages=True, intervals=None) fig1.show() fig2 = plot_gain(df) fig2.show() daily_returns, fig1_c, fig2_c = compare_stocks(config.stock_names_compare, timestamps)
def button_train(name): img = cv2.imread( os.path.join(os.getcwd(), 'avengers/' + name + '/' + name + '_p.jpg')) scale_img = prepro.collect_data(img) obj = training(modeldir, scale_img, name) emb_array = obj.main_train() feature_list.append(feature_map(name, emb_array)) return "Success!"
def get_data(csv): if csv: df = pd.read_csv(csv) df = df.set_index('Date') return df else: timestamps = preprocess.get_timestamps(preprocess.config.yrs, preprocess.config.mths, preprocess.config.dys) df = preprocess.collect_data( timestamps, preprocess.config.stock_names[0], moving_averages=preprocess.config.moving_averages, include_gain=True) return df
def make_predictions(features): timestamps = get_timestamps(config.yrs, config.mths, config.dys) if len(config.stock_names) == 1: for feature in features: df = collect_data(timestamps, config.stock_names[0], moving_averages = config.moving_averages, include_gain=True) dataset = Dataset(df, feature = feature) dataset.get_dataset(scale=True) train_data, test_data, train_data_len = dataset.split(train_split_ratio = 0.8, time_period = 30) x_train, y_train = train_data x_test, y_test = test_data model = keras_lstm(x_train) pred = Predict() pred.train([x_train, y_train], model, show_progress=True) scaler = dataset.scaler predictions= pred.predict([x_test, y_test], scaler, data_scaled=True, show_predictions=True) plot_predictions(df, train_data_len, predictions)
def click2(): """ respond to the button2 click """ # toggle button colors as a test if (button_flag[2] % 2 ==1): button2.config(bg="white") button_flag[2] +=1 if button_flag[2] == 1: #pre_image.append(aug_img) print ("Training Start") scale_img = prepro.collect_data(os.path.join(os.getcwd(),'avengers/hermsworth/hermsworth_p.jpg')) obj = training(modeldir, scale_img, "hermsworth") get_feature = obj.main_train() feature_list.append(get_feature) print('Getting feature map succeed') elif(button_flag[2] %2 ==0): button2.config(bg="green") button_flag[2] += 1