yesterday vs today

Where do legs come from?

“Everything has its price!” instilled in us since childhood, to which inquisitive minds responded with the questions “What is the price?”, “How to manage it?”, “Can it be predicted?” Some people are so fascinated by these questions that they decide to connect their whole life with prices and become a cashier at Pyaterochka, others go to the stock exchange to experiment with prices, but my path to mastering the basics of pricing turned out to be a little less thorny (but this is inaccurate) and began 15 years ago with the development of a platform for accounting and warehouse management in Retail. At that time, the concepts of predictive analytics and price forecasting were on a par with advertisements like: “Elite lobotomy: Long! Hurt! Expensive!”, and fortune telling with morning coffee often gave better results in accuracy than the software implementation of predictive methods available at that time.

The modern development of AI and ML technologies opens up new opportunities here, and we are already actively using our developed technological and analytical expertise in those areas where pricing issues are most relevant – in retail, manufacturing, catering and other areas.

Today I would like to share one small but clear example of how approaches and tools have evolved recently and how all this is reflected in the results of real business.

How much is gold worth?

What do you imagine when you hear the word “mining”?

My associative series, as a resident of the Irkutsk region with the price of electricity in the region of 1 ruble per kW, for a long time ended at the ASIC heating my grandmother’s dacha. All until I came across companies involved in mining, and then I realized that mining is not only about Bitcoin, but also about nickel, copper, gold, with which such an applied task comes to the surface How Mineral Commodity Price Forecastingthe solution of which is relevant, in particular, in gold mining, to which the case we are analyzing will relate.

The gold mining industry is especially developed in Mongolia, neighboring Irkutsk. I’ll save the lecture “Ulaanbaatar – a city of contrasts” with pictures of yurts against the backdrop of skyscrapers for another time, but now I’ll tell you how local companies approach solving production and operational problems using machine learning technologies. Although, without pictures, it’s boring! So here you go!

The author against a background of contrasts

The author against a background of contrasts

Historically, most solutions for predicting mineral resource prices in the industry have been developed based on models ARIMA (Autoregressive Integrated Moving Average) or integrated moving average autoregressive modelAnd GARCH (Generalized Autoregressive Conditional Heteroskedasticity) or generalized autoregressive heteroscedasticity model. Over the years of their use, questions have often arisen about optimization, increasing accuracy, or even replacing them with other more suitable models.

Below, for example, is data from an experiment based on the ARIMA model, as part of our case study on the dynamics of prices per ounce of gold, from which it becomes clear why changes are overdue. The models in the experiment were trained on historical data collected from 1950 to 2022.

ARIMA forecast and fact of price per ounce of gold for 2023

ARIMA forecast and fact of price per ounce of gold for 2023

The magnitude of errors depending on the timeframe for the ARIMA model

ARIMA forecast and fact of price per ounce of gold for 2023

The magnitude of errors depending on the timeframe for the ARIMA model

The magnitude of errors depending on the timeframe for the ARIMA model

As a result of analyzing the problem, auditing existing solutions and conducting experiments, we came to the conclusion that it is possible to effectively replace models based on ARIMA and GARCH with LSTM( Long short-term memory) or models long short term memorywhich even at the prototype stage showed more promising results.

The LSTM model itself in the experiment was built on the basis of the Tensor Flow and Keras API libraries, while for training the root mean square error estimate was used as a loss function, and Adam (Adaptive Moment Estimation) optimizer was chosen as the optimization algorithm:

# Создание модели
model = Sequential()
model.add(LSTM(50, input_shape=(1, look_back)))
model.add(Dense(1))
model.compile(loss="mean_squared_error", optimizer="adam")

# Остановка в отсутствии улучшений в течение 10 эпох
early_stopping = EarlyStopping(monitor="val_loss", patience=10, restore_best_weights=True)

# Тренировка модели
model.fit(X_train, Y_train, epochs=100, batch_size=1, verbose=2, validation_data=(X_test, Y_test), callbacks=[early_stopping])

# Погадай-ка мне, большая черепаха!
train_predict = model.predict(X_train)
test_predict = model.predict(X_test)

Below you can find the results of the model trained on the same dataset as ARIMA from the example above:

LSTM forecast and actual gold price per ounce for 2023

LSTM forecast and actual gold price per ounce for 2023

Error magnitude depending on timeframe for LSTM

Error magnitude depending on timeframe for LSTM

From the data presented, it is clear that for all scenarios, the forecast accuracy of the LSTM model significantly exceeds the ARIMA indicators, which ultimately converts into more effective solutions and better financial performance for business, thereby more than recouping the costs of optimizing existing processes and introducing advanced technologies into production and operational activities, given that the duration of this type of experiment is limited to weeks, and a PoC solution can be obtained without using large resource capacities.

Instead of a conclusion

The basic principle “If it works, don’t touch it!” previously was largely justified by the fact that the cost of any change in the created software monolith was often prohibitively high. Now, against the backdrop of hyperactive development large language models or LLM (Large Language Model) In recent years, the cost of testing product hypotheses and conducting technological experiments has decreased significantly, so it’s time to think about revising this principle and moving to a new one – “Does it work? maybe better!”.

Even though all the tricks described in this article were performed by professionals, I highly recommend trying them at home 🙂 The cost of trial and error has become relatively small, so experiment, optimize, and may the power of technology be with you!

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *