This project implements a Recurrent Neural Network (RNN) to forecast the next-day closing price of American Airlines (AAL) stock. Leveraging time series data, the model captures temporal dependencies to provide accurate price predictions.
-
Source: Yahoo Finance
-
Ticker: AAL
-
Period: December 1, 2022 to November 30, 2023
-
Features: Open, High, Low, Close, Adj Close, Volume
-
Utilizes raw OHLC data along with adjusted closing price and trading volume
-
Constructs sequences of 5-day historical windows to predict the following day's closing price (input shape: (5, 6))
-
Normalization:
- Scales all features to the [0,1] range using
MinMaxScaler
- Scales all features to the [0,1] range using
-
Sequence Generation:
- Custom
rnn_data_setupfunction creates training samples with lookback windows and corresponding targets
- Custom
-
Data Splitting:
-
Training set: 144 samples
-
Validation set: 48 samples
-
Test set: 48 samples
-
-
Type: Sequential RNN
-
Layers:
-
SimpleRNNwith 16 units (linear activation) -
Denseoutput layer (1 unit)
-
-
Hyperparameters:
-
Learning rate: 0.0012
-
Batch size: 512
-
Loss: Mean Squared Error (MSE)
-
Metric: Mean Absolute Error (MAE)
-
Optimizer: Adam
-
-
Epochs: 100
-
Validation: Monitored on a hold-out validation set during training (verbose=0)
-
Prediction Shape: (48, 1)
-
Evaluation Metrics on Test Set:
-
Mean Squared Error (MSE): 0.08615
-
Root Mean Squared Error (RMSE): 0.29352
-
-
Clone the repository:
git clone https://github.com/CSwebD/RNN-AAL-Prediction.gitcd RNN-AAL-Prediction -
Install dependencies:
pip install -r requirements.txt -
Launch Jupyter Notebook:
RNN.pred.AAL_jupyter.ipynb -
Execute all cells to reproduce preprocessing, training, and evaluation.
Python 3.x
numpy, pandas, matplotlib, seaborn, yfinance, tensorflow (keras), scikit-learn
Contributions are welcome! Please fork the repo, create a branch for your feature or bugfix, and submit a pull request.
This project is licensed under the MIT License. Feel free to use and modify for educational and research purposes.