15 #ifndef PALL_PERFORMANCE_MEASURES_HPP
16 #define PALL_PERFORMANCE_MEASURES_HPP
18 #include <boost/range/combine.hpp>
19 #include <boost/range/empty.hpp>
20 #include <boost/range/size.hpp>
21 #include <boost/tuple/tuple.hpp>
39 template<
typename FloatType = double,
40 typename Probs,
typename TestResults>
41 FloatType
log_loss(Probs &&probs, TestResults &&test_results) {
42 assert(boost::size(probs) == boost::size(test_results));
43 assert(!boost::empty(probs));
46 static FloatType EPSILON{1e-6};
47 for(
auto prob_result : boost::combine(probs, test_results)) {
48 FloatType prob, result;
49 boost::tie(prob, result) = prob_result;
50 loss -= std::log(std::max(result ? prob : 1 - prob,
54 return loss / boost::size(probs);
65 template<
typename FloatType>
67 return std::exp(-log_loss);
80 template<
typename FloatType = double,
81 typename Probs,
typename TestResults>
82 FloatType
likelihood(Probs &&probs, TestResults &&test_results) {
84 std::forward<TestResults>(test_results)));
97 template<
typename FloatType = double,
98 typename Probs,
typename TestResults>
100 assert(boost::size(probs) == boost::size(test_results));
101 assert(!boost::empty(probs));
104 for(
auto prob_result : boost::combine(probs, test_results)) {
105 FloatType prob, result;
106 boost::tie(prob, result) = prob_result;
107 loss += std::abs(prob - result);
110 return loss / boost::size(probs);
FloatType log_loss(Probs &&probs, TestResults &&test_results)
FloatType likelihood_from_log_loss(FloatType log_loss)
FloatType likelihood(Probs &&probs, TestResults &&test_results)
FloatType mean_absolute_error(Probs &&probs, TestResults &&test_results)