Skip to content

Commit 351ee95

Browse files
committed
fix minor bug on stock prediction notebook
1 parent 008dc85 commit 351ee95

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

machine-learning/stock-prediction/stock_prediction.ipynb

+3-4
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@
4747
"import time\n",
4848
"from tensorflow.keras.layers import LSTM\n",
4949
"\n",
50-
"\n",
5150
"# Window size or the sequence length\n",
5251
"N_STEPS = 70\n",
5352
"# Lookup step, 1 is the next day\n",
@@ -82,8 +81,8 @@
8281
"BATCH_SIZE = 64\n",
8382
"EPOCHS = 400\n",
8483
"\n",
85-
"# Apple stock market\n",
86-
"ticker = \"AAPL\"\n",
84+
"# Tesla stock market\n",
85+
"ticker = \"TSLA\"\n",
8786
"ticker_data_filename = os.path.join(\"data\", f\"{ticker}_{date_now}.csv\")\n",
8887
"# model name to save, making it as unique as possible based on parameters\n",
8988
"model_name = f\"{date_now}_{ticker}-{LOSS}-{OPTIMIZER}-{CELL.__name__}-seq-{N_STEPS}-step-{LOOKUP_STEP}-layers-{N_LAYERS}-units-{UNITS}\"\n",
@@ -1116,7 +1115,7 @@
11161115
"# evaluate the model\n",
11171116
"mse, mae = model.evaluate(data[\"X_test\"], data[\"y_test\"], verbose=0)\n",
11181117
"# 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",
11201119
"print(\"Mean Absolute Error:\", mean_absolute_error)\n",
11211120
"# predict the future price\n",
11221121
"future_price = predict(model, data)\n",

0 commit comments

Comments
 (0)