mlpack
f1.hpp
Go to the documentation of this file.
1 
12 #ifndef MLPACK_CORE_CV_METRICS_F1_HPP
13 #define MLPACK_CORE_CV_METRICS_F1_HPP
14 
15 #include <type_traits>
16 
17 #include <mlpack/core.hpp>
19 
20 namespace mlpack {
21 namespace cv {
22 
44 template<AverageStrategy AS, size_t PositiveClass = 1>
45 class F1
46 {
47  public:
55  template<typename MLAlgorithm, typename DataType>
56  static double Evaluate(MLAlgorithm& model,
57  const DataType& data,
58  const arma::Row<size_t>& labels);
59 
64  static const bool NeedsMinimization = false;
65 
66  private:
70  template<AverageStrategy _AS,
71  typename MLAlgorithm,
72  typename DataType,
73  typename = std::enable_if_t<_AS == Binary>>
74  static double Evaluate(MLAlgorithm& model,
75  const DataType& data,
76  const arma::Row<size_t>& labels);
77 
81  template<AverageStrategy _AS,
82  typename MLAlgorithm,
83  typename DataType,
84  typename = std::enable_if_t<_AS == Micro>,
85  typename = void>
86  static double Evaluate(MLAlgorithm& model,
87  const DataType& data,
88  const arma::Row<size_t>& labels);
89 
93  template<AverageStrategy _AS,
94  typename MLAlgorithm,
95  typename DataType,
96  typename = std::enable_if_t<_AS == Macro>,
97  typename = void,
98  typename = void>
99  static double Evaluate(MLAlgorithm& model,
100  const DataType& data,
101  const arma::Row<size_t>& labels);
102 };
103 
104 } // namespace cv
105 } // namespace mlpack
106 
107 // Include implementation.
108 #include "f1_impl.hpp"
109 
110 #endif
Linear algebra utility functions, generally performed on matrices or vectors.
Definition: cv.hpp:1
static const bool NeedsMinimization
Information for hyper-parameter tuning code.
Definition: f1.hpp:64
static double Evaluate(MLAlgorithm &model, const DataType &data, const arma::Row< size_t > &labels)
Run classification and calculate F1.
Definition: f1_impl.hpp:22
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...
F1 is a metric of performance for classification algorithms that for binary classification is equal t...
Definition: f1.hpp:45
AverageStrategy
This enum declares possible strategies for averaging that can be used in some metrics like precision...
Definition: average_strategy.hpp:25