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


R yardstick huber_loss_pseudo 偽Huber損失

計算 Pseudo-Huber 損失,即 huber_loss() 的平滑近似。與 huber_loss() 一樣,它對異常值的敏感度低於 rmse()

用法

huber_loss_pseudo(data, ...)

# S3 method for data.frame
huber_loss_pseudo(
  data,
  truth,
  estimate,
  delta = 1,
  na_rm = TRUE,
  case_weights = NULL,
  ...
)

huber_loss_pseudo_vec(
  truth,
  estimate,
  delta = 1,
  na_rm = TRUE,
  case_weights = NULL,
  ...
)

參數

data

data.frame 包含由 truthestimate 參數指定的列。

...

目前未使用。

truth

真實結果的列標識符(即 numeric )。這應該是一個不帶引號的列名,盡管此參數是通過表達式傳遞的並且支持quasiquotation(您可以不帶引號的列名)。對於 _vec() 函數,一個 numeric 向量。

estimate

預測結果的列標識符(也是 numeric )。與 truth 一樣,可以通過不同的方式指定,但主要方法是使用不帶引號的變量名稱。對於 _vec() 函數,一個 numeric 向量。

delta

單個 numeric 值。定義損失函數從二次函數過渡到線性函數的邊界。默認為 1。

na_rm

logical 值,指示在計算繼續之前是否應剝離 NA 值。

case_weights

案例權重的可選列標識符。這應該是一個不帶引號的列名稱,其計算結果為 data 中的數字列。對於 _vec() 函數,一個數值向量。

tibble 包含列 .metric.estimator.estimate 以及 1 行值。

對於分組 DataFrame ,返回的行數將與組數相同。

對於 huber_loss_pseudo_vec() ,單個 numeric 值(或 NA )。

參考

胡貝爾,P.(1964)。位置參數的穩健估計。統計年鑒,53 (1), 73-101。

理查德·哈特利 (2004)。計算機視覺中的多視圖幾何。 (第二版)。第619頁。

也可以看看

其他數字指標:ccc() , huber_loss() , iic() , mae() , mape() , mase() , mpe() , msd() , poisson_log_loss() , rmse() , rpd() , rpiq() , rsq_trad() , rsq() , smape()

其他準確度指標:ccc() , huber_loss() , iic() , mae() , mape() , mase() , mpe() , msd() , poisson_log_loss() , rmse() , smape()

作者

詹姆斯·布萊爾

例子

# Supply truth and predictions as bare column names
huber_loss_pseudo(solubility_test, solubility, prediction)
#> # A tibble: 1 × 3
#>   .metric           .estimator .estimate
#>   <chr>             <chr>          <dbl>
#> 1 huber_loss_pseudo standard       0.199

library(dplyr)

set.seed(1234)
size <- 100
times <- 10

# create 10 resamples
solubility_resampled <- bind_rows(
  replicate(
    n = times,
    expr = sample_n(solubility_test, size, replace = TRUE),
    simplify = FALSE
  ),
  .id = "resample"
)

# Compute the metric by group
metric_results <- solubility_resampled %>%
  group_by(resample) %>%
  huber_loss_pseudo(solubility, prediction)

metric_results
#> # A tibble: 10 × 4
#>    resample .metric           .estimator .estimate
#>    <chr>    <chr>             <chr>          <dbl>
#>  1 1        huber_loss_pseudo standard       0.185
#>  2 10       huber_loss_pseudo standard       0.179
#>  3 2        huber_loss_pseudo standard       0.196
#>  4 3        huber_loss_pseudo standard       0.168
#>  5 4        huber_loss_pseudo standard       0.212
#>  6 5        huber_loss_pseudo standard       0.177
#>  7 6        huber_loss_pseudo standard       0.246
#>  8 7        huber_loss_pseudo standard       0.227
#>  9 8        huber_loss_pseudo standard       0.161
#> 10 9        huber_loss_pseudo standard       0.188

# Resampled mean estimate
metric_results %>%
  summarise(avg_estimate = mean(.estimate))
#> # A tibble: 1 × 1
#>   avg_estimate
#>          <dbl>
#> 1        0.194

相關用法


注:本文由純淨天空篩選整理自Max Kuhn等大神的英文原創作品 Psuedo-Huber Loss。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。