Operations Research and Machine Learning

Reliable OR development. Testing with Hypothesis

| |

Sometimes you start with a simple optimization model, and then you are asked to add more and more features and constraints. Sometimes you venture into complicated modeling from the very beginning when it is not always even clear how different constraints will interact with each other.

But in any case, you want to make sure that your model is correct, that your solution satisfies customer requirements with any valid data input. How? Obviously by testing it. However usual unit-testing approach will most likely fail here.

Hypothesis_idea

In this article, we talk about an efficient and simple way to test optimization models, which was introduced to me by my colleague Torsten. More specifically, I will talk about the Hypothesis framework which can be used for any type of code, and exceptionally well fits Operations Research testing needs. Let’s start!

Budget @HOME. Make it work

| |

Only last step is left: to combine all the components in one Jupyter notebook based app. We would like to have it interactive, and in this part, we will see how we can do that in Jupyter. It allows to quickly prototype a simplistic interface and also showcases a nice type of notebooks, which you can share with your stakeholders, without them running away from the look of all the python code.

Budget @HOME. Optimization model

| |

In this part, we create the “business logic” of our basic app. We would like to retroactively analyze our past spendings and to select transactions, which we need to cut in order to achieve a certain savings level. Under the hood, we will have a small optimization problem, which we solve with an open-source solver. Note, that this problem can be solved in multiple ways, and probably one can write a simple deterministic algorithm to find the optimal solution. However, our usage of MIP solver makes the approach extendable: we can easily add additional rules for optimization without making major changes to the algorithm. Let’s take a look!

Budget @HOME. Data Visualization

| |

In this part we visualize bank transactions data, aiming to get an idea

  • Types of expenses and there share
  • Savings trends
  • Expenses by months and types Just to understand what do we spend money on, and where is potential for savings.

Budget @HOME. Data Preparation

| |



Not only Machine Learning, but also Operations Research projects quite often start with the data preparation step. In this part, we explore our bank account data, prepare it and deal with the transaction classification.

This sunburst chart from plotly library is a sneak preview from the visualization part of this post series. Our task, for now, is to prepare data, in order to allow such type of visualizations and data explorations through plotting libraries.