當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python mxnet.metric.PCC用法及代碼示例

用法:

class mxnet.metric.PCC(name='pcc', output_names=None, label_names=None, has_global_stats=True)

參數

  • name(str) - 此度量實例的名稱用於顯示。
  • output_names(list of str, or None) - 使用update_dict 更新時應使用的預測名稱。默認情況下包括所有預測。
  • label_names(list of str, or None) - 使用update_dict 更新時應使用的標簽名稱。默認情況下包括所有標簽。

基礎: mxnet.metric.EvalMetric

PCC 是從 Pearson 相關係數的離散解派生的 Matthews 相關係數的多類等價物。

根據 K x K 混淆矩陣 C 定義。

當標簽超過兩個時,PCC 將不再介於 -1 和 +1 之間。相反,最小值將在 -1 和 0 之間,具體取決於真實分布。最大值始終為 +1。

例子

>>> # In this example the network almost always predicts positive
>>> false_positives = 1000
>>> false_negatives = 1
>>> true_positives = 10000
>>> true_negatives = 1
>>> predicts = [mx.nd.array(
    [[.3, .7]]*false_positives +
    [[.7, .3]]*true_negatives +
    [[.7, .3]]*false_negatives +
    [[.3, .7]]*true_positives
)]
>>> labels  = [mx.nd.array(
    [0]*(false_positives + true_negatives) +
    [1]*(false_negatives + true_positives)
)]
>>> f1 = mx.metric.F1()
>>> f1.update(preds = predicts, labels = labels)
>>> pcc = mx.metric.PCC()
>>> pcc.update(preds = predicts, labels = labels)
>>> print f1.get()
('f1', 0.95233560306652054)
>>> print pcc.get()
('pcc', 0.01917751877733392)

相關用法


注:本文由純淨天空篩選整理自apache.org大神的英文原創作品 mxnet.metric.PCC。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。