官术网_书友最值得收藏!

Bayes' rule for conditional probability

Bayes' rule is another essential tenet of probability theory in the machine learning sphere. It allows us to calculate the conditional probability of an event happening by inverting the conditions of the events. Bayes' rule is formally written as:

Let's use Bayes' rule to look at a simple conditional probability problem. In the following table, we see the likelihood of a patient contacting a disease:

How do we interpret this table? The axis tells us the percentage of the population who have the disease; if you have it, you are firmly in the Disease column. Based on that condition, the axis is the likelihood of you testing positive or negative, based on whether you actually have the disease or not.

Now, let's say that we have a positive test result; what is the chance that we actually have the disease? We can use Bayes' formula to figure solve:

Our answer comes out to 7.8%, the actual probability of having the disease given a positive test:

In the following code, we can see how Bayes' formula can model these conditional events based on likelihood. In machine learning and AI in general, this comes in handy when modeling situations or perhaps classifying objects. Conditional probability problems also play into discriminative models, which we will discuss in our section on Generative adversarial networks:

.p_diseasePos = 0.8 ## Chance of having the disease given a positive result
p_diseaseNeg = 0.2 ## Chance of having the disease given a negative result
p_noPos = 0.096
p_noNeg = 0.904
p_FalsePos = (.80 * .01) + (.096 * .99)
p_disease_given_pos = (.80 * .01) / p_FalsePos
print(p_disease_given_pos)

Remember: when conducting multiplication, the type of operation matters. We can use the Hadamard product to multiply two equally-sized vectors or matrices where the output will be another equally-sized vector or matrix. We use the dot product in situations where we need a single number as an output. The dot product is essential in machine learning and deep learning; with neural networks, inputs are passed to each layer as a matrix or vector, and these are then multiplied with another matrix of weights, which forms the core of basic network operations. 

Probability distributions and the computations based on them rely on Bayesian thinking in the machine learning realm. As we'll see in later chapters, some of the most innovative networks in AI directly rely on these distributions and the core concepts of Baye's theorem. Recall that there are two primary forms of probability distribution: PMFs for discrete variables, and probability density functions PDFs for continuous variables; CDF, which apply to any random variables, also exist.

Baye's rule, in fact, has inspired an entire branch of statistics known as Bayesian statistics. Thus far, we have discussed frequent statistics, which measure probability based on an observed space of repeatable eventsBayesian probability, on the other hand, measures degrees of belief; how likely is an event to happen based on the information that is currently available? This will become important as we delve into ANNs in the following chapters.

主站蜘蛛池模板: 京山县| 南岸区| 榆社县| 巧家县| 荥经县| 涪陵区| 衡阳市| 衡阳市| 大连市| 昆明市| 鄂伦春自治旗| 肇州县| 大关县| 稻城县| 上杭县| 疏附县| 农安县| 格尔木市| 古丈县| 突泉县| 越西县| 铁岭市| 汉源县| 清水河县| 颍上县| 岗巴县| 刚察县| 满城县| 罗山县| 炉霍县| 化德县| 三门县| 彭阳县| 澎湖县| 克东县| 额尔古纳市| 枣阳市| 青神县| 东丽区| 共和县| 崇左市|