The code implements a neural network model, PricePredictor, trained on historical stock price data to predict future stock prices, visualizing the predictions alongside historical prices and calculating the average of the predicted prices.
The graph produced will either show the plotted points, the average after the historical days from january or the historical prices for the year with the forecasted days added onto it.
- Swap
ticker="INTC"
for whatever ticker you want to check - Swap
future_days=30
for the amount of days you want to forecast - Ensure that you have a cuda device before running and you have the libraries installed except for yfianance since kaggle and colab don't have it.
This model is trained by adjusting its internal parameters based on historical stock price data and observed outcomes. It uses a forward pass to make predictions and calculates the difference between the predicted and actual prices using a loss function. Through multiple iterations and parameter updates, the model learns patterns in the data and improves its ability to make accurate predictions. Once trained, the model can take input values and generate predictions for future stock prices based on the patterns it has learned.