Combining rule-systems and machine learning

I was recently reading an article by Neal Lathia about how using machine learning is not always necessarily better than using rule-based systems. There are pros and cons to taking either approach, and you should take the one which suits the problem complexity, expected execution speed, and various other factors the best.


I am working on a project which I and my team believe is a great fit for applying ML techniques. However, we have also achieved some measure of success in achieving our goals using a rule-based system. Without sharing the details, I can say that while we have a long way to go, one thing that is increasingly clear is that rule-based and AI/ML-based approaches to building systems are not mutually exclusive. There are various ways in which these can be applied together effectively. I want to discuss some of these ideas. 

The thing to remember is that every system is made up of many parts and each of them serves a different function. Most parts are simple and require little to no intelligence in the machine learning sense. So it only makes sense to slice the problem and the overall system into smaller parts and apply the technique most suited to it. The parts that require inferences made from lots of data can be built using machine learning techniques, and other parts can be built using rules or plain old application engineering.

In fact, acknowledging that these two types of parts exist in a system can have a dramatic impact on the architecture and technology choices being made. 

Rule System output as ML feature

Machine Learning models work on sets of inputs called features. Features might already exist as first-class artifacts in some data store, or as is often the case, they are attributes derived from multiple other data points of the system. These derivations are often built using simple rules or heuristics and then consumed by ML models. Both steps of the process operate independently but play an important role in the final outcome.

Think of this as lower-level staff processing raw information into reports that can be consumed by upper management to make complex decisions.

ML Model output as input to rule engine

The inverse of the above process is also common. We can have ML models use various features to come to a conclusion which is then used as one of the inputs to a rule-based system. This again works by splicing a complicated into two parts – the more intelligent/complex part uses ML to process complex data patterns. Once the data is reduced to a simple conclusion, the rule-based system can jump in to make further, simpler decisions.

Think of this as upper management passing down the results of complex strategic analysis where the lower layer can make comparatively simpler decisions about how to execute things.

Rules as elements of AI

This last pattern of combining rule and AI/ML is especially fascinating for me because it blurs the lines of what is simple and what is complex. 

A whole class of AI-based systems called Learning Classifier Systems (probably others too, I’m no expert) use rules as the building blocks of complex evolutionary hierarchies where rules mutate and evolve in such a way that we finally end up with rules that best fit the given application environment. 

This is a complex way of applying either model but it shows that there is sufficient common ground between them.

Think of this as a brainstorming session with all levels of the company (autonomous team? 5 person startup?) where simple ideas are churned around till strategies and execution plans emerge together.


Since this is a real-life problem for me at work, I want to hear what you think about it and if you have used such a combination with good results. Drop a note in the comments section with your experiences.

Read Next: What does this decade’s full stack team look like?

If you liked this, subscribe to my weekly newsletter It Depends to read about software engineering and technical leadership

3 thoughts on “Combining rule-systems and machine learning”

  1. Pingback: Learning

Leave a Reply