This project uses Random Forest to predict the direction of stock price changes. Using historical data from the Nifty50 index (Indian stock market), the project first creates new features of rolling averages and trends and then builds a: Random Forest Classifier to predict whether the stock price will increase or decrease.
-
Training and testing the Model:
stock_predictor.ipynb--> This notebook pulls historical data from the Nifty50, trains a Random Forest Classifier and Regressor, and saves the models asstockpred.pklandprice_change_predictor.pkl. -
Use the Model: Scroll down ,This notebook loads the saved models and tests them on new stock data. Modify the
new_dataDataFrame in this notebook to test predictions on your own data.
Install the required libraries:
pip install yfinance pandas scikit-learn joblibThe Classifier: Predicts whether the stock price will go up or down based on features such as Close, Volume, Open, High, and Low.
From stock_predictor.ipynb:
new_data = pd.DataFrame({
'Close': [25127.95],
'Volume': [206400],
'Open': [25023.45],
'High': [25159.75],
'Low': [25017.50]
})Predictions for new data: [0] #0 means the price will go down
This project provides a basic model for predicting daily stock price movements and changes using machine learning. It was build as my capstone project for CBSE 2025 AI practical.