The goal of this project is to predict future stock prices based on historical stock data.
We used features like Open, High, Low, Close, and Volume to train a regression model and evaluate its prediction accuracy.
- File:
stock.csv - Columns:
Date— Trading dateOpen— Opening priceHigh— Highest price of the dayLow— Lowest price of the dayClose— Closing priceVolume— Trading volume
- Python
- Pandas
- NumPy
- Matplotlib
- scikit-learn (Linear Regression, train-test split, metrics)
- Converted
Datecolumn to datetime and sorted by date - Handled missing values using forward fill
- Optional feature: Added
Averageprice = (High + Low) / 2
- Model: Linear Regression
- Features:
Open, High, Low, Volume, Average - Target:
Close - Train-Test Split: 80%-20% (time series, shuffle=False)
- Metrics:
- Mean Squared Error (MSE)
- R² Score
- Chart: Actual Close vs Predicted Close
- Linear Regression can predict general trend of stock prices
- Model performance can be improved with advanced models like LSTM or Random Forest Regression
- Key features influencing prediction:
Open, High, Low, Volume, Average
- Place
stock.csvin the project folder - Run
stock_prediction.pyin VS Code or any Python IDE - View terminal outputs and chart
- Terminal outputs: dataset info, MSE, R²
- Chart: Actual vs Predicted Close Price