Loading [MathJax]/jax/output/HTML-CSS/fonts/TeX/fontdata.js

Estimating Probabilities from data

previous
next
back

Remember that the Bayes Optimal classifier: "all we needed was" P(Y|X). Most of supervised learning can be viewed as estimating P(X,Y).

There are two cases of supervised learning:
Some machine learning algorithms (e.g. kNN) do not estimate P(Y|X) but only the function f(x)=argmaxyP(Y=y|x). This is also considered discriminative learning. Not estimating the probabilities can provide some flexibility in terms of what approach is used, but one loses the advantage of knowing probability estimates of the labels and may not have a good reading on the certainty of a prediction.

So, how can we estimate probabilities from data?
There are many ways to estimate probabilities from data.

Simple scenario: coin toss

Suppose you find a coin and it's ancient and very valuable. Naturally, you ask yourself, "What is the probability that it comes up heads when I toss it?" You toss it n=10 times and get results: H,T,T,H,H,H,T,T,T,T. What is P(H)?

We observed nH heads and nT tails. So, intuitively, P(H)nHnH+nT=0.4 Can we derive this formally?

Maximum Likelihood Estimation (MLE)

Let P(H)=θ. θ, however, is unknown and all we have is D (sequence of heads and tails). So, what we can do to estimate θ is to choose its value such that the data is most likely.

MLE Principle: Find ˆθ to maximize the likelihood of the data, P(Dθ):
ˆθMLE=argmaxθP(Dθ)

For the sequence of coin flips we can use the binomial distribution to model P(Dθ): P(Dθ)=(nH+nTnH)θnH(1θ)nT Now, ˆθMLE=argmaxθ(nH+nTnH)θnH(1θ)nT=argmaxθlog(nH+nTnH)+nHlog(θ)+nTlog(1θ)=argmaxθnHlog(θ)+nTlog(1θ) We can now solve for θ by taking the derivative and equating it to zero. This results in nHθ=nT1θnHnHθ=nTθθ=nHnH+nT

Check: 1θ0 (no constraints necessary)

For example, suppose you observe H,H,H,H,H. What is ˆθMLE?

Simple scenario: coin toss with prior knowledge

Assume you have a hunch that θ is close to θ=0.5. But your sample size is small, so you don't trust your estimate.

Simple fix: Add m imaginery throws that would result in θ (e.g. θ=0.5). Add m Heads and m Tails to your data. ˆθ=nH+mnH+nT+2m For large n, this is an insignificant change. For small n, it incorporates your "prior belief" about what θ should be.

Can we derive this formally?

The Bayesian Way

Model θ as a random variable, drawn from a distribution P(θ). Note that θ is not a random variable associated with an event in a sample space. In frequentist statistics, this is forbidden. In Bayesian statistics, this is allowed.
Now, we can look at P(θD)=P(Dθ)P(θ)P(D) (recall Bayes Rule!), where

Now, we can use the Beta distribution to model P(θ): P(θ)=θα1(1θ)β1B(α,β) where B(α,β)=Γ(α)Γ(β)Γ(α+β) is the normalization constant. Note that here we only need a distribution over a binary random variable. The multivariate generalization of the Beta distribution is the Dirichlet distribution.

Why using the Beta distribution? P(θD)P(Dθ)P(θ)θnH+α1(1θ)nT+β1 Note taht in general θ are the parameters of our model. For the coin flipping scenario θ=P(H).
So far, we have a distribution over θ. How can we get an estimate for θ?

Maximum a Posteriori Probability Estimation (MAP)

For example, we can choose ˆθ to be the most likely θ given the data.
MAP Principle: Find ˆθ that maximizes the posterior distribution P(θD): ˆθMAP=argmaxθP(θD)=argmaxθlogP(Dθ)+logP(θ) For out coin flipping scenario, we get: ˆθMAP=argmaxθP(θ|Data)=argmaxθP(Data|θ)P(θ)P(Data)(By Bayes rule)=argmaxθlog(P(Data|θ))+log(P(θ))=argmaxθnHlog(θ)+nTlog(1θ)+(α1)log(θ)+(β1)log(1θ)=argmaxθ(nH+α1)log(θ)+(nT+β1)log(1θ)ˆθMAP=nH+α1nH+nT+β+α2

"True" Bayesian approach

Note that MAP is only one way to get an estimator for θ. There is much more information in P(θD). So, instead of the maximum as we did with MAP, we can use the posterior mean (end even its variance). ˆθpost_mean=E[θ,D]=θθP(θD)dθ For coin flipping, this can be computed as ˆθpost_mean=nH+αnH+α+nT+β.

Posterior Predictive Distribution

To make predictions using θ in our coin tossing example, we can use P(headsD)=θP(heads,θD)dθ=θP(headsθ,D)P(θD)dθ=θθP(θD)dθ Here, we used the fact that we defined P(heads)=θ and that P(heads)=P(headsD,θ) (this is only the case for coin flipping - not in general).

In general, the posterior predictive distribution is P(YD,X)=θP(Y,θD,X)dθ=θP(Yθ,D,X)P(θ|D)dθ Unfortunately, the above is generally intractable in closed form and sampling techniques, such as Monte Carlo approximations, are used to approximate the distribution.

Machine Learning and estimation

In supervised Machine learning you are provided with training data D. You use this data to train a model, represented by its parameters θ. With this model you want to make predictions on a test point xt.