質問編集履歴
1
train_x,train_yを作る関数を記載しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -105,3 +105,41 @@
|
|
105
105
|
-2.32E-04
|
106
106
|
|
107
107
|
```
|
108
|
+
|
109
|
+
|
110
|
+
|
111
|
+
train_xを作る関数です。
|
112
|
+
|
113
|
+
```python
|
114
|
+
|
115
|
+
def load_data(cls, n_prev):
|
116
|
+
|
117
|
+
|
118
|
+
|
119
|
+
df = pd.DataFrame(list(daily_list.objects.filter().values()))
|
120
|
+
|
121
|
+
df = df.sort_values(['symbol', 'created_date_at'])
|
122
|
+
|
123
|
+
df = df.reset_index(drop=True)
|
124
|
+
|
125
|
+
trainX, trainY = [], []
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
for symbol, df_s in df.groupby('symbol'):
|
130
|
+
|
131
|
+
df_s2 = df_s.loc[:, 'signal0']
|
132
|
+
|
133
|
+
for i in range(len(df_s2) - n_prev):
|
134
|
+
|
135
|
+
trainX.append(df_s2.iloc[i:i + n_prev].values)
|
136
|
+
|
137
|
+
trainY.append(df_s2.iloc[i + n_prev])
|
138
|
+
|
139
|
+
atrainX = np.array(trainX)
|
140
|
+
|
141
|
+
atrainY = np.array(trainY)
|
142
|
+
|
143
|
+
return (atrainX, atrainY)
|
144
|
+
|
145
|
+
```
|