This project predicts and forecasts Apple Stock Prices (AAPL) using a Stacked LSTM (Long Short-Term Memory) model.
It uses historical stock data, applies preprocessing with MinMaxScaler, and trains an LSTM deep learning model with TensorFlow/Keras.
- Python
- NumPy & Pandas
- Matplotlib & Seaborn
- Scikit-learn
- TensorFlow / Keras
- Jupyter Notebook
├── app.py # (Optional) Streamlit app for deployment
├── stock_lstm.ipynb # Jupyter Notebook (EDA + Model training)
├── AAPL.csv # Stock data file
├── requirements.txt # Dependencies
├── model/ # Saved trained model & scaler
└── .gitignore # Ignored files
- Data Collection – Fetch stock price data using
pandas_datareader. - Preprocessing – Scaling with MinMaxScaler.
- Data Splitting – Train/Test split (65% training, 35% testing).
- Sequence Creation – Creating time-step-based input sequences.
- Model Building – Stacked LSTM layers with Keras.
- Model Training – 100 epochs, batch size = 64.
- Evaluation – RMSE calculation for training & testing.
- Prediction – Forecasting future stock prices (next 30 days).
- Visualization – Comparing actual vs. predicted stock trends.
Clone the repository and install requirements:
git clone https://github.com/your-username/Stock-Market-Prediction.git
cd Stock-Market-Prediction
pip install -r requirements.txt
Run the Jupyter Notebook:
jupyter notebook stock_lstm.ipynb
Run the Streamlit app:
This Command Launch my Python script as a web app in the browser
streamlit run app.py
🔹 Step 1: Open terminal (Command Prompt / PowerShell / Git Bash / VS Code Terminal)
Navigate to your project folder:
cd path\to\your\project
🔹 Step 2: Create the virtual environment
python -m venv .venv
python -m venv → creates a virtual environment
.venv → the folder name (you can also name it env, but .venv is common for GitHub projects)
🔹 Step 3: Activate the environment
On Windows (CMD)
.venv\Scripts\activate
On Windows (PowerShell)
.venv\Scripts\Activate.ps1
On Mac/Linux
source .venv/bin/activate
On Windows (PowerShell)
.venv\Scripts\Activate.ps1
🔹 Step 4: Install required libraries
Run this inside your project:
pip install streamlit pandas scikit-learn joblib
🔹 5. Run your Streamlit app
In the terminal (inside your project folder):
streamlit run app.py
The model achieves a low RMSE score on both training and test data.
Predicted trends closely follow the actual Apple stock price.
Next 30 days of stock prices are forecasted using the trained LSTM.
For queries or suggestions, feel free to connect:
📩 Email: zuhairzia1@gmail.com
💼 LinkedIn: www.linkedin.com/in/zuhairzia