Generativity #438

Machines That Learn:
Differential Diagnosis and Botanical Insights

     Certain words have particular probabilities of occurring in a spam email versus a legitimate email. For instance, most email users will eventually receive an email from a diplomat or princess asking for a small donation guaranteed to let loose the flood-gates of embezzled riches, a common event in spam email, but seldom seen in other emails. To me this begs the question of just how a princess or diplomat manages to use email, but that is a question for their respective internet service providers to answer. Maybe they just have other people do it for them.

     In this column we’ll be exploring artificial intelligence (AI) modules from the Comprehensive Perl Archive Network (CPAN), a great resource for legally appropriating very useful tools made by people far better at this than me. One of their featured machine learning modules is also one of the simplest. It’s called the Naive Bayes algorithm.

     The Naive Bayes algorithm is what is known as a classifier-type algorithm. You’d probably know it best as the mechanism by which your email program decides whether to show you an email or just shunt it to your junk mail folder. It has a memory comprised of training data (classes of things, in this case words, that either define spam or not); and based on what criteria it is presented with (in this case the email in question), it calculates a probability (odds) that it is spam. If that number is high enough, off it goes to the junk folder.

     The algorithm earned this name because it is based on a type of probability known as Bayesian, named after the Reverend Thomas Bayes, an early math nerd who came up with it while trying to use probability to prove the existence of God.

     The Naïve Bayes algorithm is based on Bayes Theorem for calculating probabilities and conditional probabilities. The algorithm is naive because the events it models are independent; the occurrence of one event does not affect the probability of the occurrence of another. We make it initially ‘smart’ by supplying it with training data: a model of the known stuff about the world that the algorithm can learn from and make predictions on.

     Bayes Theorem describes the probability of an event, based on prior knowledge of conditions that might be related to the event. For example, if osteoporosis is related to age, then a person’s age can be used to more accurately assess the probability that they have osteoporosis, compared to an assessment made without knowing the person’s age. Bayes Theorem is a tool that converts human belief, based on evidence, into predictions.

Bayes Theorem is commonly expressed as the formula:

     With Bayes Theorem we can use the probability of one thing to predict the probability of another thing. And because of this, Bayes Theorem has become one of the great statistical sausage machines that scientists can ratchet-up to make better predictions as new evidence surfaces. Although it hasn’t proved the existence of God, Bayes Theorem has proved useful in other ways: from testing new medicines, to weather forecasting, and even helping to improve mobile-phone reception.

Differential Diagnosis

     If you hear the sound of hoofs, don’t expect to see zebras. Unless, of course, zebras be nearby. As most of the readers know, differential diagnosis (DDx) is a method used to identify the presence of a disease entity where multiple alternatives are possible. Evidence suggests that the association between physicians’ diagnostic accuracy and their confidence in that accuracy may be quite poor.1 The likelihood of an accurate DDx is dependent on inclusion of candidate conditions that are responsible for as large part as possible of the probability of having developed the condition. If an important candidate condition is missed, no method of differential diagnosis will supply the correct conclusion.

     With this in mind, I coded DDx Pinpointer, a Perl script that uses the Naive Bayes machine learning algorithm to classify possible candidate conditions based on a training dataset of weighted symptomatology data that I’d previously extracted from PubMed (Medical Subject Headings) MeSH datasets (https://www.ncbi.nlm.nih.gov/mesh)

     To run DDx Pinpointer, fire up your favorite browser and point it to https://www.datapunk.net/tlfd/bayes_ddx.
Don’t worry, I’ll wait.
You’re back?
Good!

     You are presented with a query screen (Figure 1):

     Using the scrollable window on the left, simply tick off a few favorite symptoms, and optionally give them some ‘weight’ (weight would correspond to symptom severity in an actual patient). To factor in occurrence data, (puts emphasis on more common presentations) tick the ‘Factor Occurrence’ checkbox. Don’t remember what ‘Drug-Induced Akathisia’ is? Then click on any hyperlinked symptom to trigger a small descriptive popup. We’ll tick ‘Constipation,’ ‘Abdominal Pain,’ and ‘Nausea.’ When ready, pressing the Run DDxPinpointer button will take you to the results screen.

     Figure 2 shows the probable diagnostic considerations rated from highest to lowest probability. ‘Intestinal Obstruction’ comes in at number one, which sort of makes sense; followed by the somewhat unhelpful ‘Gastrointestinal Diseases,’ ‘Irritable Bowel Syndrome,’ ‘Colonic Neoplasms,’ and then everything else. To my way of thinking it is the ‘Everything Else’ that will be most helpful to the clinician in real-time, the stuff we just don’t think of at the time – the weirdo rule-outs.

     Figure 3 provides an additional deep-dive for those interested in genomic/molecular links to pathology. If desired, you can tick off a few of the winning diseases and the app will respond with a probability-based guess at what genes/ molecules are likely to be of interest. It’s just an illustration of the power of bioinformatic mash-ups: taking disparate data and making them play together.

Bayes’ Leaf

     Recently, I was in the applications directory of my Mac and saw an icon for an app called Bountiful Herbs (https://www.bountifulherbs.net/) that I must have downloaded years ago. Clicking on it I discovered a fairly robust herbal database that had enough weighed information to provide some good training data. The program allowed for the export of data; and after massaging it so much that I could probably get a certificate from the Swedish Institute, I was able to feed it into the Perl Naive Bayes module.

     Since you’re already on the website, to fire up the Phyto Pinpointer, just select it from the TLfD Tools pull-down menu on the bar at the top of the page (Figure 4).

     With Phyto Pinpointer, you select a combination of desired medicinal actions you want to explore, and the program will use Reverend Bayes’ algorithm to return a graduated list of botanicals that probability-wise best fit those selected actions. For each selection you can optionally add an indication ‘strength’ (a weighted value of just how important that particular action should factor in the overall classification).

     For example, if I select the actions ‘Alterative’, ‘Anodyne’ (mild) and ‘Anti-rheumatic while also setting the strength of ‘Anti-rheumatic to ‘strong’ when I press the Pinpoint button, the script returns with results (Figure 5). In this case, Phyto Pinpointer responds with three very good suggestions (Smilax spp., Harpagophytum procumbens and Phytolacca Americana).

     Like all machine-learning algorithms, what makes the Naive Bayes algorithm so powerful is its ability to gauge the probability for submitted groups of criteria that do not have an exact representation in the training data. That is the big difference between encyclopedia-type lookups and AI. The first can only retrieve what it knows, the second can make a pretty good guess about what it doesn’t.

     I’m not a big herbal energetics guy, but, hey, data is data; and these often factor in traditional medical type prescribing, so I added the ability to weave this type of criteria into the AI training knowledge set. You can choose both an ‘energetics’ and a ‘taste’ setting and give it some weight as well.

     All in all, I’m pleased and somewhat surprised at just how perceptive and useful these simple machine learning apps are. The Naive Bayes algorithm has numerous applications in medical AI, so future applications are essentially endless, given the appropriate training data. For example, I’ll probably do a future column on how AI can help clinicians predict the odds of specific Phase I detoxification compromise, based on published cytochrome interactions and specific client polymorphisms. In a world of patients increasingly characterized by an intake of multiple drugs, supplements, herbs and foods, this type of vigilance is essential to the practice of safe medicine.

Reference

1.    Meyer AN, et al. Physicians’ diagnostic accuracy, confidence, and resource requests: a vignette study. JAMA Intern Med. 2013 Nov 25;173(21):1952‑8.

Peter D’Adamo is a distinguished professor of clinical medicine at the University of Bridgeport School of Naturopathic Medicine. His New York Times bestselling books have sold over 8 million copies and have been translated into over 75 languages. He is the developer of the acclaimed Opus23 genomic software suite and a variety of other generative apps that can be explored at www.datapunk.net
In his spare time, he brings old VW Beetles back to life
at his garage on www.kdf20.com.