Spaces:
Runtime error
Runtime error
Commit
·
a8a6f27
1
Parent(s):
2b14627
Update app.py
Browse files
app.py
CHANGED
|
@@ -48,9 +48,38 @@ scaler = MinMaxScaler(feature_range=(0,1))
|
|
| 48 |
|
| 49 |
data_training_array = scaler.fit_transform(data_training)
|
| 50 |
|
| 51 |
-
|
| 52 |
-
|
| 53 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 54 |
|
| 55 |
|
| 56 |
#testing part
|
|
|
|
| 48 |
|
| 49 |
data_training_array = scaler.fit_transform(data_training)
|
| 50 |
|
| 51 |
+
x_train = []
|
| 52 |
+
y_train = []
|
| 53 |
|
| 54 |
+
for i in range(100, data_training_array.shape[0]):
|
| 55 |
+
x_train.append(data_training_array[i-100: i])
|
| 56 |
+
y_train.append(data_training_array[i, 0])
|
| 57 |
+
|
| 58 |
+
x_train, y_train = np.array(x_train), np.array(y_train)
|
| 59 |
+
|
| 60 |
+
import tensorflow as tf
|
| 61 |
+
from tensorflow import keras
|
| 62 |
+
from keras.layers import Dense, Dropout, LSTM
|
| 63 |
+
from keras.models import Sequential
|
| 64 |
+
|
| 65 |
+
model = Sequential()
|
| 66 |
+
model.add(LSTM(units = 50, activation = 'relu', return_sequences = True,
|
| 67 |
+
input_shape = (x_train.shape[1], 1)))
|
| 68 |
+
model.add(Dropout(0.2))
|
| 69 |
+
|
| 70 |
+
model.add(LSTM(units = 60, activation = 'relu', return_sequences = True))
|
| 71 |
+
model.add(Dropout(0.3))
|
| 72 |
+
|
| 73 |
+
model.add(LSTM(units = 80, activation = 'relu', return_sequences = True))
|
| 74 |
+
model.add(Dropout(0.4))
|
| 75 |
+
|
| 76 |
+
model.add(LSTM(units = 120, activation = 'relu'))
|
| 77 |
+
model.add(Dropout(0.5))
|
| 78 |
+
|
| 79 |
+
model.add(Dense(units = 1))
|
| 80 |
+
|
| 81 |
+
model.compile(optimizer='adam', loss = 'mean_squared_error', metrics='accuracy')
|
| 82 |
+
model.fit(x_train, y_train, epochs = 10)
|
| 83 |
|
| 84 |
|
| 85 |
#testing part
|