Stock Market Prediction using LSTM
- Pooja Shrikisan Gurav
- Jul 23, 2025
- 3 min read
📈 Predicting Tesla’s Stock Price: A Machine Learning and Deep Learning Approach

Tesla Inc., the electric vehicle and renewable energy giant, continues to dominate headlines not just for its cutting-edge tech, but also for its dynamic stock market performance. For investors and analysts alike, predicting Tesla’s stock trends is both a challenge and an opportunity.
In this project, we combined data analysis, feature engineering, and predictive modeling to forecast Tesla's stock price movements using both traditional machine learning models and advanced deep learning architectures like LSTM (Long Short- Term Memory) networks.
🔍 Objective
The goal was to:
Clean and analyze Tesla's historical stock market data
Extract meaningful insights through exploratory data analysis (EDA)
Engineer features to enhance model performance
Train and evaluate different models for stock price prediction
Compare traditional ML techniques with deep learning models for forecasting
🧾 Tesla Dataset Overview
Our dataset included:
Date
Open, High, Low, Close prices
Volume (number of shares traded)
Adjusted Close (reflecting dividends, splits, etc.)
We added a 'Month' column to observe monthly trends.
❓ Research Questions
How well do machine learning methods forecast stock prices?
How can time-series analysis be used to predict future stock prices?
Are non-linear models better than linear regression for this task?
What patterns exist between open/close prices and other market variables?
📊 Data Analysis & Visualization
Exploratory Insights
No null values or missing data
No outliers disrupting trends
Dataset was fully numeric, suitable for modeling
Visualizations
Line charts to show trends in Open, High, Low, Close, and Volume over time
Heatmap to show correlation between features
Bar and line plots for monthly and yearly averages
AUC-ROC plots to compare model performance
An interactive dashboard was built to help users explore stock trends in real-time
🤖 Models Applied
We trained and tested the following models:
Logistic Regression
Support Vector Classifier (SVC)
XGBoost Classifier
LSTM (Long Short-Term Memory) – for time-series forecasting
📌 Key Observations
XGBoost showed overfitting — high training accuracy but lower test performance.
Logistic Regression and Linear Regression produced RMSE values of 53.57 and 77.2 respectively.
LSTM outperformed all with the lowest RMSE values and better generalization, making it the best model for stock trend prediction.
🧠 Why LSTM?
LSTM networks are designed for sequential data, making them perfect for stock trend forecasting. They:
Capture long-term dependencies
Learn from historical price patterns
Efficiently handle non-linearities in financial data
We used 70% of the data for training and 30% for testing. Among the features, 'Low' price delivered the best results in terms of RMSE.
📉 RMSE Values of LSTM Model
Feature | Training RMSE | Testing RMSE |
All Features | 168.76 | 314.11 |
Open | 5.75 | 11.69 |
Close | 5.80 | 12.26 |
High | 5.44 | 12.23 |
Low | 5.29 | 11.01 |
🔹 The 'Low' feature had the smallest gap between training and testing RMSE values, making it the most stable and generalizable predictor.
📌 Final Verdict
LSTM emerged as the most efficient and reliable model, outperforming traditional models like Logistic Regression and XGBoost. It handled complex time-based relationships and delivered accurate stock trend forecasts.
📚 References
Gandhmal, D.P., & Kumar, K. (2019). Systematic analysis and review of stock market prediction techniques. Computer Science Review, 34:100190.
Li, Z., Yu, H., Xu, J., Liu, J., & Mo, Y. (2023). Stock market analysis and prediction using LSTM: A case study on technology stocks. Innovations in Applied Engineering and Technology.
🚀 Conclusion
Whether you’re a data enthusiast, financial analyst, or just curious about the power of machine learning in finance, this project shows how AI can offer deep insights into market behavior. With Tesla’s stock being highly volatile, using LSTM models opens up new possibilities for smarter investment strategies.




Comments