This project leverages the power of a Long Short-Term Memory (LSTM) neural network implemented in TensorFlow and Keras to predict stock prices. The primary objective is to train a model capable of forecasting future stock prices based on historical trends.
The journey begins by loading the dataset into a Pandas DataFrame. The 'close' prices are then normalized using Min-Max scaling. Sequences and labels are crafted from the scaled data, utilizing a sequence length of 60 days for the LSTM model. Finally, the dataset is meticulously split into training and testing sets.
The core of the project lies in the LSTM model, featuring two layers of 128 units each. A dash of ReLU activation functions enhances the network's capabilities, while strategically placed dropout layers prevent overfitting. The output layer, a Dense layer with a linear activation function, perfectly aligns with regression tasks. The model is fine-tuned using the Adam optimizer and Mean Squared Error (MSE) loss.
Witness the model's evolution through 20 epochs, with a batch size of 32 ensuring a balance between efficiency and accuracy. Early stopping and learning rate reduction callbacks come into play, adding finesse to the training process.
Marvel as the trained model predicts stock prices on the test set. Predictions are gracefully inverse-transformed to their original scale for seamless comparison with actual prices. The results are unveiled using Matplotlib, presenting a captivating plot of actual versus predicted stock prices over time.
Embark on a journey of continuous refinement. Acknowledging the complexity of stock prediction, the current architecture remains a canvas for ongoing modifications aimed at achieving superior accuracy. Additional sections delve into the visual representation of training and validation losses over epochs.
Dive into the visual narrative of actual and predicted stock prices—a mesmerizing time series plot awaits. As the project concludes, the README emphasizes that the model is a dynamic work in progress, with relentless efforts focused on refining its architecture and unlocking greater predictive potential.
This stock prediction initiative is a holistic pursuit, not tailored to a specific company. The README underlines an unwavering commitment to refining model architecture and exploring avenues to boost prediction accuracy.