The potential of Machine Learning with the Axon Framework

by Halleh KhosnevisSeptember 20, 2018

Machine Learning creates lots of value in the business processes, if and when applied properly and the right data is available. These days a lot of data is already held within organisations. It is common to see this data unused, with possibilities and insights unseen. While it can be due to limitations of modelling and pattern recognition, we often see practical problems with data quality and availability setting the actual limit. In the recent years, development in this area has increased drastically, and with it, the possibilities!

Axon is a popular lightweight framework used by a growing number of companies which enables you to apply sound architectural principles like DDD, event sourcing and CQRS, and helps you to build less complex and better maintainable applications.

Using these principles, the Axon Framework promises scalability, agility and smooth integration with external systems. As a side effect, they also provide a reliable trail of events leading to a system state. By storing these in an event store, it enables perfect auditing capabilities for the past. This same detailed data also enables you to apply Machine Learning techniques to look forward and get precise predictions of the future

Organisations with all kinds of challenges and optimisation issues now have the opportunity to Forecast user interest and prevent churn, detect fraud right when it happens, and to cluster information to significantly improve recommendations.

Three main principles of Axon is aggregates, repositories and events.

An aggregate is an entity or group of entities that are always kept in a consistent state. For example, a “Contact” aggregate could contain two entities: Name and Address.

A repository is the mechanism that provides access to aggregates. There are two kinds of repositories, ones that save the current state of the aggregate and those that store the events of an aggregate (the Event Store).

An event is anything that has happened in the sense of business. For example, the action of creating a contact in an address book, would result in an event. Importantly, updating this contact, would also result in an event

When developing scalable applications, Axon helps you to focus on business logic. When the business logic changes over time, the original events are not touched but an upcaster maps the new understanding of the world on events before they are pushed to event listeners.

Imagine now, we can use all the events that have happened and stored in the Event Store, for different purposes.

Time series forecasting

Time series forecasting is an important area of Machine Learning which can solve many prediction problems that involve a time component. The dataset for the time series forecasting is a sequence of observations taken sequentially in time, and the goal is to eventually forecast the future values of a series based on this historical dataset. Considering the fact that all the events stored in the Event Store have the time component, we can leverage from the core structure of the Event Store in the Axon Framework and forecast the next trend or predict the next action.

A concrete use-case could be tracking the behaviour of a user on a web-shop, and finding out what actions leads to the purchase an item

Anomaly detection

Another example can be anomaly detection which is a technique used to identify unusual patterns that do not conform to the expected behaviour. It has many applications in business, such as intrusion detection in network traffic, spotting a tumor in an MRI scan, fraud detection in bank transactions and fault detection in operating environments.

Thanks to the Axon Framework, all the events that have been stored in the Event Store collectively help us in detecting what is normal, and hence what is an anomaly. An example use case could be analysing the events from an authentication system, and flagging when someone fails to login too many times, or has attempts from many different IPs.

Better ML Models

We can benefit from the rich and structured data stored in the payload of each event. High quality, structured data, plays a major role in the validity and accuracy of the Machine Learning models generated to solve a business problem.

In the Axon Framework, each event contains a payload which is the data being used in the event. By querying the collection of data related to events, we are able to create a rich dataset of the event’s data which enables us to make a relevant Machine Learning models.

For instance, we could query all the prescriptions which have been given to the patients with dementia. With that information, we were able to generate the next prescription for the patients with similar issues. Basically, we found that it was straightforward to start applying Machine Learning models for recommendation, prediction and recognition on the data stored in terms of events.

Integration

Since our models are based directly on the events that the system generates, it is easy to integrate them and start providing real business value. Examples of integrations would be providing live recommendations, alerting and in general helping decision making. With Axons focus on easy integration, we can even enable the models to take actual decisions.

Conclusion

These examples lead to the conclusion that events from a system built around the Axon Framework are a perfect starting point for Machine Learning. Of course, we have a precondition for business value: Understanding the business challenges and being able to integrate the ML solution within the Business processes is paramount to success. If these preconditions are met, applying ML techniques to Axon based systems provide real valuable insights and optimisation possibilities, helping you to solve advanced business challenges.

 

More information about Machine Learning on Axon can be found here: https://trifork.com/ml4axon/