similarlywe do this for the prior probabilitiesaccounting for arithmetic underflows there is yet another roadblock in realitywe work with probabilities much smaller than the ones we have dealt with in the toy example in realitywe also have more than two featureswhich we multiply with each other this will quickly lead to the point where the accuracy provided by numpy does not suffice anymoreimport numpy as np np set_printoptions(precision= tell numpy to print out more digits (default is np array([ - ]array( - ]np array([ - ]array( ]sohow probable is it that we will ever hit number like - to answer thiswe just have to imagine likelihood for the conditional probabilities of and then multiply of them together (meaning that we have low probable feature valuesand you've been hit by the arithmetic underflowx= ** still fine - ** ouch float in python is typically implemented using double in to find out whether it is the case for your platformyou can check it as followsimport sys sys float_info sys float_info(max= + max_exp= max_ exp= min= - min_exp=- min_ _exp=- dig= mant_dig= epsilon= - radix= rounds= to mitigate thisyou could switch to math libraries such as mpmath (google com/ /mpmath/that allow arbitrary accuracy howeverthey are not fast enough to work as numpy replacement