Clear Sky Science · en
A hybrid grey wolf optimized eXtreme gradient boosting-based machine learning model for hospital pharmaceutical demand forecasting
Why medicine supply needs a smarter crystal ball
When you show up at a hospital, you expect the right medicines to be on the shelf. Behind the scenes, however, hospitals struggle to guess how much of each drug they will need in the coming weeks. Order too little and patients face dangerous stockouts; order too much and expensive medicines expire unused. This study introduces a new data-driven forecasting approach that helps hospitals anticipate medicine needs more accurately by blending real patient dispensing records with local weather and time-of-year patterns.

Everyday problems behind the pharmacy counter
Hospitals worldwide walk a tightrope between shortages and waste. Traditional forecasting tools—such as simple trend lines and moving averages—treat demand as if it changes smoothly and predictably. In reality, medicine use jumps up and down as illnesses spread, seasons change, and local events unfold. Flu season, heatwaves, or mosquito-borne outbreaks can suddenly drive up demand for specific drugs. Existing methods often miss these twists, particularly in smaller or resource-limited hospitals, leading to panicked last-minute purchases or piles of unused stock.
Letting data, weather, and seasons tell the story
The researchers focused on two provincial hospitals in Lamphun Province, Thailand, collecting more than 3.4 million records of outpatient visits and pharmacy dispensing between late 2023 and mid-2025. They linked these records to a national medicine catalogue so each item could be tracked consistently across hospitals. At the same time, they pulled in detailed weather information—temperature, rainfall, humidity, wind, and sunlight—from an open weather service, along with calendar clues such as year, month, and week number. By combining these pieces, they built a rich weekly picture of how demand for 588 different medicines rises and falls with both hospital activity and environmental conditions.

How a wolf pack helps pick the right clues
To turn this complex data into reliable forecasts, the team designed a hybrid model that marries two ideas. The first is a search method inspired by the hunting behavior of grey wolves. In the model, each “wolf” represents a possible subset of clues—such as certain weather measures or time markers—that might help predict demand. These wolves roam through the space of possibilities, gradually converging on the most informative combinations while discarding noisy or redundant factors. The second idea is a powerful prediction engine known as gradient boosting, which builds many small decision trees and combines them into a strong overall forecast. By letting the wolf-inspired search tune which clues to use and how the trees are built, the system focuses its learning power where it matters most.
Putting the model to the test in real hospitals
The new hybrid model was pitted against five strong machine-learning rivals, including random forests, neural networks, and other boosting methods, all given the same cleaned and standardized data. The researchers judged performance using three common yardsticks: how large the typical error was, how strongly big mistakes were penalized, and how much of the ups and downs in real demand the model could explain. Across the board, the hybrid approach came out on top. It not only made the smallest errors but also tracked sudden peaks and dips in weekly medicine use more closely than the alternatives, and its results stayed stable even when the train–test data split was changed.
What better forecasts mean for patients and planners
For non-specialists, the core message is straightforward: using smarter algorithms that pay attention to weather and timing can make hospital medicine forecasts far more reliable. While this proof-of-concept is based on just two Thai hospitals, it shows that blending real-world dispensing data with local environmental signals can reduce guesswork, cut waste, and help prevent shelves from running empty. With careful oversight and integration into hospital information systems, such tools could support purchasing teams, improve national drug planning, and ultimately make it more likely that the right medicine is available when a patient needs it.
Citation: Samniang, W., Shah, S.M.T., Tun, Y. et al. A hybrid grey wolf optimized eXtreme gradient boosting-based machine learning model for hospital pharmaceutical demand forecasting. Sci Rep 16, 13400 (2026). https://doi.org/10.1038/s41598-026-48590-4
Keywords: medicine demand forecasting, hospital pharmacy, machine learning, healthcare supply chains, weather and health