This project builds a time series forecasting model to predict Tesla's stock prices using LSTM (Long Short-Term Memory) networks. The model is trained on historical stock data and deployed as an API using FastAPI with Uvicorn.
- Data Collection: Fetching historical Tesla stock prices.
- Data Preprocessing: Normalization, feature engineering, and sequence generation.
- Model Training: Implementing LSTM with TensorFlow/Keras.
- Evaluation & Optimization: Hyperparameter tuning and performance analysis.
- Deployment: Serving predictions using FastAPI.
- Source: Yahoo Finance
- Data: Tesla (TSLA) stock prices
- Features: Date, Open, High, Low, Close, Volume
- Python
- TensorFlow & Keras
- Pandas & NumPy
- Scikit-learn
- Matplotlib & Seaborn (for visualization)
- FastAPI & Uvicorn (for API deployment)
- Docker (optional for containerization)
- Clone this repository:
git clone https://github.com/yourusername/Stock_Prediction.git cd Stock_Prediction - Install dependencies:
pip install -r requirements.txt
Run the training script:
python train.pyThis will:
- Load and preprocess the Tesla stock dataset
- Train an LSTM model
- Save the trained model as
model.h5
- Start the FastAPI server:
uvicorn app:app --reload
- API Endpoint:
Example request:
GET /predict?days=5Example response:curl -X GET "http://127.0.0.1:8000/predict?days=5"{ "predicted_prices": [880.45, 890.12, 905.67, 915.32, 925.89] }
- Integrate Sentiment Analysis on news headlines for better forecasting.
- Implement GRU or Transformer-based models for comparison.
- Deploy on Cloud (AWS/GCP/Azure) for real-time inference.
Feel free to fork this repository and submit a pull request if you have any improvements!
This project is licensed under the MIT License.