Predictive Analysis of Stock based on Historical Data in Python The models used are LSTM Model and ARIMA.
Data is dynamically taken from _Yahoo Finance.
The program asks you to enter the Stock Ticker, Start Date and End Date for analysis. Based on your input it will download the historical data from Yahoo Finance.
At first, the program will split the data as 70%-train and 30%-test. I have trained the LSTM model by adding dense=1(1 layer) and lookback is 60. While fitting the epocs are set as 50. Loss function value initially is high but it reduces down and as set epoch 50 to get a better loss function value.
Plotly graphs are used for plotting the time series. You can see
Close values plotted:
Results of LSTM Model: The red line are the predictions and green is the original close. As we can see from the graph, the predictions are closer to the original close values.
Root Mean Square Error and R2 Score values for the LSTM Model.
ARIMA Model
I have used ARIMA(4,1,2) Model for forecasting the future values.
Forecasting plotted using plotly graph after taking inverse trasform of the predictions from the results of ARIMA Model Blue line indicates the forcasting values
You can compare both and check LSTM and ARIMA. In this scenario I have used Tesla Stock but as I said the program will ask you initially which stock do you want to consider, you can enter the stock ticker value of your desired stock.
Thankyou