友:你要不要一起參加鐵人賽?
我:好啊!
(幾天後)
我:乾我不小心忘了報名......
--------------------------------------> 2021.09.17
import numpy as np
import pandas as pd
import tensorflow as tf
coin_data = pd.read_csv('coin_Bitcoin.csv')
coin_data.head() # 顯示前面幾筆資料,預設五筆。
data = coin_data.drop(['SNo', 'Name', 'Symbol', 'Date', 'Volume', 'Marketcap'], axis=1)
data.head()
train_data = []
for idx in range(len(data)-7):
train_data.append(data.values[idx:idx+7].tolist())
train_label = []
for idx in range(7, len(data)):
rise_or_fall = data['Close'][idx] - data['Close'][idx-1]
if rise_or_fall >= 0:
rise_or_fall = 1
else:
rise_or_fall = 0
train_label.append(rise_or_fall)
稍微檢查一下data跟label長度有沒有一樣。
print(np.array(train_data).shape)
print(np.array(train_label).shape)
# (2984, 7, 4)
# (2984,)
好的,今天我們把會訓練模型需要的資料整理好了,明天將會帶大家來訓練不同的模型囉!