# Problem with two layers: how to predict?

Let me get straigt into it:

Think of an scheduled operation. There is a surgeon and, say, three other medical personel that carry out various tasks. For instance, a nurse, an anesthesiologist, and a backup.

Each one reports to duty at a certain time. However, with some probability p (to be predicted) one or many member(s) of the team won't show up for work. If an individual does not show up for work, but his particular skill set is still covered due to the backup, then the operation is done. Otherwise, it is cancelled. For instance, if the backup is a certified anesthesiologist, absence of the scheduled anesthesiologist does not prevent the surgery from taking place since a minimum required skill mix is given. If, however, the backup is a nurse, and the anesthesiologist does not show up, then the surgery has to be cancelled.

This problem involves two layers:

1. Does an individual team member show up for work?
2. Is an individual team member's skill critical for the execution of the surgery.

My goal is to predict cancellation of the surgery, which involves step 1 and step 2 simulataneously (alternatively, you could think of step 2 being conditional on step 1).

I have a good understanding of how to use standard machine learning algorithms to predict 1. But how do I generate final predictions taking both layers into account? The problem set up seems reasonably general so that I would assume there exists a "standard" method?

This problem is best addressed with discrete-event, stochastic simulation modeling. The prediction you get from such a model is a probability distribution on the surgery being canceled.

It's easy to code up such a model given your problem statement. You need:

• A boolean function for each kind of surgery, which, given the cast of characters and skill sets as input, determines True/False if the surgery can proceed.
• A probability distribution for the appearance of each kind of character, when scheduled.
• An object which is initialized with the schedule.

The idea is to do this check (surgery/surgery canceled) many times, thereby growing a set of outcomes for each policy you wish to explore.

If you don't want to roll your own, there are packages for many languages such as SimPy for Python and Simmer for R.

The nice thing about discrete event simulation is that you don't need to make any simplifying assumptions about probabilities, and the business logic can be arbitrarily complex. For example, if the surgeon and one of the nurses are having an affair, the chance that one cancels on the same day as the other can be increased.