Case study: Artificial Intelligence based real time forecasting of a customer's purchase pattern and cross-selling.

The work is a mobile based application which collects and analyses spending patterns of bank customers based upon their card swiping history (time series data) and geographic locations (GPS based latitude and longitude, and GEOHASH), using intelligent AI algorithms. The output of the application is of two parts:

Utility: Better understanding and prediction of customer behaviour

Part 1

Based upon an individual’s card swiping data that extracts only the time series spending pattern of the concerned individual. It then uses various statistical and machine learning algorithms to predict the future spending pattern of the individual.

Part 2

This is based upon utilising the GPS data of the location of spending which, matches it with the names of the business, their nature etc. These characteristics of the businesses are further matched with their business promotional features (offers, discounts, etc.) to inform the card holder of the best offers, promotional deals etc.

Part 1

Since this mobile application extracts the GPS location of the card holder, it first asks the mobile user for his/her permission to record and store such location related data. In addition, it asks the application user for permission to merge the GPS data with his/her card swiping information. These forms of data are then sent to a secured database server of the bank, that creates an individual account for each application user. Analytics carried out on an application user’s data is then sent to his/her mobile application at regular intervals.

Since various application users are expected to have various spending patterns, no particular time series algorithm is assigned for all users for the forecasting purpose. Rather a number of algorithms such as Auto Regressive Integrated Moving Average (ARIMA), Exponential Time Smoothing (ETS), Exponential Smoothing State Space Model With Box-Cox Transformation, ARMA Errors, Trend And Seasonal Components (TBATS) to name a few- are considered.

A comparison of the Mean Absolute Percentage Error (MAPE) for all the models are then carried out and the algorithm with the lowest MAPE value is chosen as the best model for forecasting. Thus for example, based upon the difference of spending pattern, the application may choose ARIMA for user A and ETS for user B. The below figure is a proposed graphical feature shown by the application. It is based on a simulated data sample of the daily spending amount of a user. The application forecasts his/her trend in daily spending pattern for the next 10 days.

Figure: Forecasting the trend in daily spending pattern

Figure: Dynamic clustering of spending pattern

Feature – Optimal clustering of daily spending (monitor average spending)

This feature uses dynamic programming to cluster univariate (amount of daily spending) data and guarantees production of optimal, fast and reproducible clusters. We use the algorithm to cluster previous daily spending and determine various classes of daily spending. An explanation of the use of the algorithm is provided in figure on the left.

The left panel of the figure shows the overall trend of daily spending, whereas, the right panel shows the univariate clustering of the same data. The significance of the right figure lies in the automatic estimation of the various levels of spending. Thus while the black circles show the low levels of daily spending, the black dashed line is the average level of low daily spending and is at ZAR 600. Following the same logic, the cyan colour rhombuses are the highest level of daily spending and its average is approximately at ZAR 900. In addition, the population of the symbols shows the relative concentration of an user’s daily spending. From  the right panel it seems that the user’s daily spending has increased over time. Thus, this feature can help a user to monitor his/her spending over time.


Feature – Prescriptive analytics using web-scrapping, GPS and GEOHASH codes – for promoting other businesses

This feature extracts GPS data of the application user at places where his/her card has been swiped. While the latitude and longitude provides the exact location of the transaction, GEOHASH’s can be used to easily find places close to one another or, in the same locality. Thus for example, two nearby places in Johannesburg, Linden and Auckland Park would have GEOHASH’s as ke7gkfp2fg and ke7gj1xg5u respectively. It might be noted that the first four characters of the two GEOHASH’s are exactly the same – hence, denoting that they are in vicinity of one another.

Aggregation of the name (refer column Business unit in Table 1) of the business units at which a user has swiped his/her card (over a period of several days) can provide an idea of his/her nature of transactions, things purchased, mode of entertainment etc. The figure below show a fictitious example of the users transactions at various kinds of business units over an estimated three weeks.

Figure: Percentage of times a user swiped his/her card at various business units over three weeks

Want To Be Ahead In The 4th Industrial Revolution?


Artificial Intelligence Group (AI Group) is a developer and marketer of AI and big data solutions company.

Big Data

Big Data is the proliferation of structured and unstructured data that floods your organization on a daily basis – and if managed well, it can deliver powerful insights.

Artificial Intelligence

Artificial Intelligence is the branch of computer science concerned with making computers behave like humans, i.e. with automation of intelligent behaviour.


Tell: +27 10 035 2335

150 Rivonia Road
South Africa

© Copyright Artificial Intelligence Group 2019

Close Menu