Add Machine Learning to Legacy Applications with Python

Add Machine Learning to Legacy Applications with Python

These days, it seems like Machine Learning (ML) is everywhere. Well, everywhere except in legacy applications. But you can hardly blame the application if it was created prior to the recent advances in Python that have made ML mainstream (i.e. the last 3-5 years). Unfortunately, rewriting or refactoring legacy applications is typically a cost-prohibitive non-starter. But if you don’t modernize older applications by adding capabilities like ML, your customers will sooner or later stop using them.

Certainly, the market is now full of established analytics and reporting applications that are all making the leap to include some kind of AI/ML functionality in order to avoid becoming obsolete. After all, ML thrives on data, so baking it into the foundations of data analysis in the enterprise just makes sense. Every application has someplace to store/some way to leverage data. And all of these applications could  apply ML to that data in order to discover insights, create new business opportunities, or just accomplish a task faster, better, or maybe for the first time ever.

For example:

  • Insurance – ML is allowing insurance companies to mine their abundant claims data in order to automate underwriting and claims adjustment.
  • Banking & Finance – ML allows banks to combine a customer’s online banking behaviour with social media data in order to better understand and make predictions about the customer’s financial needs.
  • Healthcare – using ML to study disease progression from clinical data allows doctors to better predict death dates for patients with terminal illnesses, and ensure that palliative care can be provided in a timely manner.


Legacy Modernization with Python

Each of these industries (and many more) have benefited by extending their legacy applications to enable ML capabilities. But when it comes to updating legacy apps, there are many different approaches. API wrapping (aka encapsulation) is the simplest, most cost-effective way to modernize older applications, making them far more usable with minimal effort. Figure 1. Below shows that encapsulation (API wrapping) has the lowest complexity and cost.

Figure 1: Legacy Modernization Approaches (area of rectangle correlates to effort)

API wrapping creates a new interface for older applications, making them readily accessible by other applications and software components. Additionally, minimal code changes are required, which means less risk when compared to re-architecting or rebuilding an application from scratch. Scripting languages in general are a good choice for API wrapping (Tcl comes to mind). But, if the goal is to add ML capabilities, Python is the best choice, and with its growing popularity and ability to find skilled talent, some might say, the only choice.

Key Benefits:

  1. Python is at the forefront of advances in machine learning.
  2. Python has a well designed C API, which makes it ideally suited to extend or embed in applications written in C or C++.
  3. Python is simple to learn and use for your own developers, but can also be readily adopted by your customer base, as well.


Wrapping Applications with Python

If you’re ready to make the leap and extend your application with Python’s ML capabilities, you’ll need to consider at least the following three steps:

  1. If you want to incorporate extensible ML capabilities within your application, you’ll need to embed a Python runtime environment into your existing code base, where the runtime includes the base Python language plus any third-party (i.e., PyPI) packages required, as well as the Python interpreter.
    • Alternatively, you may just want to open up an extension point in your application in order to allow it to be customised by your customers using their own ML routines. In this case, you can embed the Python interpreter inside your application with just a few lines of code.
  2. Wrap your existing C/C++ code with Python. You can find any number of tutorials online detailing the basics of how to accomplish this, such as Wrapping C/C++ for Python.
  3. Expose and document the new Python API so your customers can more easily extend your application’s functionality to accommodate their use case. At the very least, your customers will likely want to retrain any model you ship using their data.


OEM’ing Python

Lastly, you’ll want to consider how Python gets deployed on premise. Some companies still require customers to download, install and maintain their own version of Python for use with their application. This can be problematic for a number of reasons, not least of which is support costs that invariably increase due to poor Python installations that result in system conflicts, dependency mismatches, and other issues.

Instead, consider purchasing a commercial OEM license for Python and embedding it within your application’s installer to ensure consistent deployment at customer sites.

  • For more information on ActiveState’s OEM offering, refer to our OEM datasheet
  • For a case study on how one customer has gained advantages in their marketplace by adding ML capabilities to their legacy application, read the Mentor Case Study

Recent Posts

Scroll to Top