|
47 | 47 | "import time\n",
|
48 | 48 | "from tensorflow.keras.layers import LSTM\n",
|
49 | 49 | "\n",
|
50 |
| - "\n", |
51 | 50 | "# Window size or the sequence length\n",
|
52 | 51 | "N_STEPS = 70\n",
|
53 | 52 | "# Lookup step, 1 is the next day\n",
|
|
82 | 81 | "BATCH_SIZE = 64\n",
|
83 | 82 | "EPOCHS = 400\n",
|
84 | 83 | "\n",
|
85 |
| - "# Apple stock market\n", |
86 |
| - "ticker = \"AAPL\"\n", |
| 84 | + "# Tesla stock market\n", |
| 85 | + "ticker = \"TSLA\"\n", |
87 | 86 | "ticker_data_filename = os.path.join(\"data\", f\"{ticker}_{date_now}.csv\")\n",
|
88 | 87 | "# model name to save, making it as unique as possible based on parameters\n",
|
89 | 88 | "model_name = f\"{date_now}_{ticker}-{LOSS}-{OPTIMIZER}-{CELL.__name__}-seq-{N_STEPS}-step-{LOOKUP_STEP}-layers-{N_LAYERS}-units-{UNITS}\"\n",
|
|
1116 | 1115 | "# evaluate the model\n",
|
1117 | 1116 | "mse, mae = model.evaluate(data[\"X_test\"], data[\"y_test\"], verbose=0)\n",
|
1118 | 1117 | "# calculate the mean absolute error (inverse scaling)\n",
|
1119 |
| - "mean_absolute_error = data[\"column_scaler\"][\"adjclose\"].inverse_transform(mae.reshape(1, -1))[0][0]\n", |
| 1118 | + "mean_absolute_error = data[\"column_scaler\"][\"adjclose\"].inverse_transform([[mae]])[0][0]\n", |
1120 | 1119 | "print(\"Mean Absolute Error:\", mean_absolute_error)\n",
|
1121 | 1120 | "# predict the future price\n",
|
1122 | 1121 | "future_price = predict(model, data)\n",
|
|
0 commit comments