A time series deep learning project that predicts stock closing prices using an LSTM (Long Short-Term Memory) neural network. This model learns patterns from Apple Inc. (AAPL) stock data between 2015 and 2024. Predicting future stock prices using machine learning and deep learning techniques in Python.
| File Name | Description |
|---|---|
stock_price_prediction.ipynb |
Jupyter Notebook containing all code for data loading, training, and evaluation |
README.md |
Project documentation |
- Python 🐍
- Pandas
- NumPy
- Matplotlib / Seaborn
- Scikit-learn
- TensorFlow / Keras (for LSTM models)
- yfinance (for fetching stock data)
- ✅ Load historical stock data using
yfinance - 📊 Use
Closeprice as target feature - 📏 Normalize data using MinMaxScaler
- ⛓️ Create sequential data (lookback window = 60 time steps)
- 🤖 Train a 2-layer LSTM neural network
- 📉 Evaluate model using RMSE (Root Mean Squared Error)
- 🧪 Plot actual vs. predicted prices (optional)
data– contains historical stock price CSV filesnotebooks– Jupyter notebooks for EDA and model buildingmodels– saved trained modelssrc– Python scripts for preprocessing and modelingREADME.md– project documentationrequirements.txt– list of required packages
Stock price data is fetched using the yfinance library and saved in CSV format for analysis and modeling.
Visualize trends, check stationarity, analyze moving averages, and understand seasonal patterns in closing prices.
- Normalize the price data using MinMaxScaler
- Create time-series sequences using a sliding window
- Reshape input for compatibility with LSTM models
- A deep LSTM architecture with dropout regularization
- Trained on historical closing price sequences
- Compiled with mean squared error loss and Adam optimizer
The model is trained for multiple epochs with a batch size of 32. Model checkpoints and loss evaluation are logged.
Once trained, the model predicts future stock prices based on the latest sequences. Predictions are scaled back to original values.
Actual vs. predicted prices are plotted to evaluate model performance visually.
Mean Squared Error (MSE) is calculated to quantify prediction error. Lower MSE indicates better performance.
This project demonstrates the application of deep learning techniques—particularly LSTM networks—for predicting stock prices based on historical data. While the model shows promising results in capturing trends, it's important to note that stock markets are influenced by countless external factors, and predictions should not be used for real-world trading decisions without further validation.