Analysis of BMRI Stock Prices Using Python and LTSM in Google Colab

· Source: Machine Learning on Medium · Field: Technology & Digital — Artificial Intelligence & Machine Learning, Data Science & Analytics, Capital Markets & Investment Management · Depth: Intermediate, extended

Summary

A project analyzed and predicted PT Bank Mandiri (Persero) Tbk (BMRI) stock prices using Python and a Long Short-Term Memory (LSTM) model in Google Colab. Historical data from Yahoo Finance, spanning January 1, 2022, to December 8, 2025, was retrieved and preprocessed using MinMaxScaler. An LSTM model, comprising two 50-neuron layers and a Dense output layer, was trained for 10 epochs with a batch size of 32, achieving a Mean Squared Error (MSE) of 24,017.37. The model then predicted BMRI stock prices for the next 30 days, showing a gradual upward trend. These predictions were subsequently analyzed by a Llama 3 Large Language Model via Ollama, which interpreted the trends and offered recommendations, demonstrating an integrated approach for financial forecasting.

Key takeaway

For data scientists building financial forecasting systems, this integrated approach demonstrates how to combine robust time series prediction with interpretive AI. You should consider using LSTM for its pattern recognition capabilities on historical stock data and then integrate an LLM like Llama 3 to generate human-readable analyses and recommendations, enhancing the utility of raw predictions for stakeholders. This can streamline your workflow from data to actionable insights.

Key insights

Integrating LSTM for stock prediction with LLM for analysis provides comprehensive financial forecasting.

Principles

Method

Retrieve historical stock data, normalize closing prices using MinMaxScaler, train an LSTM model with a sliding window (n_steps=60), then use iterative forecasting for future predictions. Integrate with an LLM for interpretive analysis.

In practice

Topics

Best for: Machine Learning Engineer, Data Scientist, AI Student

Related on AIssential

Open in AIssential →

Editorial summary, takeaway, and curation by AIssential. Original article published by Machine Learning on Medium.