LSTM Stock Price Prediction

An interactive neural network model for forecasting stock prices using Long Short-Term Memory networks.


This simulation implements an LSTM (Long Short Term Memory) neural network trained on historical stock price data to forecast future closing prices. Select any stock ticker and watch as the model predicts price movements based on 30-day historical sequences.

How It Works

The model processes historical daily closing prices through a normalization pipeline, creates 30-day sequences as input features, and trains a stacked 2-layer LSTM with 32 hidden units. After training on 80% of the data, it makes predictions on unseen test data and evaluates performance using RMSE (Root Mean Squared Error).

Key Components

  • Data Source: Historical daily stock prices via yfinance
  • Normalization: StandardScaler for zero mean, unit variance
  • Sequencing: 30-day sliding windows for temporal patterns
  • Architecture: 2-layer LSTM (32 hidden units) with linear output layer
  • Training: Adam optimizer, MSE loss, 100 epochs on train set
  • Evaluation: RMSE metric on test set, visualization of predictions vs actual

Try Different Stocks

Enter any publicly traded stock ticker (e.g., AAPL, GOOGL, TSLA, MSFT, AMZN) to see how the model performs across different companies. The model adapts to each stock's unique price distribution through normalization.

Current: AAPL

About this model

This LSTM neural network is trained on historical stock price data to forecast future closing prices. The model uses a sequence length of 30 days and has been trained to minimize prediction error.

Note: This is a demonstration model. Real trading decisions should never be based solely on automated predictions. Always conduct thorough research and consult with financial advisors.


Important Disclaimer

This is a demonstration model for educational purposes only. Machine learning predictions of financial markets come with significant limitations:

  • Historical patterns do not guarantee future performance
  • Market behavior is influenced by countless unpredictable events
  • This model does not account for market sentiment, news, or economic indicators
  • Overfitting to historical data can lead to poor real-world predictions

Never make real financial decisions based solely on this model. Always conduct thorough research, diversify your portfolio, and consult with qualified financial advisors.

← Back to Simulations