[#10] Rules and ML
Does machine learning replace rules or can they work together?
In this (relatively) new world of AI and machine learning, there is sometimes confusion as to where machine learning can, not just be applied, but produce significant gains for an organization or for consumers.
This is important because machine learning is not necessarily the answer for everything, and even when machine learning can be useful, there are different ways to apply machine learning.
So, what were companies using before machine learning became so popular?
In some cases where ML is used today, previously a system using a hard-coded set of rules was employed. Some believe ML should completely replace rules-based systems, but maybe there are still places where direct human insight can be beneficial, or even necessary.
There is a useful blog post on this topic, written by Neal Lathia, Director of Machine Learning at Monzo, who also has a PhD in recommender systems. He makes the point that instead of narrowly focusing on replacing all rules-based systems with ML, one needs to focus on how ML can “improve the outcomes of the entire system.” Moreover, “if you can write a rule set that captures everything you need, then you don’t need machine learning!”
There are cases where ML can actually enhance, instead of fully replace, rules-based systems. First, ML can be used to help design the rules. For example, an ML algorithm can be trained to predict a particular outcome, using whichever features are available. Then, one can look at which features were given the most weight by the model and use this information to design a rule, or set of rules.
Alternatively, one can use ML in conjunction with rules as part of the same system. For example, if there is a case that does not fit any of the hard-coded rules, then this case can be sent to an ML algorithm that will make a decision instead.
I recommend reading the whole post, but the main takeaway here is that while ML can be immensely useful in many cases, there are still times that hard-coded human decisions are needed and, perhaps more interestingly, there are really useful ways that ML and rules set by humans can be used together to achieve the best result for a given system.
For more recommendations on when to use rules versus ML, see this article by an engineer at Capital One.
As many data scientists, including myself, are using Python, I will occasionally include some tips and tricks or interesting packages to share.
Do you use
range() when writing your
for loops? If so, check out the
enumerate function, which gives you access to both the index and the value on each iteration of the loop:
for index, element in enumerate(some_list_or_array):
See this article on Medium for more.
References and Notes
 Neal Lathia's Blog Post - https://nlathia.github.io/2020/10/ML-and-rule-engines.html
 Capital One Tech Article - https://medium.com/capital-one-tech/a-modern-dilemma-when-to-use-rules-vs-machine-learning-61cc908769b0