电竞比分网-中国电竞赛事及体育赛事平台

分享

用正態(tài)分布理解貝葉斯線性回歸和高斯過程

 家有仙妻寶寶 2022-04-03

在上一篇文章中,我們學習了機器學習 (ML) 的核心正態(tài)分布屬性。在這里,我們將運用我們的知識來操縱正態(tài)分布來解決棘手的貝葉斯推理。我們將用貝葉斯線性回歸和高斯過程來證明它。我們還將通過一些證明來應(yīng)用我們所學的知識。但是我們假設(shè)您已經(jīng)閱讀了上一篇文章,如果您還沒有閱讀,請閱讀。

文章圖片2

貝葉斯線性回歸

貝葉斯線性回歸利用了正態(tài)分布運算的“便利性”,解析地解決了回歸問題。

對于樣本大小為n且每個數(shù)據(jù)點具有m個特征的數(shù)據(jù)集,貝葉斯線性回歸定義為

文章圖片3

并且先驗參數(shù)θ和誤差ε都被假設(shè) 為正態(tài)分布。

文章圖片4

后部

在處理正態(tài)分布時,如果結(jié)果是概率分布,我們可以專注于合并這些正態(tài)分布而忽略任何縮放因子。我們可以專注于尋找得到的正態(tài)分布的參數(shù)。這里,后驗等于

文章圖片5

即后驗是

文章圖片6

后驗預(yù)測分布

為了計算貝葉斯推理中的后驗預(yù)測分布,我們將后驗整合到模型的所有可能值θ上。

文章圖片7

這種整合通常是棘手的。在貝葉斯線性回歸中,似然是高斯函數(shù)的形式。

文章圖片8

因此,我們可以利用正態(tài)分布特性更容易地計算后驗預(yù)測分布?;叵胍幌拢惾~斯回歸模型定義為

文章圖片9

并且正態(tài)分布的線性變換規(guī)則是。

文章圖片10

讓我們將A替換為x*并將x替換為θ,我們得到

文章圖片11

應(yīng)用求和規(guī)則來解釋貝葉斯回歸方程中的 ε

文章圖片12

后驗預(yù)測分布變?yōu)?/span>

文章圖片13

把所有東西放在一起,后驗預(yù)測分布是

文章圖片14

此分布的平均值是給定x * 的y * 的點估計。

接下來,我們將討論探索數(shù)據(jù)點與正態(tài)分布之間關(guān)系的高斯過程。

高斯過程 (GP)

讓我們快速了解一下 GP 可以做什么。高斯過程 (GP) 的分布是函數(shù)上的分布。這是什么意思?給定訓練數(shù)據(jù)集D = {( x ?, y ?), ( x ?, y ?), ( x ?, y ?), ( x ?, y ?)},下面的函數(shù)f完全適合D。

文章圖片15

但是貝葉斯永遠不會安定于點估計!事實上,有無數(shù)的函數(shù)可以精確地擬合這些數(shù)據(jù)點。但是某些功能比其他功能更有可能。例如,下面的函數(shù)f 2似乎比其他函數(shù)更有可能,因為它為適應(yīng)數(shù)據(jù)所做的曲線變化較少。對于???,他們將使用最似然估計 (MLE) 為我們提供最終回歸模型。但是對于貝葉斯主義者,他們模擬了所有的可能性。為了演示,我們可以從 GP 中反復(fù)采樣,繪制出貝葉斯預(yù)測的函數(shù)。

文章圖片16

GP是一個生成模型。它生成適合的函數(shù)(樣本)

  • 觀察結(jié)果,以及
  • 我們對數(shù)據(jù)如何相關(guān)以及它們的期望值(平均值)是多少的信念。
文章圖片17
文章圖片18

在 GP 回歸中,它預(yù)測給定x * 的y *的正態(tài)分布,即f ( x* ) 的概率密度函數(shù)。

文章圖片19

懶惰的會計師

讓我們快速瀏覽一個插圖。在每個季度的開始,會計師向 CEO 報告應(yīng)收賬款 (AR) 和應(yīng)付賬款 (AP) 之間的余額(余額 = AR 減去 AP)。在任何時間點,AR 都可能高于 AP,反之亦然。不幸的是,這家公司只能實現(xiàn)收支平衡,即平均而言,余額為零。

會計師退休了,一個聰明但懶惰的會計師保羅被聘用了。他沒有做他的工作,而是在下面創(chuàng)建了一個多元正態(tài)分布,并自動生成接下來 20 個月的余額。

文章圖片20

這種分布很有意義,因為預(yù)期值為 0。這是一個帶有未來 20 個月余額的單個樣本的圖。

文章圖片21

協(xié)方差矩陣 Σ 控制數(shù)據(jù)點的相關(guān)性。當數(shù)據(jù)點i與數(shù)據(jù)點j不相關(guān)時, Σ?? 等于 0 。如果它大于零,它們就是。Paul 選擇的 Σ 是數(shù)據(jù)點之間距離的指數(shù)函數(shù)。因此,相鄰月份之間的余額是相似的。s是復(fù)制天平范圍的比例因子。l是一個可調(diào)的超參數(shù)(又名內(nèi)核寬度)。較大的l,數(shù)據(jù)點會影響更遠的鄰居。從另一個角度來看,每個數(shù)據(jù)點都會受到更多鄰居的影響。因此,相應(yīng)的曲線會更平滑。

文章圖片22

資源

該方案非常成功,以至于 Paul 創(chuàng)建了一個新模型,并在接下來的 20 個月中每天對一個數(shù)據(jù)點進行采樣。

文章圖片23

The plotted graph is smooth and just looks like a function. So he calls his system a sampler of functions. Every sample is a sample of the function f.

文章圖片24

The CFO is impressed with the plot and asks him to redo the monthly balance for the last financial year. He cannot reuse the last function sampler anymore. It will not match the previous quarterly reports.

As discussed before, if we know a multivariate normal distribution, we can re-establish the probability distribution of the missing data given the observed one.

文章圖片25

As in this example, the probability distribution for x? given x?=2 is

文章圖片26

Paul realizes that too. If he knows f (the last 4 quarter balances), he can recreate the distribution of f* for the last 12 months. The first four entries in his new model are the reported balances at months 1, 4, 7, and 10 (every financial quarter). The next 12 entries (f*) represent the new curve for the last financial year.

文章圖片27

The diagram below plots one of the functions sampled.

文章圖片28

The original prior defines the mean and the covariance of the functions. It is our prior belief on the expectation value for f and how data are correlated. Given the observations (the four balances), the posterior enforces the constraints that any sampled functions must cross the path at the red dots below.

文章圖片29

但有時,CEO 只對幾個數(shù)據(jù)點感興趣,例如第 60 天和第 280 天的余額。這可以通過以下新的多元正態(tài)分布來建模。它對預(yù)測特定輸入的輸出的函數(shù)f * 進行采樣。例如,f* 的一個可能樣本[ f* 1(125) = -0.2, f* 1(300) = 1.1])。

文章圖片30

還有一個重要的觀察。隨著我們進一步遠離紅點,f的方差增加。預(yù)測將有更廣泛的猜測和更低的確定性。簡而言之,隨著我們遠離已知數(shù)據(jù)點,預(yù)測的不確定性會增加。

全科醫(yī)生定義

高斯過程是函數(shù)的正態(tài)分布。每個 GP 由平均函數(shù)m (x) 和協(xié)方差函數(shù)κ (x, x') 定義。κ模擬f (x) 和f (x')之間的協(xié)方差(相關(guān)性)。

文章圖片31

Paul將m (x) 設(shè)計為 0 以反映預(yù)期的平衡。如果我們繼續(xù)采樣函數(shù),f 1(x), f 2(x), f 3(x), ... 的平均值接近m (x)。

Paul 使用高斯核對協(xié)方差函數(shù)進行建模。

文章圖片32

For any pair of x and x’, the sampled data points f(x) and f(x) form a bivariate normal distribution. As a simple demonstration, let’s have x’ equals x. As shown below, κ(x, x), the red curve, is normally distributed.

文章圖片33

How do we sample data from a GP? In particular, A function can be viewed as a collection of random variables f(x?), f(x?), f(x?), … For continuous functions, the number of random variables is unlimited. Therefore, it has infinite random variables and GP has an infinite dimension. In practice, we can focus on the k variables in interest, even k can be very large.

文章圖片34

Definition: A GP is a collection of random variables in which the joint distribution of every finite subset of random variables is multivariate normally distributed.

By taking advantage of this definition, we model a k-variate normal distribution from the joint distribution. For example, Paul creates the finite subset X = {x?, x?, x?, x?, …, x??} for the coming year report. It contains 12 random variables holding a balance for each month. Once the 12-variate normal distribution is defined, we sample values from this multivariate normal distribution to create sample functions.

文章圖片35

It starts with a prior belief from the designer on how data are related.

文章圖片36

Or in Paul’s mind, this is

文章圖片37

where

文章圖片38

Here are the two possible sample functions returned.

文章圖片39

Kernel function

協(xié)方差函數(shù)建模中流行的核函數(shù)之一是平方指數(shù)核

文章圖片40

其中s是比例因子。當x ? 和x ? 相距較遠時,k等于 0。如果它們相同,則等于 1。但是核函數(shù)有很多選擇。通過實驗,設(shè)計人員可以選擇一個對數(shù)據(jù)進行最佳建模的模型。

在矩陣代數(shù)中,矩陣K 半正定的,如果

協(xié)方差矩陣是半正定的。

文章圖片42

因此,核函數(shù)必須是半正定的。它也是對稱的 Cov( x , x ') = Cov( x ', x)。

后驗預(yù)測分布

后驗預(yù)測分布是關(guān)于在給定x * 和D的情況下找到f * 。

文章圖片43

后驗預(yù)測分布通常寫成

文章圖片44

文章圖片45

通過對多元正態(tài)分布應(yīng)用條件規(guī)則,均值向量和協(xié)方差矩陣為

文章圖片46

這就是無噪聲高斯過程回歸。

為了考慮信息中的噪聲,我們將預(yù)測公式化為

文章圖片47

使用正態(tài)分布的求和規(guī)則,噪聲將被添加到協(xié)方差矩陣中,如下所示

文章圖片48

正態(tài)分布的后驗預(yù)測分布為

文章圖片49

下一個

機器學習和深度學習中的概率分布

在貝葉斯影響中,概率分布被大量用于解決棘手的問題。

    本站是提供個人知識管理的網(wǎng)絡(luò)存儲空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點。請注意甄別內(nèi)容中的聯(lián)系方式、誘導購買等信息,謹防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊一鍵舉報。
    轉(zhuǎn)藏 分享 獻花(0

    0條評論

    發(fā)表

    請遵守用戶 評論公約

    類似文章 更多