Provides a way to create a list of metrics/performance measures from a parametrized function like the Tweedie deviance or the elementary scoring functions for expectiles.
multi_metric(fun, ...)
A named list of functions.
data <- data.frame(act = 1:10, pred = c(1:9, 12))
multi <- multi_metric(fun = deviance_tweedie, tweedie_p = c(0, seq(1, 3, by = 0.1)))
performance(data, actual = "act", predicted = "pred", metrics = multi)
#> metric value
#> 1 0 0.4000000000
#> 2 1 0.0353568864
#> 3 1.1 0.0277433337
#> 4 1.2 0.0217696386
#> 5 1.3 0.0170825127
#> 6 1.4 0.0134047978
#> 7 1.5 0.0105190563
#> 8 1.6 0.0082547003
#> 9 1.7 0.0064778947
#> 10 1.8 0.0050836368
#> 11 1.9 0.0039895436
#> 12 2 0.0031309780
#> 13 2.1 0.0024572251
#> 14 2.2 0.0019284927
#> 15 2.3 0.0015135584
#> 16 2.4 0.0011879238
#> 17 2.5 0.0009323654
#> 18 2.6 0.0007317992
#> 19 2.7 0.0005743888
#> 20 2.8 0.0004508460
#> 21 2.9 0.0003538822
#> 22 3 0.0002777778
multi <- multi_metric(
fun = r_squared,
deviance_function = deviance_tweedie, tweedie_p = c(0, seq(1, 3, by = 0.1))
)
performance(data, actual = "act", predicted = "pred", metrics = multi)
#> metric value
#> 1 0 0.9515152
#> 2 1 0.9787562
#> 3 1.1 0.9805770
#> 4 1.2 0.9822680
#> 5 1.3 0.9838366
#> 6 1.4 0.9852900
#> 7 1.5 0.9866347
#> 8 1.6 0.9878772
#> 9 1.7 0.9890236
#> 10 1.8 0.9900797
#> 11 1.9 0.9910512
#> 12 2 0.9919432
#> 13 2.1 0.9927609
#> 14 2.2 0.9935091
#> 15 2.3 0.9941923
#> 16 2.4 0.9948149
#> 17 2.5 0.9953812
#> 18 2.6 0.9958950
#> 19 2.7 0.9963602
#> 20 2.8 0.9967804
#> 21 2.9 0.9971590
#> 22 3 0.9974993
multi <- multi_metric(fun = elementary_score_expectile, theta = 1:11, alpha = 0.1)
performance(data, actual = "act", predicted = "pred", metrics = multi, key = "theta")
#> theta value
#> 1 1 0.00
#> 2 2 0.00
#> 3 3 0.00
#> 4 4 0.00
#> 5 5 0.00
#> 6 6 0.00
#> 7 7 0.00
#> 8 8 0.00
#> 9 9 0.00
#> 10 10 0.00
#> 11 11 0.09
multi <- multi_metric(fun = elementary_score_expectile, theta = 1:11, alpha = 0.5)
performance(data, actual = "act", predicted = "pred", metrics = multi, key = "theta")
#> theta value
#> 1 1 0.00
#> 2 2 0.00
#> 3 3 0.00
#> 4 4 0.00
#> 5 5 0.00
#> 6 6 0.00
#> 7 7 0.00
#> 8 8 0.00
#> 9 9 0.00
#> 10 10 0.00
#> 11 11 0.05