深度学习的不确定性(Uncertainty/confidence score)与校准(Calibration)
目錄
- 不確定性估計(uncertainty estimates)
- 什么是不確定性(uncertainty )
- 不確定性的統計學定義
- 不確定性分類
- 什么是不確定性估計值(uncertainty estimates:名詞,表示估計值)
- 為何不確定性估計重要
- 怎么生成不確定性估計(Uncertainty Estimation或者Estimating the predictive uncertainty)
- 評價不確定性估計的指標(UNCERTAINTY MEASURES AND QUALITY)
- 容易混淆的術語
- uncertainty = probability = Confidence
- uncertainty estimates、uncertainty estimation、uncertainty measure
- 相關論文
- 模型校準的概念與原理
- calibration的概念、定義與例子
- 如何評估uncertanty estimates的好壞(是否well-calibrated)
- 常用的校準方法(Calibration Methods/有時也稱recalibration methods)
- 校準方法的分析和對比
- 不確定性校準程度的評價指標
- 論文:On Calibration of Modern Neural Networks
- 樸素貝葉斯:概率類模型的評估指標
- birer score 與brier kill score
- 多分類的評價指標
- 可靠性圖與Expected Calibration Error (ECE)
- 一個好的github評價指標實現
- 與不確定性(置信度)相關的研究
不確定性估計(uncertainty estimates)
什么是不確定性(uncertainty )
不確定性的統計學定義
如何創造可信任的機器學習模型?先要理解不確定性
那「不確定性」究竟是什么?
不確定性度量反映的是一個隨機變量的離散程度(dispersion)。換句話說,這是一個標量,反應了一個隨機變量有多「隨機」。在金融領域,這通常被稱為「風險」。
不確定性不是某種單一形式,因為衡量離散程度的方法有很多:標準差、方差、風險值(VaR)和熵都是合適的度量。但是,要記住一點:單個標量數值不能描繪「隨機性」的整體圖景,因為這需要傳遞整個隨機變量本身才行!
盡管如此,為了優化和比較,將隨機性壓縮成單個數值仍然是有用的。總之要記住,「越高的不確定性」往往被視為「更糟糕」(除了在模擬強化學習實驗中)。
- xys:在深度分類模型中,隨機變量就是模型預測所得的類別,不確定性就是模型給出的盤位該類別的置信度(softmax輸出的概率分布里最大的那個值)。
監督學習中的不確定性(uncertainty quantification):筆記1
什么是不確定性(uncertianty)
關于如何定義各種不確定性,文獻中的說法普遍比較模糊。關于data uncertainty,model uncertainty,distributional uncertainty 的準確描述也有爭論。這里嘗試從頭整理。
(1)首先,data uncertainty的定義是清晰且確定的。由于系統自身和數據收集中產生的隨機性,輸出所服從的概率分布對應的預測極限,就是data uncertainty
(2)第二,關于model/distributional uncertainty的定義。我們這里還是介紹文獻中主流的model/ditributional uncertainty 定義。
Model uncertainty 定義為,給定模型所輸出條件概率分布的mode的不確定性。mode是指條件概率最大處所對應的隨即變量的值(xys:置信度的不確定性)
distributional uncertainty 一般定義為,給定模型所輸出條件概率分布的方差的不確定性。
不確定性分類
不確定估計學習小結
一般而言,不確定性可以分類兩種[2]:
- 1.數據的不確定性:也被稱為偶然(Aleatoric)不確定性,它描述的是數據中內在的噪聲,即無法避免的誤差,這個現象不能通過增加采樣數據來削弱。例如有時候拍照的手稍微顫抖畫面便會模糊,這種數據是不能通過增加拍照次數來消除的。因此解決這個問題的方法一般是提升數據采集時候的穩定性,或者提升衡量指標的精度以囊括各類客觀影響因素。
- 2.模型的不確定性:也被稱為認知(Epistemic)不確定性。它指出,模型自身對輸入數據的估計可能因為訓練不佳、訓練數據不夠等原因而不準確,與某一單獨的數據無關。因此,認知不確定性測量的,是訓練過程本身所估計的模型參數的不確定性。這種不確定性是可以通過有針對性的調整(增加訓練數據等方式)來緩解甚至解決的。
如何創造可信任的機器學習模型?先要理解不確定性
該文闡述了三種不確定性:
- 偶然不確定性
- 認知不確定性
超出分布的不確定性
用模型不確定性理解模型
1、模型不確定性,又稱認知不確定性(epistemic uncertainty):假設你有一個單一數據點,想知道哪種線性模型是最適合數據的。但是沒有數據的話,我們根本無法判斷,所以需要更多數據!
認知不確定性是由于模型的參數不確定。我們不知道模型的哪個權重能最好地表現數據,但是數據越多,不確定性越低。這種類型的不確定性在數據較少的高風險應用中很重要。
再比如,你想搭建一個模型,要在一系列動物圖片中預測哪種動物會吃掉你。假設你在訓練時給模型提供的都是獅子和長頸鹿的照片,現在模型看到了一張僵尸照片。由于之前它沒有見過僵尸,所以這里的不確定性就非常高。如果在訓練時能提供足夠的僵尸照片,那么模型的不確定性會隨之減少。
(xys:模型不確定性與數據量的關系)
2、數據不確定性
3、測量不確定性
4、噪聲標簽
《A Survey of Uncertainty in Deep Neural Networks》
These factors are mainly based on an uncertainty already included in the data (data uncertainty) or a lack of knowledgeof the neural network (model uncertainty)--------------------------《A Survey of Uncertainty in Deep Neural Networks.》
不確定性包括:(1)數據不確定性:事先存在于數據中的不確定性,(2)模型不確定性:神經網絡知識的缺乏(模型沒有訓練好,模型能力不夠)
什么是不確定性估計值(uncertainty estimates:名詞,表示估計值)
Estimating the predictive uncertainty is not sufficient for safe decision-making. Furthermore, it is crucialto assure that the uncertainty estimates are reliable.To this end,the calibration property (the degree of reliability) of DNNs has been investigated and re-calibration methods have been proposed [15], [47], [48] to obtain reliable (well-calibrated)uncertainty estimates.--------------------------《A Survey of Uncertainty in Deep Neural Networks.》
- Estimating the predictive uncertainty:動詞,指的是產生不確定性值的過程和方法
- the uncertainty estimates:名詞,指的是不確定性估計值(不確定性值)。例如,在分類問題中,用softmax輸出的概率分布、或者softmax輸出的概率分布中的最大值(置信度)作為不確定性估計值。
- reliable (well-calibrated)uncertainty estimates:可靠的(well-calibrated)不確定性估計值
- calibration property:可靠性程度,一般用calibration error來衡量。
- re-calibration methods:使不確定性值更加可靠的方法
Through a series of experiments on classification and regression benchmarks, we demonstrate that our method produces well-calibrated uncertainty estimates which are as good or better than approximate Bayesian NNs-----《Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles》
- well-calibrated uncertainty estimates,明顯可以看出uncertainty estimates指的是模型輸出的預測概率值。(estimate可以作為名詞)
- Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles,可以看出Uncertainty Estimation指的是通過某種方法產生不確定性估計值(產生uncertainty estimates)。
不確定估計學習小結(筆者認為其理解并不太好)
(1)以人臉識別為例,輸入一張人臉圖像,得到一個特征向量embedding,將此特征向量與底庫中的特征向量計算相似度,從而根據此相似度來判斷兩張人臉圖像是否屬于同一個ID。假設相似度很高(95%),則認為這兩張人臉圖像屬于同一個人。這種將一張輸入圖像x映射到高維空間中的一個點embedding的方式,可以被稱為確定性預測(deterministic prediction)。
但以同樣的人臉系統、相同的底庫來看,假設我們輸入一張很模糊的人臉或者一張貓的圖片,此時系統可能會給出同樣是95%的相似度。然而,在這種情形下,這種相似度得分并不能反映出兩張圖片是屬于同一ID的,即這個相似度結果不可信。因此,我們不僅需要一個相似度得分,還需要一個能判斷此相似度是否可信的得分。具體而言,假設在此種情形下,即使兩種圖片的相似度得分是95%,但只有10%的得分認為該相似度得分可行,那么做出判斷就需要更加謹慎。
(2)再舉一個例子,假設我們使用了cifar100來訓練了一個分類模型,現在用戶隨意找了張不屬于此100類的圖片(例如貓),輸入到該分類模型中,那么這個“貓”必然會分類到cifar100中的其中一個類別,例如認為是飛機。從模型來看,這個分類置信度得分可能很高,堅定認為這個“貓”就是“飛機”;從人的認識來看,此次分類結果是失敗的。面對這種情況,我們希望模型不僅能給出分類的置信度得分,還希望模型能給出一個判斷此次置信度得分是否可信的判斷。(xys認為更好的說法:我們希望模型不僅能給出分類的置信度得分,還希望模型能給出的置信度能恰好等于模型真實的預測準確率。因為分類問題中模型的最終輸出是類別,而置信度是模型對判斷為該類別的信心程度,已經是對模型給出的此次決策的可信程度的判斷了)
(3)從上面幾個案例來看,無論是相似度得分還是置信度得分,都不一定可信,即模型對于給出的判斷具有一定程度的“不確定性”。那么,我們就希望知道模型對于此次判斷有多少把握,對于“不確定性”得分高的判斷(即把握度低),我們可以進行額外的處理操作。(xys:要使模型給出的不確定性估計是可靠的,就需要對模型進行校準,使得模型達到well-calibrated的狀態。)
- xys—對模型給出的得分或置信度等進行可靠性的估計(是否可信,以及可信任的程度),即為不確定性估計。也可認為:不確定性估計 = 計算置信度與真實準確率之間的誤差程度。(該解釋是筆者對上述引文的直接理解,但實際上筆者認為深度學習領域很少這樣理解"uncertainty estimates")
- xys—如果模型給出的得分或置信度正好能準確地表示預測結果的可信任程度(即置信度恰好等于樣本的準確率),那么就說模型是well-calibrated的。
- xys—然而,在深度學習中,很多時候會將“模型輸出的置信度”與“uncertainty estimates”兩個詞混用。意思是:模型輸出的置信度(通常為一個表示類別概率的小數)就表示了最終預測類別的不確定性(可能性)。即uncertainty esimates= uncertainty= probability = Confidence。例如:We propose an alternative to Bayesian neural networks, that is simple to implement, readily parallelisable and yields high quality predictive uncertainty estimates.--------《Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles》
這里,“uncertainty estimates”指的是模型輸出的置信度,而不是“計算置信度與真實準確率之間的誤差程度”。
為何不確定性估計重要
R TALK | 曠視危夷晨:不確定性學習在視覺識別中的應用
上面介紹完之后,我們再來談談它為什么重要。簡單來講,不確定性估計在深度學習之中有著廣泛的應用場景,為其落地發揮著不可替代的重要作用,下面講一些比較要代表性的場景:
- 高風險應用場景。這類場景需要非常精確的估計,因為一旦估計錯誤,可能出現嚴重的后果,例如醫療圖像診斷、自動駕駛。
- 大量機器學習場景。比如,在主動學習(Active Learning)這種技術框架中,模型需要確定哪些樣本更值得被打標簽。這也涉及到系統對于估計樣本“價值程度”不確定性。同時,的研究人員往往也會發現單純使用機器學習系統進行判斷時,會存在少量樣本系統無法做出很好的判斷,因此這時人們會邀請專家來標記這部分困難樣本,以訓練模型。
- 強化學習。強化學習由于經常要權衡exploration和exploitation操作,因此如何確定每一臺機器的概率分布是否被準確估計,就是對這臺機器模型參數的不確定性估計。
- 對處于訓練數據分布之外情況的檢測。由于很多時候測試數據并不在訓練數據中,因此如果測試數據超出了訓練數據的數據分布,那這樣的預測是沒有準確度可言的,這時候就需要一個額外的不確定性估計來確認對當前的預測有多大把握。
如何創造可信任的機器學習模型?先要理解不確定性
校準:下一件大事?
警告:只是因為一個模型能夠確定一個預測結果的置信區間,并不意味著該置信區間能真正反映結果在現實中的實際概率!
展望未來,如果我們要信任部署在現實世界中的機器學習系統(機器人、醫療系統等),我認為「證明我們的模型能夠正確理解世界」的一種遠遠更為強大方法是針對統計校準測試它們。優良的校準也意味著優良的準確度,所以這是一個更嚴格的更高的優化指標。
用模型不確定性理解模型
你為什么應該關注不確定性?
1、一個重要的例子就是高風險的應用,假設你正在創建一個模型,可以幫助醫生判斷病人的嚴重程度。在這種情況下,我們不應該僅僅關心模型的精確度,更要關注模型對其預測結果有多大程度的肯定。如果不確定性太高,醫生需要謹慎決策。
2、自動駕駛汽車是另外一個有趣的例子。如果模型不確定是否有行人在馬路上,我們可以利用這一信息讓車子減速,或者發出警報讓駕駛員手動操作。
3、不確定性還可以在缺乏數據樣本的情況下幫助我們。如果模型不是在與樣本相似的數據上訓練的,它可能無法輸出想要的結果。谷歌照片曾經將黑種人錯誤地認成了大猩猩,就是由于這個原因,種類單一的訓練集可能導致令人尷尬的結果。
4、不確定性的最大用途,也是本文的主要目的,就是為模型排除錯誤。
怎么生成不確定性估計(Uncertainty Estimation或者Estimating the predictive uncertainty)
《A Survey of Uncertainty in Deep Neural Networks.》第三部分:
- Single deterministic methods give the prediction basedon one single forward pass within a deterministic network. The uncertainty quantification is either derivedby using additional (external) methods or is directly predicted by the network(xys:就是將模型直接輸出的某個值(如softmax或置信度)當做不確定性估計值)
- Bayesian methods cover all kinds of stochastic DNNs,i.e. DNNs where two forward passes of the same samplegenerally lead to different results.
- Ensemble methods combine the predictions of severaldifferent deterministic networks at inference.(集成方法)
- Test-time augmentation methods give the predictionbased on one single deterministic network but augmentthe input data at test-time in order to generate several predictions that are used to evaluate the certainty of the prediction.(測試時,將數據多次增廣,分別輸入模型獲得多個預測,然后據此來計算預測的不確定性)
評價不確定性估計的指標(UNCERTAINTY MEASURES AND QUALITY)
《A Survey of Uncertainty in Deep Neural Networks.》第四部分:UNCERTAINTY MEASURES AND QUALITY
uncertainty estimation與uncertaity measures/quality有區別:
- uncertainty estimation:產生表示不確定性的概率值或者置信度的過程或方法(=Estimating the predictive uncertainty)。
- uncertaity measures/quality:對各種uncertainty estimation的測量/質量,即定量計算這些uncertainty estimation的好壞。主要是采用一些指標如softmax的最大值、熵、互信息、KL散度、softmax的均值和方差等等)
容易混淆的術語
uncertainty = probability = Confidence
Confidence calibration – the problem of predicting probability estimates representative of the true correctness likelihood – is important forclassification models in many applications.----《On Calibration of Modern Neural Networks》
- uncertainty = probability = Confidence , 不確定性=概率=置信度
- Confidence calibration = uncertainty calibration,
- predicting probability estimates,這里的estimate意為“估計值”(其實就是指這個probability)
有時會見到術語predicting uncertainty estimates ,其實也就是"不確定性(概率)估計值"。
所以predicting uncertainty estimates = predicting probability estimates(這里estimate作為名詞, estimate=Estimation)
a network should provide a calibrated confidence measure in addition to its prediction.
Calibrated confidence estimates are also important for model interpretability
----------《Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles》
- uncertainty = probability = Confidence , 不確定性=概率=置信度
- estimate =measure(xys:這里measure不太規范,在《A Survey of Uncertainty in Deep Neural Networks》中,estimate 和measure有區別:
— --uncertainty estimate :模型輸出的表示不確定性的概率值或者置信度。
------uncertaity measures/quality:對各種uncertainty estimate 的測量/質量,即定量計算這些uncertainty estimation的好壞。主要是采用一些指標如softmax的最大值、熵、互信息、KL散度、softmax的均值和方差等等)
uncertainty estimates、uncertainty estimation、uncertainty measure
參見論文:《A Survey of Uncertainty in Deep Neural Networks.》
- predictive uncertainty estimates:指的是模型輸出的預測概率值。(estimate可以作為名詞)
- uncertainty estimation:產生表示不確定性的概率值或者置信度的過程或方法(=Estimating the predictive uncertainty)。
- uncertaity measures/quality:對各種uncertainty estimation的測量/質量,即定量計算這些uncertainty estimation的好壞。主要是采用一些指標如softmax的最大值、熵、互信息、KL散度、softmax的均值和方差等等)
相關論文
Uncertainty 相關論文
模型校準的概念與原理
Calibration: 一個工業價值極大,學術界卻鮮有研究的問題!(原論文:On Calibration of Modern Neural Networks,論文中有一些基本的校準方法,包括溫度縮放Temperature Scaling)
在大多情況下,我們只關心類別的預測 有多準,根本不 care 置信度是怎樣的。然而,在一些實際應用場景下,置信度的度量也同樣重要。
例如 對于自動駕駛中的目標識別任務,車輛的前方出現了一個人,神經網絡會將其識別成塑料袋,此時輸出的置信度為50%(低于閾值),則可通過其它傳感器進行二次的正確識別(識別為人)。但想想看,若神經網絡對塑料袋預測的置信度為90%會怎樣?
再例如,使用 Resnet 模型簡單的對一些圖片任務進行訓練,收斂后的模型對測試集的平均置信度高達80%-85%,然而只有將近70%的圖片能被正確分對(紅色代表分錯,綠色代表分對)。這意味著啥?訓練好的模型好像有點盲目自信,即出現 overconfidence 現象,或者可以稱為模型的準確率和置信度不匹配(miscalibration)。
Expected Calibration Error (ECE)模型校準原理解析
?模型校準就是要讓模型結果預測概率和真實的經驗概率保持一致。說人話也就是,在一個二分類任務中取出大量(M個)模型預測概率為0.6的樣本,其中有0.6M個樣本真實的標簽是1。總結一下,就是模型在預測的時候說某一個樣本的概率為0.6,這個樣本就真的有0.6的概率是標簽為1。
?上面是一個正面的例子,下面我再來舉一個反面的例子說明模型校準的重要性。還是在一個二分類任務中取出大量(M個)模型預測概率為0.6的樣本,而這些樣本的真實標簽全部都是1。雖然從accuracy的角度來考察,模型預測樣本概率為0.6最后輸出時會被賦予的標簽就是1,即accuracy是100%。但是從置信度的角度來考察,這個模型明顯不夠自信,本來這些全部都是標簽為1的樣本,我們肯定希望這個模型自信一點,輸出預測概率的時候也是1。
?
如何創造可信任的機器學習模型?先要理解不確定性
Hinton等人最新研究:大幅提升模型準確率,標簽平滑技術到底怎么用?
本文通過實驗證明,標簽平滑不僅能夠提升模型的泛化能力,還能夠提升模型的修正能力,并進一步提高模型的集束搜索能力。
calibration的概念、定義與例子
所謂校準:預測置信度與事件發生的真實概率的匹配程度,二者相等即為well-calibrated,否則就存在calobration error。
Firstly, we shall examine calibration [12, 13], a frequentist notion of uncertainty which measures the discrepancy between subjective forecasts and(empirical) long-run frequencies.
The quality of calibration can be measured by proper scoring rules[17] such as log predictive probabilities and the Brier score [9]. Note that calibration is an orthogonal concern to accuracy: a network’s predictions may be accurate and yet miscalibrated, and vice versa
------《Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles》
- calibration的定義和參考文獻
- The quality of calibration 校準的質量可以通過布里爾分數等來測量
The probability that a system outputs for an event should reflect the true frequency of that event: ifan automated diagnosis system says 1,000 patients have cancer with probability 0.1, approximately100 of them should indeed have cancer. In this case, we say the model is uncertainty calibrated.------《Verified Uncertainty Calibration》
a network should provide a calibrated confidence measure in addition to its prediction. In other words, the probability associated with the predicted class label should reflect its ground truth correctness likelihood. -------《Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles》
- 什么是一個校準好的confidence measure
Let h be a neural network with h(X)=(?Y,?P)h(X) =( ?Y , ?P)h(X)=(?Y,?P), where ?Y is a class prediction and ?P is its associated confidence, i.e. probability of correctness. We wouldlike the confidence estimate ?P to be calibrated, which in-tuitively means that ?P represents a true probability. Forexample, given 100 predictions, each with confidence of 0.8, we expect that 80 should be correctly classified. Moreformally, we define perfect calibration as ----《On Calibration of Modern Neural Networks》
- calibration的公式定義,舉例
如何評估uncertanty estimates的好壞(是否well-calibrated)
NLL is a proper scoring rule and a popular metric for evaluating predictive uncertainty [49]. For classification we additionally measure classification accuracy andthe Brier score-----《Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles》
- evaluating predictive uncertainty:評估不確定性,即對不確定性的校準情況(校準:置信度與真實概率的匹配情況)進行評估。它與uncertainty estimates是兩個概念。
A clas-sifier is well-calibrated, if the probability associated withthe predicted class label matches the probability of suchprediction being correct (Br ?ocker, 2009; Dawid, 1982)
- well-calibrated的參考文獻
More formally, we define perfect calibration(well-calibrated) as: ------------《On Calibration of Modern Neural Networks》
- perfect calibration或well-calibrated的公式化定義
Definition 2.1. The classifier f is perfectly calibrated, if for any input instances x ∈X, the prediction and the canonical calibration probabilities match: z = π(z) (Dawid, 1982)----------《Mix-n-Match : Ensemble and Compositional Methods for Uncertainty Calibration in Deep Learning》
Definition 2.3 (Top-label calibration error). The top-label calibration error examines the difference between the model’s probability for its top prediction and the true probability of that prediction given the model’s output:-----------------《Verified Uncertainty Calibration》
- 多分類情況下,calobration error的公式化定義
常用的校準方法(Calibration Methods/有時也稱recalibration methods)
《A Survey of Uncertainty in Deep Neural Networks》
- Regularization methods applied during the training phase(如lable smooth,mixup等)
- Post-processing methods applied after the training pro-cess of the DNN(后處理,如temperature scaling)
- Neural network uncertainty estimation methods(如集成學習、貝葉斯方法)
《On Calibration of Modern Neural Networks 》的calibration methods一節有大量的校準方法。
Uncertainty Calibration Library----對應文章:Verified Uncertainty Calibration
深度學習模型不確定性校準方法對比
(NeurIPS 2019 的 Can You Trust Your Model’s Uncertainty? Evaluating
Predictive Uncertainty Under Dataset Shift 論文為主線,回顧近年頂級機器學習會議對于
dataset shift 和 out-of-distribution dataset 問題相關的論文,包括了 Temperature
scaling [1],DeepEnsemble [2],Monte-Carlo Dropout [3] 等方法)
pytorch神經網絡_使用pytorch進行神經網絡校準(溫度縮放Temperature Scaling)
https://github-dotcom.gateway.web.tr/gpleiss/temperature_scaling(基于pytorch的模型校準:temperature_scaling)
A simple way to calibrate your neural network. The temperature_scaling.py module can be easily used to calibrated any trained model.
Based on results from On Calibration of Modern Neural Networks.
Learning Confidence for Out-of-Distribution Detection in Neural Networks
《在神經網絡中計算置信度用于域外檢測》閱讀筆記
校準方法的分析和對比
《Verified Uncertainty Calibration》----分析了scaling系列方法(Plattscaling [12], isotonic regression [13], and temperature scaling)和histogram binning方法的優缺點
《Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles》分析了貝葉斯方法、MC-dropout方法的優缺點
《Mix-n-Match : Ensemble and Compositional Methods for Uncertainty Calibration in Deep Learning
》-----
- introduction部分將校準方法進行了分類:后驗校準(post-hoc manner.),前置校準(ab-initio well calibrated model)
- introduction部分介紹了深度學習的校準方法(也屬于后驗方法):Recently, calibra-tion methods for multi-class deep neural network classifiershave been developed, which include: temperature, vector& matrix scaling (Guo et al., 2017), Dirichlet scaling (Kullet al., 2019), intra order-preserving method (Rahimi et al.,2020) and Gaussian processes based calibration methods(Milios et al., 2018; Wenger et al., 2020)
- 2.1節將校準方法分為:參數化方法、非參數化方法
不確定性校準程度的評價指標
論文:On Calibration of Modern Neural Networks
有四個指標的公式化定義:
- Reliability Diagrams
- Expected Calibration Error (ECE)
- Maximum Calibration Error (MCE)
- Negative log likelihood
In the case ofmulti-class K-way classification, the popular softmax cross entropy loss is equivalent to the log likelihood and is a proper scoring rule. Interestingly, L(θ) = ?S(pθ,(y,x)) = K?1 ∑Kk=1(δk=y ?pθ(y = k|x))2, i.e., minimizing the squared error between the predictive probability of a label and one-hot encoding of the correct label, is also a proper scoring rule known as the Brier score [9].-----《Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles》
- 對多分類問題,softmax交叉熵=對數似然
- 布里爾分數=預測概率與one-hot標簽之間的平方誤差
樸素貝葉斯:概率類模型的評估指標
內容包括(基于sklearn的代碼):
1.布里爾分數Brier Score
2.對數似然函數Log Loss
3.可靠性曲線Reliability Curve
4.預測概率的直方圖
5.校準可靠性曲線
birer score 與brier kill score
Brier Score – How to measure accuracy of probablistic predictions
What is a Brier Score?
While the Brier Score (BS) tells you how good a model is, it is still not a relative metric. That is, it does not tell you how good a model is compared to others. A useful metric to compare the performance of one more in comparison with another is the ‘Brier Skill Score’.
Brier Skill Score = (BSE – BSN) / BSE
where: BSE = Brier Score of existing model
BSN = Brier Score of new model
If a Brier Skill Score is positive, then the new model makes more accurate predictions. If the Brier Skill Score is negative, then the new model makes worse predictions. And if the Brier Skill Score is equal to zero, then the new model offers no improvement over the existing model.
For example,
suppose our existing model has a Brier Score of BSE = 0.4221 and our new model has a Brier Score of BSN = 0.3352. The Brier Skill Score of our new model can be calculated as:
Brier Skill Score = (0.4421 – 0.3352) / (0.4421) = 0.2418.
Since this number is positive, it’s an indication that our new model provides more accurate forecasts relative to the existing model.
The higher the Brier Skill Score, the bigger the improvement is in the new model compared to the existing model.
多分類的評價指標
摘自:(Calibration of Convolutional Neural Networks)
多分類的布里爾分數Brier Score計算
briercalc: Brier Scores (and decompositions) for multiple classes(代碼)
In the case ofmulti-class K-way classification, the popular softmax cross entropy loss is equivalent to the log likelihood and is a proper scoring rule. Interestingly, L(θ) = ?S(pθ,(y,x)) = K?1 ∑Kk=1(δk=y ?pθ(y = k|x))2, i.e., minimizing the squared error between the predictive probability of a label and one-hot encoding of the correct label, is also a proper scoring rule known as the Brier score [9].-----《Simple and Scalable Predictive Uncertainty Estimation using Deep Ensembles》
- 對多分類問題,softmax交叉熵=對數似然
- 布里爾分數=預測概率與one-hot標簽之間的平方誤差
可靠性圖與Expected Calibration Error (ECE)
marcoromanelli-github/ReliabilityDiagrams(從模型輸出的softmaxt開始進行計算,又詳細的注釋)
hollance/reliability-diagrams(對圖形有詳細的解釋,論文中可以借鑒)
zygmuntz/classifier-calibration(包含兩種校準方法)
ECE的計算公式參照:Expected Calibration Error (ECE)模型校準原理解析(ECE公式是基于可靠性圖的bin分區的)
一個好的github評價指標實現
https://github.com/markus93/NN_calibration/tree/master/scripts/calibration
(對應的文章:Calibration of Convolutional Neural Networks)
與不確定性(置信度)相關的研究
- 對置信度不高的分類結果進行后處理:
CAN:借助先驗分布提升分類性能的簡單后處理技巧
CAN: 借助數據分布提升分類性能
模型訓練Tricks——后處理:利用訓練集先驗類別提升分類預測效果
總結
以上是生活随笔為你收集整理的深度学习的不确定性(Uncertainty/confidence score)与校准(Calibration)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: nico和niconiconi dp
- 下一篇: 牛客dp nico和niconiconi